Trees
A connected graph without any cycles is called a tree.
- A tree always has edges.
- There is always a unique path between any two vertices in a tree.
A graph (not necessarily connected) without any cycles is called a forest. In such graph, each connected graph is a tree.
Rooted Trees
In a tree we can specify a special vertex, called the root. Any vertex can be the root.
The root is chosen to be .
- ancestors is just .
- ancestors are and .
- children are and .
- descendants are and .
- The leaves are , , and .
Parent
The parent of a vertex is the first vertex in the unique path to the root.
We call the parent of v
,
The root has no parent.
Ancestors
The ancestors of a vertex are its parent and its parent's parent, etc. All the way to the root.
We call the set of ancestors of a vertex v
, .
- If
v
is the root, then - If
v
is not the root, then
Children
The children of a vertex are all its neighbors except its parent.
Descendants
The descendants of a vertex is all its children, all its children's children, etc.
We call the set of children of a vertex v
, and the set of descendants .
- If the vertex is the root then , otherwise
- The descendants are given by:
Why is there no base case?
It exists, it just built in to the notation. If then the big union will disappear.
Leaf
A vertex without children is called a leaf.
Subgraph
Induced Subgraph
Subtree
Spanning Tree
Use Cases
- In networking, we often identiy a spanning tree of the network and only send packets along the edge of the spanning tree. This prevents packets from going around the network in a cycle.
- The graph of the shortest paths from a vertex will form a rooted spanning tree.
Vocabulary
intrinsic
- A built-in function that is implemented directly by the compiler, without any intermediate call to a library.
- An ability possessed by a character and not requiring any external equipment.
- Innate, inherent, inseparable from the thing itself, essential.
- (of a body part) Situated, produced, secreted in, or coming from inside an organ, tissue, muscle or member.
descendants
- One who is the progeny of a specified person, at any distance of time or through any number of generations.
- A thing that derives directly from a given precursor or source.
- A later evolutionary type.
- A language that is descended from another.
- A word or form in one language that is descended from a counterpart in an ancestor language.