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

graphty-org / graphty-element / 16232812979

12 Jul 2025 12:28AM UTC coverage: 70.153% (+2.5%) from 67.674%
16232812979

push

github

apowers313
test: add tests for PointerRenderer

465 of 661 branches covered (70.35%)

Branch coverage included in aggregate %.

3801 of 5420 relevant lines covered (70.13%)

1174.4 hits per line

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

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

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

6
export const ForceAtlas2LayoutConfig = z.strictObject({
1✔
7
    ... SimpleLayoutConfig.shape,
1✔
8
    pos: z.record(z.number(), z.array(z.number()).min(2).max(3)).or(z.null()).default(null),
1✔
9
    maxIter: z.number().positive().default(100),
1✔
10
    jitterTolerance: z.number().positive().default(1.0),
1✔
11
    scalingRatio: z.number().positive().default(2.0),
1✔
12
    gravity: z.number().positive().default(1.0),
1✔
13
    distributedAction: z.boolean().default(false),
1✔
14
    strongGravity: z.boolean().default(false),
1✔
15
    nodeMass: z.record(z.number(), z.number()).or(z.null()).default(null),
1✔
16
    nodeSize: z.record(z.number(), z.number()).or(z.null()).default(null),
1✔
17
    weightPath: z.string().or(z.null()).default(null),
1✔
18
    dissuadeHubs: z.boolean().default(false),
1✔
19
    linlog: z.boolean().default(false),
1✔
20
    seed: z.number().or(z.null()).default(null),
1✔
21
    dim: z.number().default(2),
1✔
22
});
1✔
23
export type ForceAtlas2LayoutConfigType = z.infer<typeof ForceAtlas2LayoutConfig>;
24
export type ForceAtlas2LayoutOpts = Partial<ForceAtlas2LayoutConfigType>;
25

26
export class ForceAtlas2Layout extends SimpleLayoutEngine {
1✔
27
    static type = "forceatlas2";
1✔
28
    static maxDimensions = 3;
1✔
29
    scalingFactor = 100;
1✔
30
    config: ForceAtlas2LayoutConfigType;
31

32
    constructor(opts: ForceAtlas2LayoutOpts) {
1✔
33
        super(opts);
1✔
34
        this.config = ForceAtlas2LayoutConfig.parse(opts);
1✔
35
    }
1✔
36

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

42
        this.positions = forceatlas2Layout(
×
43
            {nodes, edges},
×
44
            this.config.pos,
×
45
            this.config.maxIter,
×
46
            this.config.jitterTolerance,
×
47
            this.config.scalingRatio,
×
48
            this.config.gravity,
×
49
            this.config.distributedAction,
×
50
            this.config.strongGravity,
×
51
            this.config.nodeMass,
×
52
            this.config.nodeSize,
×
53
            this.config.weightPath,
×
54
            this.config.dissuadeHubs,
×
55
            this.config.linlog,
×
56
            this.config.seed,
×
57
            this.config.dim,
×
58
        );
×
59
    }
×
60
}
1✔
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