DSA Repository

Graphs

A graph is a way to connect things.

The things are called vertices or nodes.

The connections are called edges.

Files In This Folder

Fast Idea

AlgorithmMain Idea
BFSExplore level by level
DFSGo deep, then backtrack
DijkstraFind shortest path with non-negative weights
Topological SortOrder tasks so prerequisites come first

Real-Life Picture

  • Graph: cities and roads
  • BFS: spreading wave
  • DFS: walking down one path in a maze
  • Dijkstra: GPS shortest route

See Also

For side-by-side notes, read Comparison.

For diagram-heavy notes, read Visual Comparison.