Skip to content

Commit 623518e

Browse files
authored
Merge pull request #26 from yashmahalwal/master
Typings
2 parents 71dfcad + c381141 commit 623518e

7 files changed

Lines changed: 816 additions & 385 deletions

File tree

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
index.ts

index.d.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
declare type NodeId = string;
2+
declare type EdgeWeight = number;
3+
interface Serialized {
4+
nodes: {
5+
id: NodeId;
6+
}[];
7+
links: {
8+
source: NodeId;
9+
target: NodeId;
10+
weight: EdgeWeight;
11+
}[];
12+
}
13+
declare function Graph(serialized?: Serialized): {
14+
addNode: (node: string) => any;
15+
removeNode: (node: string) => any;
16+
nodes: () => string[];
17+
adjacent: (node: string) => string[];
18+
addEdge: (u: string, v: string, weight: number) => any;
19+
removeEdge: (u: string, v: string) => any;
20+
setEdgeWeight: (u: string, v: string, weight: number) => any;
21+
getEdgeWeight: (u: string, v: string) => number;
22+
indegree: (node: string) => number;
23+
outdegree: (node: string) => number;
24+
depthFirstSearch: (sourceNodes?: string[] | undefined, includeSourceNodes?: boolean) => string[];
25+
lowestCommonAncestors: (node1: string, node2: string) => string[];
26+
topologicalSort: (sourceNodes: string[], includeSourceNodes?: boolean) => string[];
27+
shortestPath: (source: string, destination: string) => string[] & {
28+
weight?: number | undefined;
29+
};
30+
serialize: () => Serialized;
31+
deserialize: (serialized: Serialized) => any;
32+
};
33+
export = Graph;

0 commit comments

Comments
 (0)