liveBook · Manning

Path

As explained in Grokking Data Structures

A path is a sequence of connected nodes in a graph from one vertex to another.

A path is a sequence of connected edges that lets you travel through a graph from one vertex to another. Each edge must begin where the previous edge ends. section 13.5

Following a graph path

In the animal follower graph, Giraffe→Crocodile→Monkey→Giraffe forms a path whose first and last vertices match, so it is also a cycle. A path that does not return to its starting vertex is not a cycle. section 13.5

Paths help describe structure in several common data structures:

  • Trees contain simple paths from the root to leaves; no node appears twice, and each node has one parent except the root. section 11.2
  • A node is an ancestor of another when it lies on the path between the root and that node; the reverse relationship is descent. section 11.2
  • A tree's height is the length of its longest root-to-leaf path, while a heap has height as small as log(n). section 11.2 section 10.11
  • A graph with no cycles is acyclic; a cycle is a path that starts and ends at the same vertex. section 13.5

Use the graph figure to trace connected edges, identify cycles, and distinguish paths that return to their starting vertex. section 13.5

How Grokking Data Structures covers it

How deep it goes
Defines connected edge sequences and derives tree and heap properties, but stops short of implementation or traversal algorithms.
Examples
Traces animal follower edges, root-to-leaf tree routes such as 0→2→6→3, and sorted root-to-leaf heap paths.
What it assumes
Builds the definition from connected edges, vertices, and destinations before relating paths to trees, graphs, and heaps.
What you can do after
Evaluate paths, cycles, ancestry, and tree or heap height in small graph-based examples.
How it connects
Connects paths with graphs, vertices, edges, cycles, trees, roots, leaves, ancestors, descendants, and heaps.

Also explained in

Compare how 4 books explain path →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Data Structures. The section links point to the parts of the book it draws on.