@antv/layout 1.0.0-alpha.17 → 1.0.0-alpha.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/a79631be14145535191e.worker.js +2 -0
  2. package/dist/a79631be14145535191e.worker.js.map +1 -0
  3. package/dist/index.min.js +1 -1
  4. package/dist/index.min.js.map +1 -1
  5. package/esm/a79631be14145535191e.worker.js +2 -0
  6. package/esm/a79631be14145535191e.worker.js.map +1 -0
  7. package/esm/index.esm.js +1 -1
  8. package/esm/index.esm.js.map +1 -1
  9. package/lib/dagre/acyclic.d.ts +4 -0
  10. package/lib/dagre/add-border-segments.d.ts +2 -0
  11. package/lib/dagre/coordinate-system.d.ts +4 -0
  12. package/lib/dagre/data/list.d.ts +12 -0
  13. package/lib/dagre/greedy-fas.d.ts +3 -0
  14. package/lib/dagre/layout.d.ts +18 -0
  15. package/lib/dagre/nesting-graph.d.ts +8 -0
  16. package/lib/dagre/normalize.d.ts +5 -0
  17. package/lib/dagre/order/add-subgraph-constraints.d.ts +3 -0
  18. package/lib/dagre/order/barycenter.d.ts +14 -0
  19. package/lib/dagre/order/build-layer-graph.d.ts +3 -0
  20. package/lib/dagre/order/cross-count.d.ts +3 -0
  21. package/lib/dagre/order/index.d.ts +2 -0
  22. package/lib/dagre/order/init-data-order.d.ts +6 -0
  23. package/lib/dagre/order/init-order.d.ts +3 -0
  24. package/lib/dagre/order/resolve-conflicts.d.ts +20 -0
  25. package/lib/dagre/order/sort-subgraph.d.ts +7 -0
  26. package/lib/dagre/order/sort.d.ts +7 -0
  27. package/lib/dagre/parent-dummy-chains.d.ts +3 -0
  28. package/lib/dagre/position/bk.d.ts +25 -0
  29. package/lib/dagre/position/index.d.ts +7 -0
  30. package/lib/dagre/rank/feasible-tree.d.ts +5 -0
  31. package/lib/dagre/rank/index.d.ts +2 -0
  32. package/lib/dagre/rank/network-simplex.d.ts +16 -0
  33. package/lib/dagre/rank/util.d.ts +6 -0
  34. package/lib/dagre/util.d.ts +35 -0
  35. package/lib/dagre.d.ts +31 -0
  36. package/lib/index.d.ts +1 -0
  37. package/lib/types.d.ts +33 -4
  38. package/lib/util/common.d.ts +15 -0
  39. package/lib/util/function.d.ts +7 -0
  40. package/package.json +1 -1
  41. package/dist/6b692814699bee26e220.worker.js +0 -2
  42. package/dist/6b692814699bee26e220.worker.js.map +0 -1
  43. package/esm/6b692814699bee26e220.worker.js +0 -2
  44. package/esm/6b692814699bee26e220.worker.js.map +0 -1
@@ -0,0 +1,4 @@
1
+ import { Graph } from "../types";
2
+ declare const run: (g: Graph, acyclicer: string) => void;
3
+ declare const undo: (g: Graph) => void;
4
+ export { run, undo };
@@ -0,0 +1,2 @@
1
+ import { Graph } from "../types";
2
+ export declare const addBorderSegments: (g: Graph) => void;
@@ -0,0 +1,4 @@
1
+ import { DagreRankdir, Graph } from "../types";
2
+ declare const adjust: (g: Graph, rankdir: DagreRankdir) => void;
3
+ declare const undo: (g: Graph, rankdir: DagreRankdir) => void;
4
+ export { adjust, undo };
@@ -0,0 +1,12 @@
1
+ type LinkedNode<T> = {
2
+ prev?: LinkedNode<T>;
3
+ next?: LinkedNode<T>;
4
+ } & T;
5
+ export default class List<T> {
6
+ shortcut: LinkedNode<T>;
7
+ constructor();
8
+ dequeue(): LinkedNode<T> | undefined;
9
+ enqueue(entry: LinkedNode<T>): void;
10
+ toString(): string;
11
+ }
12
+ export {};
@@ -0,0 +1,3 @@
1
+ import { Edge } from "@antv/graphlib";
2
+ import { EdgeData, Graph as IGraph } from "../types";
3
+ export declare const greedyFAS: (g: IGraph, weightFn?: ((e: Edge<EdgeData>) => number) | undefined) => Edge<EdgeData>[];
@@ -0,0 +1,18 @@
1
+ import { ID } from "@antv/graphlib";
2
+ import { DagreAlign, DagreRankdir, Graph as IGraph } from "../types";
3
+ export declare const layout: (g: IGraph, options: {
4
+ keepNodeOrder: boolean;
5
+ prevGraph: IGraph | null;
6
+ edgeLabelSpace?: boolean | undefined;
7
+ align?: DagreAlign | undefined;
8
+ nodesep?: number | undefined;
9
+ edgesep?: number | undefined;
10
+ ranksep?: number | undefined;
11
+ acyclicer: string;
12
+ nodeOrder: ID[];
13
+ ranker: "network-simplex" | "tight-tree" | "longest-path";
14
+ rankdir: DagreRankdir;
15
+ }) => {
16
+ width: number;
17
+ height: number;
18
+ } | undefined;
@@ -0,0 +1,8 @@
1
+ import { ID } from "@antv/graphlib";
2
+ import { Graph as IGraph } from "../types";
3
+ declare const run: (g: IGraph) => {
4
+ nestingRoot: ID;
5
+ nodeRankFactor: number;
6
+ };
7
+ declare const cleanup: (g: IGraph, nestingRoot?: ID) => void;
8
+ export { run, cleanup };
@@ -0,0 +1,5 @@
1
+ import { ID } from "@antv/graphlib";
2
+ import { Graph as IGraph } from "../types";
3
+ declare const run: (g: IGraph, dummyChains: ID[]) => void;
4
+ declare const undo: (g: IGraph, dummyChains: ID[]) => void;
5
+ export { run, undo };
@@ -0,0 +1,3 @@
1
+ import { ID } from "@antv/graphlib";
2
+ import { Graph } from "../../types";
3
+ export declare const addSubgraphConstraints: (g: Graph, cg: Graph, vs: ID[]) => void;
@@ -0,0 +1,14 @@
1
+ import { ID } from "@antv/graphlib";
2
+ import { Graph } from "../../types";
3
+ /**
4
+ * TODO: The median method consistently performs better than the barycenter method and has a slight theoretical advantage
5
+ */
6
+ export declare const barycenter: (g: Graph, movable: ID[]) => ({
7
+ v: ID;
8
+ barycenter?: undefined;
9
+ weight?: undefined;
10
+ } | {
11
+ v: ID;
12
+ barycenter: number;
13
+ weight: number;
14
+ })[];
@@ -0,0 +1,3 @@
1
+ import { Graph } from "@antv/graphlib";
2
+ import { EdgeData, Graph as IGraph, NodeData } from "../../types";
3
+ export declare const buildLayerGraph: (g: IGraph, rank: number, direction: "in" | "out") => Graph<NodeData, EdgeData>;
@@ -0,0 +1,3 @@
1
+ import { ID } from "@antv/graphlib";
2
+ import { Graph } from "../../types";
3
+ export declare const crossCount: (g: Graph, layering: ID[][]) => number;
@@ -0,0 +1,2 @@
1
+ import { Graph as IGraph } from "../../types";
2
+ export declare const order: (g: IGraph, keepNodeOrder?: boolean) => void;
@@ -0,0 +1,6 @@
1
+ import { ID } from "@antv/graphlib";
2
+ import { Graph } from "../../types";
3
+ /**
4
+ * 按照数据中的结果设置fixorder
5
+ */
6
+ export declare const initDataOrder: (g: Graph, nodeOrder?: ID[]) => void;
@@ -0,0 +1,3 @@
1
+ import { ID } from "@antv/graphlib";
2
+ import { Graph } from "../../types";
3
+ export declare const initOrder: (g: Graph) => ID[][];
@@ -0,0 +1,20 @@
1
+ import { ID } from "@antv/graphlib";
2
+ import { Graph } from "../../types";
3
+ export type ConflictEntry = {
4
+ i: number;
5
+ indegree?: number;
6
+ in?: ConflictEntry[];
7
+ out?: ConflictEntry[];
8
+ vs: ID[];
9
+ barycenter?: number;
10
+ weight?: number;
11
+ merged?: boolean;
12
+ fixorder?: number;
13
+ order?: number;
14
+ };
15
+ declare const resolveConflicts: (entries: {
16
+ v: ID;
17
+ barycenter?: number;
18
+ weight?: number;
19
+ }[], cg: Graph) => ConflictEntry[];
20
+ export default resolveConflicts;
@@ -0,0 +1,7 @@
1
+ import { ID } from "@antv/graphlib";
2
+ import { Graph } from "../../types";
3
+ export declare const sortSubgraph: (g: Graph, v: ID, cg: Graph, biasRight?: boolean, usePrev?: boolean, keepNodeOrder?: boolean) => {
4
+ vs: ID[];
5
+ barycenter?: number | undefined;
6
+ weight?: number | undefined;
7
+ };
@@ -0,0 +1,7 @@
1
+ import { ID } from "@antv/graphlib";
2
+ import { ConflictEntry } from "./resolve-conflicts";
3
+ export declare const sort: (entries: ConflictEntry[], biasRight?: boolean, usePrev?: boolean, keepNodeOrder?: boolean) => {
4
+ vs: ID[];
5
+ barycenter?: number | undefined;
6
+ weight?: number | undefined;
7
+ };
@@ -0,0 +1,3 @@
1
+ import { ID } from "@antv/graphlib";
2
+ import { Graph as IGraph } from "../types";
3
+ export declare const parentDummyChains: (g: IGraph, dummyChains: ID[]) => void;
@@ -0,0 +1,25 @@
1
+ import { ID, Node } from "@antv/graphlib";
2
+ import { DagreAlign, Graph as IGraph, NodeData } from "../../types";
3
+ type Conflicts = Record<ID, Record<ID, boolean>>;
4
+ export declare const findType1Conflicts: (g: IGraph, layering?: ID[][]) => {};
5
+ export declare const findType2Conflicts: (g: IGraph, layering?: ID[][]) => {};
6
+ export declare const findOtherInnerSegmentNode: (g: IGraph, v: ID) => Node<NodeData> | undefined;
7
+ export declare const addConflict: (conflicts: Conflicts, v: ID, w: ID) => void;
8
+ export declare const hasConflict: (conflicts: Conflicts, v: ID, w: ID) => boolean;
9
+ export declare const verticalAlignment: (g: IGraph, layering: ID[][], conflicts: Conflicts, neighborFn: (v: ID) => Node<NodeData>[]) => {
10
+ root: Record<ID, ID>;
11
+ align: Record<ID, ID>;
12
+ };
13
+ export declare const horizontalCompaction: (g: IGraph, layering: ID[][], root: Record<ID, ID>, align: Record<ID, ID>, nodesep: number, edgesep: number, reverseSep?: boolean) => Record<ID, number>;
14
+ export declare const buildBlockGraph: (g: IGraph, layering: ID[][], root: Record<ID, ID>, nodesep: number, edgesep: number, reverseSep?: boolean) => IGraph;
15
+ export declare const findSmallestWidthAlignment: (g: IGraph, xss: Record<string, Record<string, number>>) => Record<string, number>;
16
+ export declare function alignCoordinates(xss: Record<string, Record<string, number>>, alignTo: Record<string, number>): void;
17
+ export declare const balance: (xss: Record<string, Record<string, number>>, align?: DagreAlign) => Record<string, number>;
18
+ export declare const positionX: (g: IGraph, options?: Partial<{
19
+ align: DagreAlign;
20
+ nodesep: number;
21
+ edgesep: number;
22
+ }> | undefined) => Record<string, number>;
23
+ export declare const sep: (nodeSep: number, edgeSep: number, reverseSep: boolean) => (g: IGraph, v: ID, w: ID) => number;
24
+ export declare const width: (g: IGraph, v: ID) => number;
25
+ export {};
@@ -0,0 +1,7 @@
1
+ import { DagreAlign, Graph as IGraph } from "../../types";
2
+ export declare const position: (g: IGraph, options?: Partial<{
3
+ align: DagreAlign;
4
+ nodesep: number;
5
+ edgesep: number;
6
+ ranksep: number;
7
+ }>) => void;
@@ -0,0 +1,5 @@
1
+ import { Graph } from "@antv/graphlib";
2
+ import { Graph as IGraph } from "../../types";
3
+ declare const feasibleTree: (g: IGraph) => Graph<import("@antv/graphlib").PlainObject, import("@antv/graphlib").PlainObject>;
4
+ declare const feasibleTreeWithLayer: (g: IGraph) => Graph<import("@antv/graphlib").PlainObject, import("@antv/graphlib").PlainObject>;
5
+ export { feasibleTree, feasibleTreeWithLayer };
@@ -0,0 +1,2 @@
1
+ import { Graph as IGraph } from "../../types";
2
+ export declare const rank: (g: IGraph, ranker: "network-simplex" | "tight-tree" | "longest-path") => void;
@@ -0,0 +1,16 @@
1
+ import { Edge, ID } from "@antv/graphlib";
2
+ import { EdgeData, Graph as IGraph } from "../../types";
3
+ export declare const networkSimplex: (og: IGraph) => void;
4
+ export declare const initCutValues: (t: IGraph, g: IGraph) => void;
5
+ export declare const calcCutValue: (t: IGraph, g: IGraph, child: ID) => number;
6
+ export declare const initLowLimValues: (tree: IGraph, root?: ID) => void;
7
+ export declare const leaveEdge: (tree: IGraph) => Edge<EdgeData> | undefined;
8
+ export declare const enterEdge: (t: IGraph, g: IGraph, edge: Edge<EdgeData>) => Edge<EdgeData>;
9
+ /**
10
+ *
11
+ * @param t
12
+ * @param g
13
+ * @param e edge to remove
14
+ * @param f edge to add
15
+ */
16
+ export declare const exchangeEdges: (t: IGraph, g: IGraph, e: Edge<EdgeData>, f: Edge<EdgeData>) => void;
@@ -0,0 +1,6 @@
1
+ import { Edge } from "@antv/graphlib";
2
+ import { EdgeData, Graph } from "../../types";
3
+ declare const longestPath: (g: Graph) => void;
4
+ declare const longestPathWithLayer: (g: Graph) => void;
5
+ declare const slack: (g: Graph, e: Edge<EdgeData>) => number;
6
+ export { longestPath, longestPathWithLayer, slack };
@@ -0,0 +1,35 @@
1
+ import { ID, Graph, Node } from "@antv/graphlib";
2
+ import { EdgeData, Graph as IGraph, NodeData } from "../types";
3
+ export declare const addDummyNode: (g: IGraph, type: string, data: NodeData, name: string) => ID;
4
+ export declare const simplify: (g: IGraph) => Graph<NodeData, EdgeData>;
5
+ export declare const asNonCompoundGraph: (g: IGraph) => IGraph;
6
+ export declare const zipObject: <T = any>(keys: ID[], values: T[]) => Record<ID, T>;
7
+ export declare const successorWeights: (g: IGraph) => Record<ID, Record<string, number>>;
8
+ export declare const predecessorWeights: (g: IGraph) => Record<ID, Record<ID, number>>;
9
+ export declare const intersectRect: (rect: {
10
+ x?: number | undefined;
11
+ y?: number | undefined;
12
+ width?: number | undefined;
13
+ height?: number | undefined;
14
+ }, point: {
15
+ x?: number | undefined;
16
+ y?: number | undefined;
17
+ }) => {
18
+ x: number;
19
+ y: number;
20
+ };
21
+ export declare const buildLayerMatrix: (g: IGraph) => ID[][];
22
+ export declare const normalizeRanks: (g: IGraph) => void;
23
+ export declare const removeEmptyRanks: (g: IGraph, nodeRankFactor?: number) => void;
24
+ export declare const addBorderNode: (g: IGraph, prefix: string, rank?: number, order?: number) => ID;
25
+ export declare const maxRank: (g: IGraph) => number;
26
+ export declare const partition: <T = any>(collection: T[], fn: (val: T) => boolean) => {
27
+ lhs: T[];
28
+ rhs: T[];
29
+ };
30
+ export declare const minBy: <T = any>(array: T[], func: (param: T) => number) => T;
31
+ /**
32
+ * @description DFS traversal.
33
+ * @description.zh-CN DFS 遍历。
34
+ */
35
+ export declare const dfs: (graph: IGraph, node: Node<NodeData> | Node<NodeData>[], order: "pre" | "post", isDirected: boolean) => ID[];
package/lib/dagre.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ import type { Graph as IGraph, Layout, LayoutMapping, Node, DagreLayoutOptions } from "./types";
2
+ /**
3
+ * Layout arranging the nodes in a circle.
4
+ *
5
+ * @example
6
+ * // Assign layout options when initialization.
7
+ * const layout = new CircularLayout({ radius: 10 });
8
+ * const positions = await layout.execute(graph); // { nodes: [], edges: [] }
9
+ *
10
+ * // Or use different options later.
11
+ * const layout = new CircularLayout({ radius: 10 });
12
+ * const positions = await layout.execute(graph, { radius: 20 }); // { nodes: [], edges: [] }
13
+ *
14
+ * // If you want to assign the positions directly to the nodes, use assign method.
15
+ * await layout.assign(graph, { radius: 20 });
16
+ */
17
+ export declare class DagreLayout implements Layout<DagreLayoutOptions> {
18
+ options: DagreLayoutOptions;
19
+ id: string;
20
+ constructor(options?: DagreLayoutOptions);
21
+ /**
22
+ * Return the positions of nodes and edges(if needed).
23
+ */
24
+ execute(graph: IGraph, options?: DagreLayoutOptions): Promise<LayoutMapping>;
25
+ /**
26
+ * To directly assign the positions to the nodes.
27
+ */
28
+ assign(graph: IGraph, options?: DagreLayoutOptions): Promise<void>;
29
+ private genericDagreLayout;
30
+ layoutNode: (node: Node) => boolean;
31
+ }
package/lib/index.d.ts CHANGED
@@ -10,5 +10,6 @@ export * from "./fruchterman";
10
10
  export * from "./d3Force";
