Graph representations (adjacency matrix vs list)
📖 Scenario: You are helping a friend understand how to represent a simple network of cities connected by roads. Each city is a point, and roads connect pairs of cities. You will create two common ways to show these connections: an adjacency matrix and an adjacency list.
🎯 Goal: Build two data structures for the same graph: one using an adjacency matrix and one using an adjacency list. This will help you see how the same information can be stored differently.
📋 What You'll Learn
Create a graph with exactly 4 cities named 'A', 'B', 'C', and 'D'.
Represent the connections between cities as given: A connected to B and C, B connected to C, and C connected to D.
Create an adjacency matrix showing these connections with 1 for connected and 0 for not connected.
Create an adjacency list showing the same connections with each city listing its connected neighbors.
💡 Why This Matters
🌍 Real World
Graph representations are used in maps, social networks, and computer networks to show how points connect.
💼 Career
Understanding graph data structures is important for software developers, data scientists, and network engineers to model and analyze relationships.
Progress0 / 4 steps