A path in a graph is a sequence of vertices \(v_0, v_1, v_2, \ldots, v_k\) such that there is an edge between each consecutive pair \((v_{i-1}, v_i)\).
A simple path visits each vertex at most once. Most algorithms (e.g. shortest path) search for simple paths.
In a directed graph, the path must follow edge directions: each edge \((v_{i-1}, v_i)\) must point from \(v_{i-1}\) to \(v_i\).
Example:
A → B → D → E
This is a path of length 3 from A to E (passing through B and D).
KEY TAKEAWAY: A path defines a route through the graph. The length of a path depends on whether the graph is weighted or unweighted.
In an unweighted graph, the length of a path is the number of edges it contains.
In a weighted graph, the weighted path length (also called the cost or weight of the path) is the sum of the edge weights along the path.
Example:
A --3--> B --7--> D
A --3--> B → weighted path length = 3
A --3--> B --7--> D → weighted path length = 10
EXAM TIP: Shortest path algorithms like Dijkstra’s minimise the weighted path length, not the number of edges.
A cycle is a path that starts and ends at the same vertex, with no repeated edges.
Example of a cycle:
A → B → C → A
This is a directed cycle of length 3.
A subgraph \(G' = (V', E')\) of a graph \(G = (V, E)\) is a graph where:
- \(V' \subseteq V\) (a subset of vertices)
- \(E' \subseteq E\) (a subset of edges, but only between vertices in \(V'\))
A spanning subgraph includes all vertices of \(G\) but only some edges.
A spanning tree of a connected graph \(G\) is a spanning subgraph that is also a tree (connected and acyclic). Prim’s algorithm finds a minimum spanning tree — the spanning tree with minimum total edge weight.
VCAA FOCUS: Be able to identify paths, weighted path lengths, and cycles in a given graph diagram. Know why subgraphs (especially spanning trees) are useful in network optimisation problems.
| Feature | Definition | Example Use |
|---|---|---|
| Path | Sequence of adjacent vertices | Route from A to B |
| Weighted path length | Sum of edge weights on a path | Shortest route cost |
| Cycle | Path that starts and ends at same vertex | Detecting infinite loops |
| Subgraph | Subset of vertices and edges | Spanning trees in MST algorithms |