Skip to main content
Interactive Algorithm Education

Visualize & Master Algorithms & Data Structures

Explore classic & modern sorting algorithms, efficient searching techniques, and interactive data structure visualizations — all with real-time step-by-step animation, comparisons, swaps, and Big-O metrics.

Graph Algorithms Visualizer

BFS — Breadth-First Search

Time O(V + E) · Space O(V)
Step 0 / 0
Speed 100ms
Step Progress 0 / 0
Visited 0
Frontier 0
Status Ready
Unvisited
Start
Active
Visited
MST / SPT
Rejected
SCC component

Queue

Step Explanation

Select an algorithm and press Play to begin.

Pseudocode
 
Graph Algorithms Algorithms

Graph Algorithms Algorithm Catalog

10 algorithms in this category. Click any card for detailed analysis.

Breadth-First Search

Unstable

BFS is a graph traversal algorithm that explores all vertices reachable from a source, visiting neighbors level by level using a FIFO queue.

Ideal Use: Use BFS when you need the shortest path in an unweighted graph, level-order traversal, or connectivity checks.
Best
O(V + E)
Worst
O(V + E)
Space
O(V)
Implementation Difficulty
★ ★ ☆ ☆ ☆ 2/5
Elementary
Graph algorithm — interactive visualization

Depth-First Search

Unstable

DFS is a graph traversal algorithm that explores as far as possible along each branch before backtracking, using a LIFO stack.

Ideal Use: Use DFS for topological sorting, cycle detection, connected components, solving puzzles with single-path solutions, and tree traversals.
Best
O(V + E)
Worst
O(V + E)
Space
O(V)
Implementation Difficulty
★ ★ ☆ ☆ ☆ 2/5
Elementary
Graph algorithm — interactive visualization

Dijkstra's Algorithm

Unstable

Dijkstra's algorithm finds the shortest paths from a source node to all other nodes in a weighted graph with non-negative edge weights using a min-priority queue.

Ideal Use: Use Dijkstra for shortest-path problems in weighted graphs with non-negative weights (GPS navigation, network routing, map services).
Best
O((V + E) log V)
Worst
O((V + E) log V)
Space
O(V)
Implementation Difficulty
★ ★ ★ ☆ ☆ 3/5
Intermediate
Graph algorithm — interactive visualization

Topological Sort

Unstable

Topological Sort (Kahn's algorithm) orders the vertices of a Directed Acyclic Graph (DAG) such that for every directed edge u→v, u appears before v in the ordering.

Ideal Use: Use topological sort for task scheduling, dependency resolution (Makefile, package managers), build systems, and course prerequisite ordering.
Best
O(V + E)
Worst
O(V + E)
Space
O(V)
Implementation Difficulty
★ ★ ★ ☆ ☆ 3/5
Intermediate
Graph algorithm — interactive visualization

Prim's Algorithm

Unstable

Prim's algorithm finds a Minimum Spanning Tree (MST) for a weighted undirected graph by growing a tree one vertex at a time from an arbitrary start, always adding the cheapest edge that connects a tree vertex to a non-tree vertex.

Ideal Use: Use Prim's when you need a minimum spanning tree for a dense graph, or when you have an adjacency matrix representation.
Best
O((V + E) log V)
Worst
O((V + E) log V)
Space
O(V)
Implementation Difficulty
★ ★ ★ ☆ ☆ 3/5
Intermediate
Graph algorithm — interactive visualization

Kruskal's Algorithm

Unstable

Kruskal's algorithm finds a Minimum Spanning Tree (MST) by sorting all edges by weight and adding the cheapest edge that does not form a cycle, using the Union-Find data structure.

Ideal Use: Use Kruskal's for sparse graphs, or when edges can be easily sorted. Often preferred for its simplicity and the fact that it only needs an edge list.
Best
O(E log E)
Worst
O(E log E)
Space
O(V)
Implementation Difficulty
★ ★ ★ ☆ ☆ 3/5
Intermediate
Graph algorithm — interactive visualization

Bellman-Ford Algorithm

Unstable

Bellman-Ford finds single-source shortest paths in a weighted graph and, unlike Dijkstra, supports negative edge weights. It works by relaxing all edges V−1 times and then checking for negative cycles.

Ideal Use: Use Bellman-Ford when a graph may contain negative edge weights, or when you need to detect negative cycles. Also used inside algorithms like the currency-arbitrage (negative-cycle) problem.
Best
O(E)
Worst
O(VE)
Space
O(V)
Implementation Difficulty
★ ★ ★ ☆ ☆ 3/5
Intermediate
Graph algorithm — interactive visualization

Kosaraju's SCC

Unstable

Kosaraju's algorithm finds all Strongly Connected Components (SCCs) of a directed graph in linear time using two passes of DFS: one to order vertices by finish time, and one on the reverse graph to peel off components.

Ideal Use: Use SCC analysis to decompose a directed graph: dependency cycles, 2-SAT, transitive-closure kernels, and condensation-graph problems in compilers and databases.
Best
O(V + E)
Worst
O(V + E)
Space
O(V)
Implementation Difficulty
★ ★ ★ ☆ ☆ 3/5
Intermediate
Graph algorithm — interactive visualization

Floyd-Warshall

Unstable

Floyd-Warshall computes the shortest paths between every pair of vertices in a weighted graph. It incrementally allows each vertex as an intermediate point and updates an all-pairs distance matrix.

Ideal Use: Use for all-pairs shortest path when the graph is dense or small (V ≤ a few hundred), for transitive closure, and when you need the whole distance matrix rather than one source.
Best
O(V³)
Worst
O(V³)
Space
O(V²)
Implementation Difficulty
★ ★ ★ ☆ ☆ 3/5
Intermediate
Graph algorithm — interactive visualization

Articulation Points

Unstable

An articulation point (cut vertex) is a vertex whose removal increases the number of connected components in a graph. Tarjan's algorithm finds all articulation points in a single DFS using discovery times and low-link values.

Ideal Use: Use for network reliability: finding single points of failure in communication networks, circuit analysis, and graph-connectivity problems.
Best
O(V+E)
Worst
O(V+E)
Space
O(V)
Implementation Difficulty
★ ★ ★ ☆ ☆ 3/5
Intermediate
Graph algorithm — interactive visualization
Graph Complexity Matrix

Complexity & Performance Tradeoffs

Side-by-side comparison of Big-O time and space complexity characteristics across graph algorithms.

Algorithm Best Time Average Time Worst Time Space Complexity Stability
Breadth-First Search O(V + E) O(V + E) O(V + E) O(V) Unstable
Depth-First Search O(V + E) O(V + E) O(V + E) O(V) Unstable
Dijkstra's Algorithm O((V + E) log V) O((V + E) log V) O((V + E) log V) O(V) Unstable
Topological Sort O(V + E) O(V + E) O(V + E) O(V) Unstable
Prim's Algorithm O((V + E) log V) O((V + E) log V) O((V + E) log V) O(V) Unstable
Kruskal's Algorithm O(E log E) O(E log E) O(E log E) O(V) Unstable
Bellman-Ford Algorithm O(E) O(VE) O(VE) O(V) Unstable
Kosaraju's SCC O(V + E) O(V + E) O(V + E) O(V) Unstable
Floyd-Warshall O(V³) O(V³) O(V³) O(V²) Unstable
Articulation Points O(V+E) O(V+E) O(V+E) O(V) Unstable