Last active
April 4, 2016 16:10
-
-
Save jvoigtlaender/1a7f469670c29866dafb to your computer and use it in GitHub Desktop.
print signal graph from within Elm runtime
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 printGraph(queue) | |
{ | |
queue = queue.slice(0); | |
console.log('digraph { //'); | |
var seen = []; | |
while (queue.length > 0) | |
{ | |
var node = queue.pop(); | |
var id = node.id; | |
if (seen.indexOf(id) < 0) | |
{ | |
console.log('%d [label="%s"]; //', id, node.name); | |
var kids = node.kids || []; | |
for (var i = kids.length; i--; ) | |
{ | |
console.log('%d -> %d', id, kids[i].id, '; //'); | |
} | |
queue = queue.concat(kids); | |
seen.push(id); | |
} | |
} | |
console.log('} //'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment