Skip to content

Commit 4ff03a2

Browse files
committed
feat: added typescript
1 parent 71dfcad commit 4ff03a2

7 files changed

Lines changed: 817 additions & 385 deletions

File tree

index.d.ts

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

index.d.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)