Skip to content

Instantly share code, notes, and snippets.

@jvoigtlaender
Last active April 4, 2016 16:10
Show Gist options
  • Save jvoigtlaender/1a7f469670c29866dafb to your computer and use it in GitHub Desktop.
Save jvoigtlaender/1a7f469670c29866dafb to your computer and use it in GitHub Desktop.
print signal graph from within Elm runtime
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