Graph

Run Settings
LanguageJavaScript
Language Version
Run Command
class Graph{ constructor() { this.dataStore = []; } add_vertex(V) { this.dataStore[V] = []; } add_edge(v,e) { this.dataStore[v].push(e); } display() { for(let v=0;v<this.dataStore.length;v++) { for(let e=0;e<this.dataStore[v].length;e++) console.log(this.dataStore[v]+'->'+this.dataStore[v][e]); } } } let g = new Graph() g.add_vertex('A') g.add_vertex('B') g.add_vertex('C') g.add_edge('A', 'B') g.add_edge('B', 'C') g.add_edge('C', 'A') g.display()
Editor Settings
Theme
Key bindings
Full width
Lines