Skip to content

Commit cd46318

Browse files
committed
Implement add vertex method on the graph class
1 parent ac625fb commit cd46318

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Graph.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class Graph {
2+
constructor() {
3+
this.adjacencyList = {};
4+
}
5+
addVertex(vertex) {
6+
if (!this.adjacencyList[vertex]) this.adjacencyList[vertex] = [];
7+
}
8+
}

0 commit comments

Comments
 (0)