Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save inscapist/143cddbe08c0c17418893ba147ab1b3f to your computer and use it in GitHub Desktop.
Save inscapist/143cddbe08c0c17418893ba147ab1b3f to your computer and use it in GitHub Desktop.
graph vs DAG vs tree
A Tree is just a restricted form of a Graph.
Trees have direction (parent / child relationships) and don't contain cycles.
It has only one path between any two vertices
They fit with in the category of Directed Acyclic Graphs (or a DAG).
So Trees are DAGs with the restriction that a child can only have one parent.
Directed Acyclic Graphs is a kind of directed graph that have no cycles.
DFS will create a spanning tree of a graph. So does flooding.
control-flow graph --> DFS --> spanning tree --> tree travesal (pre-order, post-order, in-order)
CFG may contains loops, nodes with multiple incoming path.
topological ordering/sorting is a concept for directed graph which has no directed cycles, that is, DAG.
Travesal method is for graph. This includes tree as it is a rectricted form of graph.
RPO (Reverse Post Order) of a DAG has another name: topological sort.
tree edge
back edge
forward edge
cross edge
https://eli.thegreenplace.net/2015/directed-graph-traversal-orderings-and-applications-to-data-flow-analysis/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment