Skip to content

Instantly share code, notes, and snippets.

@ircmaxell
Created July 29, 2014 18:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ircmaxell/179855e69dfa31ac2b19 to your computer and use it in GitHub Desktop.
Save ircmaxell/179855e69dfa31ac2b19 to your computer and use it in GitHub Desktop.
Dump Gliph to GraphViz
<?php
public function dump(DirectedAdjacencyList $func, $filename) {
$ctr = 0;
$graph = Graph::create("dump");
$nodes = new \SplObjectStorage;
$scope = new \SplObjectStorage;
foreach ($func->eachVertex() as $vertex => $_) {
$nodes[$vertex] = Node::create('node_' . $ctr++);
$graph->setNode($nodes[$vertex]);
}
foreach ($func->eachEdge() as $edge) {
$graph->link(Edge::create($nodes[$edge[0]], $nodes[$edge[1]]));
}
$graph->export('png', $filename);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment