• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

graphty-org / graphty-element / 16281745178

15 Jul 2025 01:24AM UTC coverage: 70.353% (-2.2%) from 72.536%
16281745178

push

github

apowers313
fix: build and optional argument fixes

735 of 934 branches covered (78.69%)

Branch coverage included in aggregate %.

7 of 8 new or added lines in 2 files covered. (87.5%)

878 existing lines in 24 files now uncovered.

4742 of 6851 relevant lines covered (69.22%)

311.14 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.35
/src/layout/MultipartiteLayoutEngine.ts
1
import {Edge as LayoutEdge, multipartiteLayout, Node as LayoutNode} from "@graphty/layout";
2✔
2
import {z} from "zod/v4";
2✔
3

4
import {SimpleLayoutConfig, SimpleLayoutEngine} from "./LayoutEngine";
2✔
5

6
export const MultipartiteLayoutConfig = z.strictObject({
2✔
7
    ... SimpleLayoutConfig.shape,
2✔
8
    // subsetKey: z.string().or(z.record(z.number(), z.array(z.string().or(z.number())))),
9
    subsetKey: z.record(z.string(), z.array(z.string().or(z.number()))),
2✔
10
    align: z.enum(["vertical", "horizontal"]).default("vertical"),
2✔
11
    scale: z.number().positive().default(1),
2✔
12
    center: z.array(z.number()).length(2).or(z.null()).default(null),
2✔
13
});
2✔
14
export type MultipartiteLayoutConfigType = z.infer<typeof MultipartiteLayoutConfig>;
15
export type MultipartiteLayoutOpts = Partial<MultipartiteLayoutConfigType>;
16

17
export class MultipartiteLayout extends SimpleLayoutEngine {
2✔
18
    static type = "multipartite";
2✔
19
    static maxDimensions = 2;
2✔
20
    scalingFactor = 40;
2✔
21
    config: MultipartiteLayoutConfigType;
22

23
    constructor(opts: MultipartiteLayoutOpts) {
2✔
24
        super(opts);
1✔
25
        this.config = MultipartiteLayoutConfig.parse(opts);
1✔
26
    }
1✔
27

28
    static getOptionsForDimension(dimension: 2 | 3): object | null {
2✔
29
        // Multipartite only supports 2D
30
        if (dimension > this.maxDimensions) {
1✔
31
            return null;
1✔
32
        }
1!
33

34
        // Multipartite doesn't use 'dim' parameter
UNCOV
35
        return {};
×
36
    }
1✔
37

38
    doLayout(): void {
2✔
39
        this.stale = false;
1✔
40
        const nodes = (): LayoutNode[] => this._nodes.map((n) => n.id as LayoutNode);
1✔
41
        const edges = (): LayoutEdge[] => this._edges.map((e) => [e.srcId, e.dstId] as LayoutEdge);
1✔
42

43
        this.positions = multipartiteLayout(
1✔
44
            {nodes, edges},
1✔
45
            this.config.subsetKey,
1✔
46
            this.config.align,
1✔
47
            this.config.scale,
1✔
48
            this.config.center,
1✔
49
        );
1✔
50
    }
1✔
51
}
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc