Skip to content

Commit 9ba38dd

Browse files
committed
Rename Graph interfaces for specificity
1 parent 04f4f8d commit 9ba38dd

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/practice/0-directed-graph.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export interface IGraph {
1+
export interface IDirectedGraph {
22
nodes: string[];
33
edges: { [ source: string ]: string[] };
44
}

src/practice/0-undirected-graph.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export interface IEdge {
44
distance: number;
55
}
66

7-
export interface IGraph {
7+
export interface IUndirectedGraph {
88
nodes: string[];
99
edges: IEdge[];
1010
}

src/practice/1-1-top-sort.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { IGraph } from './0-directed-graph';
1+
import { IDirectedGraph } from './0-directed-graph';
22

33
export function topSort(
4-
graph: IGraph,
4+
graph: IDirectedGraph,
55
): string[] {
66
const ordered: string[] = [];
77
const notVisited = new Set(graph.nodes);
@@ -39,7 +39,7 @@ export function nodesWithoutIncomingEdges(
3939

4040
export function isTopSort(
4141
orderedNodes: string[],
42-
graph: IGraph,
42+
graph: IDirectedGraph,
4343
): boolean {
4444
if (graph.nodes.length !== (orderedNodes || []).length) return false;
4545

@@ -53,7 +53,7 @@ export function isTopSort(
5353
return true;
5454
}
5555

56-
export function pathExists(source: string, destination: string, graph: IGraph): boolean {
56+
export function pathExists(source: string, destination: string, graph: IDirectedGraph): boolean {
5757
const toVisit = [source];
5858
const visited = new Set<string | undefined>([]);
5959

src/practice/1-2-dijkstra-shortest-path.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IGraph } from './0-undirected-graph';
1+
import { IUndirectedGraph } from './0-undirected-graph';
22

33
const infinity = Number.POSITIVE_INFINITY;
44

@@ -17,7 +17,7 @@ export interface IPath {
1717
}
1818

1919
export function dijkstraShortestPath(
20-
graph: IGraph,
20+
graph: IUndirectedGraph,
2121
sourceNode: string,
2222
destinationNode: string,
2323
): IPath {

0 commit comments

Comments
 (0)