Launch your tech mastery with us—your coding journey starts now!
Course Content
Data Structure

Graphs (The Big Picture)

Definition

A Graph is a non-linear data structure used to represent connections between objects. It consists of two main parts: Nodes (also called Vertices, representing the objects) and Edges (the lines connecting the nodes).

Graph data structure illustration showing nodes (vertices) connected by edges representing relationships or connections between data points.

How it Works

Think of a graph as a map.

  1. Vertices (V): Points on the map (e.g., cities).
  2. Edges (E): Roads connecting the cities.
    Graphs can be Directed (one-way streets) or Undirected (two-way streets). They can also be Weighted (roads with distances) or Unweighted.

Real-World Analogy

Social Networks: On Facebook, you are a “Node.” If you are friends with someone, there is an “Edge” connecting you two. This is an undirected graph (friendship is mutual). On Twitter/X, if you follow a celebrity, that is a directed graph (you follow them, but they might not follow you).