Graph

Run Settings
LanguageJavaScript
Language Version
Run Command
class Graph{ constructor() { this.nodes = 0; this.list = []; } addVertex(v) { this.list[v] = []; this.nodes++; } addEdge(v,e) { this.list[v].push(e); this.list[e].push(v); } showConnections(){ for(let i=0;i<this.list.length;i++) console.log(i+'->'+this.list[i]) } } const myGraph = new Graph(); myGraph.addVertex('0'); myGraph.addVertex('1'); myGraph.addVertex('2'); myGraph.addVertex('3'); myGraph.addVertex('4'); myGraph.addVertex('5'); myGraph.addVertex('6'); myGraph.addEdge('3', '1'); myGraph.addEdge('3', '4'); myGraph.addEdge('4', '2'); myGraph.addEdge('4', '5'); myGraph.addEdge('1', '2'); myGraph.addEdge('1', '0'); myGraph.addEdge('0', '2'); myGraph.addEdge('6', '5'); myGraph.showConnections();
Editor Settings
Theme
Key bindings
Full width
Lines