This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function buildGraph(edges) { | |
let graph = Object.create(null); | |
function addEdge(from, to) { | |
if (graph[from] == null) { | |
graph[from] = [to]; | |
} else { | |
graph[from].push(to); | |
} | |
console.log(from, to); | |
console.log(graph[from]); //vs console.log(graph); why does printing the entire graph here print the completed graph on the second call, even though it shouldn't be fully constructed until the last call? |