Skip to content

Instantly share code, notes, and snippets.

@hilverd
Created August 13, 2012 20:50
Show Gist options
  • Save hilverd/3343995 to your computer and use it in GitHub Desktop.
Save hilverd/3343995 to your computer and use it in GitHub Desktop.
Topological sort in Graphviz's gvpr
BEGIN {
int visited[node_t];
int visit(node_t n, edge_t e) {
if (visited[n] == 0) {
visited[n] = 1;
for (e = fstin(n); e; e = nxtin(e)) {
visit(e.tail, NULL);
}
printf("%s\n", n.name);
}
return 0;
}
}
N {
visit($, NULL);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment