mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-08 06:42:22 +08:00
Updating Dagre types
This commit is contained in:
104
types/dagre/index.d.ts
vendored
104
types/dagre/index.d.ts
vendored
@@ -3,6 +3,7 @@
|
||||
// Definitions by: Qinfeng Chen <https://github.com/qinfchen>
|
||||
// Lisa Vallfors <https://github.com/Frankrike>
|
||||
// Pete Vilter <https://github.com/vilterp>
|
||||
// David Newell <http://github.com/rustedgrail>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
@@ -10,27 +11,67 @@ export as namespace dagre;
|
||||
|
||||
export namespace graphlib {
|
||||
class Graph {
|
||||
edges(): Edge[];
|
||||
edge(id: any): any;
|
||||
nodes(): string[];
|
||||
node(id: any): any;
|
||||
setDefaultEdgeLabel(callback: string|(() => string|object)): Graph;
|
||||
setDefaultNodeLabel(callback: string|(() => string|object)): Graph;
|
||||
setEdge(sourceId: string, targetId: string, options?: { [key: string]: any }, value?: string): Graph;
|
||||
setEdge(params: {v: string, w: string, name?: string}, value?: string): Graph;
|
||||
setGraph(label: GraphLabel): Graph;
|
||||
setNode(id: string, node: { [key: string]: any }): Graph;
|
||||
graph(): GraphLabel;
|
||||
|
||||
constructor(opt?: {directed?: boolean, multigraph?: boolean, compound?: boolean});
|
||||
setParent(name: string, parentName: string): void;
|
||||
|
||||
graph(): GraphLabel;
|
||||
isDirected(): boolean;
|
||||
isMultiGraph(): boolean;
|
||||
setGraph(label: GraphLabel): Graph;
|
||||
|
||||
edge(edgeObj: EdgeLabel): Edge;
|
||||
edge(outNodeName: string, inNodeName: string, name?: string): Edge;
|
||||
edgeCount(): number;
|
||||
edges(): EdgeLabel[];
|
||||
hasEdge(edgeObj: EdgeLabel): boolean;
|
||||
hasEdge(outNodeName: string, inNodeName: string, name?: string): boolean;
|
||||
inEdges(inNodeName: string, outNodeName?: string): EdgeLabel[]|undefined;
|
||||
outEdges(outNodeName: string, inNodeName?: string): EdgeLabel[]|undefined;
|
||||
removeEdge(outNodeName: string, inNodeName: string): Graph;
|
||||
setDefaultEdgeLabel(callback: string|(() => string|object)): Graph;
|
||||
setEdge(params: EdgeLabel, value?: string|{[key: string]: any}): Graph;
|
||||
setEdge(sourceId: string, targetId: string, value?: string|{ [key: string]: any }, name?: string): Graph;
|
||||
|
||||
children(parentName: string): string|undefined;
|
||||
hasNode(name: string): boolean;
|
||||
neighbors(name: string): Node[]|undefined;
|
||||
node(id: string|object): Node;
|
||||
nodeCount(): number;
|
||||
nodes(): string[];
|
||||
parent(childName: string): string|undefined;
|
||||
predecessors(name: string): Node[]|undefined;
|
||||
removeNode(name: string): Graph;
|
||||
setDefaultNodeLabel(callback: string|(() => string|object)): Graph;
|
||||
setNode(id: string, node: NodeConfig): Graph;
|
||||
setParent(childName: string, parentName: string): void;
|
||||
sources(): Node[];
|
||||
successors(name: string): Node[]|undefined;
|
||||
}
|
||||
|
||||
class json {
|
||||
static read(graph: object): Graph;
|
||||
static write(graph: Graph): object;
|
||||
}
|
||||
|
||||
class alg {
|
||||
static components(graph: Graph): string[][];
|
||||
static dijkstra(graph: Graph, source: string, weightFn?: WeightFn, edgeFn?: EdgeFn): object;
|
||||
static dijkstraAll(graph: Graph, weightFn?: WeightFn, edgeFn?: EdgeFn): object;
|
||||
static findCycles(graph: Graph): string[][];
|
||||
static floydWarchall(graph: Graph, weightFn?: WeightFn, edgeFn?: EdgeFn): object;
|
||||
static isAcyclic(graph: Graph): boolean;
|
||||
static postorder(graph: Graph, nodeNames: string|string[]): string[];
|
||||
static preorder(graph: Graph, nodeNames: string|string[]): string[];
|
||||
static prim(graph: Graph, weightFn?: WeightFn): Graph;
|
||||
static tarjam(graph: Graph): string[][];
|
||||
static topsort(graph: Graph): string[];
|
||||
}
|
||||
}
|
||||
|
||||
export type WeightFn = (edge: EdgeLabel) => number;
|
||||
export type EdgeFn = (outNodeName: string) => Edge[];
|
||||
|
||||
export interface GraphLabel {
|
||||
width?: number;
|
||||
height?: number;
|
||||
label?: string;
|
||||
compound?: boolean;
|
||||
rankdir?: string;
|
||||
align?: string;
|
||||
@@ -41,12 +82,41 @@ export interface GraphLabel {
|
||||
marginy?: number;
|
||||
acyclicer?: string;
|
||||
ranker?: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
}
|
||||
|
||||
export function layout(graph: graphlib.Graph): void;
|
||||
export interface NodeConfig {
|
||||
width?: number;
|
||||
height?: number;
|
||||
}
|
||||
|
||||
export interface Edge {
|
||||
export interface EdgeConfig {
|
||||
minlen: number;
|
||||
weight: number;
|
||||
width: number;
|
||||
height: number;
|
||||
lablepos: 'l'|'c'|'r';
|
||||
labeloffest: number;
|
||||
}
|
||||
|
||||
export function layout(graph: graphlib.Graph, layout?: GraphLabel&NodeConfig&EdgeConfig): void;
|
||||
|
||||
export interface EdgeLabel {
|
||||
v: string;
|
||||
w: string;
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export interface Edge {
|
||||
points: Array<{x: number, y: number}>;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface Node {
|
||||
x: number;
|
||||
y: number;
|
||||
width: number;
|
||||
height: number;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user