Graph Terminology: Vertices, Edges, Directed, Undirected, Weighted
📖 Scenario: Imagine you are creating a simple map of cities connected by roads. Each city is a point (vertex), and each road is a connection (edge) between cities. Some roads have directions (one-way), and some have distances (weights).
🎯 Goal: You will build a basic graph using TypeScript objects to represent cities and roads. You will mark if roads are one-way or two-way and add distances to roads.
📋 What You'll Learn
Create a graph object with cities as keys and arrays of connected cities as values
Add a configuration variable to mark if the graph is directed or undirected
Add weights (distances) to the edges
Print the graph connections with directions and weights
💡 Why This Matters
🌍 Real World
Graphs are used to model maps, social networks, computer networks, and many other connections in real life.
💼 Career
Understanding graph basics is important for software developers working on navigation apps, recommendation systems, and network analysis.
Progress0 / 4 steps