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