11
11
  export * from "./force";
12
12
  export * from "./forceAtlas2";
13
+ export * from "./dagre";
13
14
  export * from "./types";
14
15
  export * from "./util";
package/lib/types.d.ts CHANGED
@@ -1,7 +1,24 @@
1
- import { Graph as IGraph, Node as INode, Edge as IEdge, PlainObject, GraphView as IGraphView } from "@antv/graphlib";
1
+ import { Graph as IGraph, Node as INode, Edge as IEdge, PlainObject, GraphView as IGraphView, ID } from "@antv/graphlib";
2
2
  export interface NodeData extends PlainObject {
3
3
  size?: number | number[];
4
4
  bboxSize?: number[];
5
+ borderLeft?: ID | ID[];
6
+ borderRight?: ID | ID[];
7
+ x?: number;
8
+ y?: number;
9
+ height?: number;
10
+ width?: number;
11
+ e?: IEdge<EdgeData>;
12
+ selfEdges?: IEdge<EdgeData>[];
13
+ rank?: number;
14
+ order?: number;
15
+ fixorder?: number;
16
+ minRank?: number;
17
+ maxRank?: number;
18
+ layout?: boolean;
19
+ layer?: number;
20
+ low?: number;
21
+ lim?: number;
5
22
  }
6
23
  export interface OutNodeData extends NodeData {
7
24
  x: number;
@@ -9,6 +26,16 @@ export interface OutNodeData extends NodeData {
9
26
  }
10
27
  export interface EdgeData extends PlainObject {
11
28
  virtual?: boolean;
29
+ weight?: number;
30
+ x?: number;
31
+ y?: number;
32
+ height?: number;
33
+ width?: number;
34
+ points?: Point[];
35
+ controlPoints?: Point[];
36
+ minlen?: number;
37
+ cutvalue?: number;
38
+ labeloffset?: number;
12
39
  }
13
40
  /** input node */
14
41
  export type Node = INode<NodeData>;
@@ -149,9 +176,11 @@ export interface RadialLayoutOptions {
149
176
  sortBy?: string;
150
177
  sortStrength?: number;
151
178
  }
179
+ export type DagreRankdir = "TB" | "BT" | "LR" | "RL" | "tb" | "lr" | "rl" | "bt";
180
+ export type DagreAlign = "UL" | "UR" | "DL" | "DR";
152
181
  export interface DagreLayoutOptions {
153
- rankdir?: "TB" | "BT" | "LR" | "RL";
154
- align?: "UL" | "UR" | "DL" | "DR";
182
+ rankdir?: DagreRankdir;
183
+ align?: DagreAlign;
155
184
  begin?: PointTuple;
156
185
  nodeSize?: number | number[];
157
186
  nodesep?: number;
@@ -161,7 +190,7 @@ export interface DagreLayoutOptions {
161
190
  edgeLabelSpace?: boolean;
162
191
  nodeOrder?: string[];
163
192
  radial?: boolean;
164
- focusNode: string | Node | null;
193
+ focusNode?: string | Node | null;
165
194
  preset?: {
166
195
  nodes: OutNode[];
167
196
  edges: Edge[];
@@ -13,6 +13,21 @@ export declare const handleSingleNodeGraph: (graph: Graph, assign: boolean, cent
13
13
  y: number;
14
14
  size?: number | number[] | undefined;
15
15
  bboxSize?: number[] | undefined;
16
+ borderLeft?: import("@antv/graphlib").ID | import("@antv/graphlib").ID[] | undefined;
17
+ borderRight?: import("@antv/graphlib").ID | import("@antv/graphlib").ID[] | undefined;
18
+ height?: number | undefined;
19
+ width?: number | undefined;
20
+ e?: import("@antv/graphlib").Edge<import("../types").EdgeData> | undefined;
21
+ selfEdges?: import("@antv/graphlib").Edge<import("../types").EdgeData>[] | undefined;
22
+ rank?: number | undefined;
23
+ order?: number | undefined;
24
+ fixorder?: number | undefined;
25
+ minRank?: number | undefined;
26
+ maxRank?: number | undefined;
27
+ layout?: boolean | undefined;
28
+ layer?: number | undefined;
29
+ low?: number | undefined;
30
+ lim?: number | undefined;
16
31
  };
17
32
  id: import("@antv/graphlib").ID;
18
33
  }[];
@@ -17,3 +17,10 @@ export declare function formatSizeFn<T extends Node>(defaultValue: number, value
17
17
  width: number;
18
18
  height: number;
19
19
  } | ((d?: T) => number) | undefined, resultIsNumber?: boolean): (d: T) => number | number[];
20
+ /**
21
+ * format the props nodeSize and nodeSpacing to a function
22
+ * @param nodeSize
23
+ * @param nodeSpacing
24
+ * @returns
25
+ */
26
+ export declare const formatNodeSize: (nodeSize: number | number[] | undefined, nodeSpacing: number | Function | undefined) => (nodeData: Node) => number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/layout",
3
- "version": "1.0.0-alpha.17",
3
+ "version": "1.0.0-alpha.19",
4
4
  "description": "graph layout algorithm",
5
5
  "main": "dist/index.min.js",
6
6
  "module": "esm/index.esm.js",