liveBook · Manning

Undirected graph

As explained in Grokking Data Structures

An undirected graph is a graph whose edges represent symmetric relationships without an orientation from one vertex to another.

Think of a friendship network: if Tiger is friends with Lion, the connection works both ways. An undirected graph models these symmetric relationships, letting every edge be traversed in either direction. section 13.4

Use an undirected graph to reason about relationships, paths, and groups:

  • Represent a connection between vertices u and v as usable from u to v and from v to u. section 13.4
  • Find direct neighbors, then examine second-degree, third-degree, or farther connections. section 13.12
  • Identify connected components: groups in which every vertex can reach the others, while separate groups have no connecting path. section 13.6
  • Implement graphs commonly with adjacency lists or, in niche contexts, adjacency matrices; use BFS for minimum-edge paths and DFS for connectivity or cycle checks. section 13.16

Comparing friendship circles

Suppose Tiger has five direct friends and Lion has four. Their direct-friend sets do not overlap, but their second-degree neighborhoods share Giraffe and Chicken. The graph therefore reveals both immediate relationships and farther connections that may link otherwise separate-looking circles. section 13.12

Explore the friendship-graph figure to compare direct neighbors with progressively farther connections. section 13.12

How Grokking Data Structures covers it

How deep it goes
Defines two-way traversal, connected components, representations, BFS, and DFS, but does not provide implementation code or formal proofs.
Examples
Uses Facebook friendship, LinkedIn connections, Tiger and Lion neighborhoods, and disconnected clusters as concrete graph examples.
What you can do after
Evaluate relationships, identify connected components, and choose BFS or DFS for graph traversal and path analysis.
How it connects
Connects undirected graphs with directed graphs, trees, adjacency lists, adjacency matrices, BFS, DFS, paths, cycles, and connected components.

Also explained in

Compare how 5 books explain undirected graph →

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.