Specify an adjacency-lists representation of the undirected graph given above. [Graph: An undirected graph with vertices {1, 2, 3, 4, 5} and edges visible in the figure. The graph shows a small connected graph with edges such as 1-2, 1-3, 2-4, 3-4, 3-5, 4-5.]
GATE 1987 · Discrete Mathematics · Graph Connectivity · easy
Answer: Adjacency list: 1: [2, 3]; 2: [1, 4]; 3: [1, 4, 5]; 4: [2, 3, 5]; 5: [3, 4]
- Read edges from the graph: From the figure: vertex 1 connects to 2 and 3; vertex 2 connects to 1 and 4; vertex 3 connects to 1, 4, and 5; vertex 4 connects to 2, 3, and 5; vertex 5 connects to 3 and 4.
- Write the adjacency lists: 1: [2, 3] | 2: [1, 4] | 3: [1, 4, 5] | 4: [2, 3, 5] | 5: [3, 4]