notesonly.in

One notebook for every subject — open it anywhere.

Log in

Trees in Graph Theory: Properties, Types, and Examples

A tree is a connected graph with no cycles — the simplest possible connected structure. Like a family tree or a real tree's branches, there is exactly one route between any two points, with no alternative loops. Trees sit at the heart of computer science: file systems, organisation charts and decision processes are all trees.

Trees matter because they are the cheapest way to keep everything connected. Any connected network can be thinned to a tree without disconnecting anyone, and trees are easy to search and traverse — which is why databases, compilers and AI all rely on them.

Key Concepts

  • Tree: a connected, acyclic (cycle-free) graph.
  • Leaf: a vertex of degree 1; every tree with at least 2 vertices has at least 2 leaves.
  • Rooted tree: a tree with one distinguished root; vertices below form parent–child relationships, like file-system folders.
  • Binary tree: a rooted tree where each vertex has at most two children — the structure behind searching and sorting.
  • Forest: an acyclic graph, not necessarily connected — a collection of trees.
  • Spanning tree: a tree built from a graph's edges that still connects all vertices.

Formulas

A tree with n vertices always has exactly n − 1 edges.

Why: each new vertex added to a tree needs exactly one edge to stay connected — more would create a cycle. So n vertices need exactly n − 1 edges, and it works both ways: a connected graph with n vertices and n − 1 edges is always a tree. A tree is minimally connected (removing any edge disconnects it) and maximally acyclic (adding any edge creates one cycle). Exactly one simple path joins any two vertices — two different paths would form a cycle.

Worked Example

Take a tree with 7 vertices: root R with children A and B; A has children C and D; B has child E; E has child F. Edges: R–A, R–B, A–C, A–D, B–E, E–F — 6 edges for 7 vertices, matching n − 1 = 6. Leaves: C, D, F. Degrees R=2, A=3, B=2, C=1, D=1, E=2, F=1 sum to 12 = 2 × 6, matching the handshaking lemma. The unique path from C to F is C–A–R–B–E–F. Remove edge R–B and the tree splits into {R, A, C, D} and {B, E, F}. Add edge C–D and the cycle C–A–D–C appears.

Common Misconceptions

  • A tree is not just "any branching diagram". It must be connected and cycle-free. A branching diagram with a loop, or two separate branching diagrams, is not a tree.
  • Every tree with n vertices has n − 1 edges — no exceptions. If you count n edges in a connected graph, it cannot be a tree; a cycle is hiding somewhere.
  • A plain tree has no root and no child limit. Rooting a tree just means choosing a starting vertex to organise it.

Real-World Applications

  • File systems: folders and files form a rooted tree; a path like /home/user/docs is the unique tree path from the root.
  • Databases and search: indexes like B-trees find records in logarithmic time.
  • Organisation charts: reporting lines form a tree — exactly one chain of command from any employee to the top.
  • Decision trees in AI: each branch is a yes/no question leading to a classification.
  • Network design: spanning trees prevent broadcast loops while keeping every device reachable.

A tree is a connected graph with no cycles, and that forces everything else: n vertices mean n − 1 edges and exactly one path between any two vertices. Minimal and loop-free.