Graph Terminology: Vertices, Edges, Directed, Undirected, Weighted
📖 Scenario: Imagine you are organizing a small network of cities connected by roads. Each city is a point (called a vertex), and each road connecting two cities is a line (called an edge). Some roads allow travel in both directions (undirected), while others only allow one-way travel (directed). Also, roads have distances (weights) showing how far apart the cities are.
🎯 Goal: You will create a simple graph representation using arrays to list cities (vertices) and roads (edges). You will mark if roads are one-way or two-way and include distances. This will help you understand basic graph terms like vertices, edges, directed, undirected, and weighted.
📋 What You'll Learn
Create an array of city names called
vertices with 4 exact cities.Create an array of edges called
edges where each edge has a start city index, end city index, and distance.Add a variable
is_directed to indicate if the roads are one-way (1) or two-way (0).Write a loop to print all edges with city names, direction, and distance.
💡 Why This Matters
🌍 Real World
Graphs are used to model networks like roads, social connections, and computer networks.
💼 Career
Understanding graph basics is important for software roles involving data structures, algorithms, and network programming.
Progress0 / 4 steps