Networks of vertices and edges modeling complex relationships and pathways.

Theory & Description

A graph consists of a set of vertices (nodes) connected by edges. Graphs can be directed or undirected, weighted or unweighted, and cyclic or acyclic. They model complex relationships like social networks, road maps, and dependency systems. Key traversal algorithms include Depth-First Search (DFS) and Breadth-First Search (BFS), while pathfinding uses Dijkstra's and Bellman-Ford algorithms.

Common Use Cases

  • Social network connections
  • Map routing and GPS navigation
  • Dependency resolution in build systems
  • Network topology and circuit analysis

Complexity Cheat Sheet

OperationAverageWorst
Add VertexO(1)O(1)
Add EdgeO(1)O(1)
BFS / DFSO(V + E)O(V + E)
Remove VertexO(V + E)O(V + E)
Space ComplexityO(V + E)

Interactive Visualization

Interactive Visualization

An interactive playground for Graphs will appear here. Insert elements, step through operations, and watch the data structure update in real time.