Skip to content

Instantly share code, notes, and snippets.

@hilverd
Created August 13, 2012 20:50
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
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