A Tree is just a restricted form of a Graph. They fit with inthe category of Directed Acyclic Graphs (or a DAG). So Treesare DAGs with the restriction that a child can only have oneparent.
Graphs are generally search breath first or depth first. The same applies
to Tree.
Basic represent way: adjacency list and adjacency matrix:
You want to mirror the problem using a tree-like structure:For this
we have boost graph library. The BGL currently provides two graph
classes and an edge list adaptor: adjacency_list, adjacency_matrix and
edge_list. The adjacency_list class is the general purpose ‘"swiss army
knife” of graph classes.