Graphs Visualizers

32

Step through every Graphs problem with animated runtime state, source highlighting, and curated test cases. Built for coding-interview prep and durable algorithmic intuition.

Alien Dictionary
Derive character order from an alien dictionary using Topological Sort (Kahn's Algorithm).
Topological Sort
All Paths From Source to Target
Use backtracking through a Directed Acyclic Graph (DAG) to eagerly collect every unique path to the target.
Graph Backtracking DFS
Bellman Ford Algorithm
Computes the absolute shortest paths sequentially from a source node to all other reachable nodes. Safely handles negative edges and detects negative cycles.
Graphs / Shortest Path
Breadth First Search (BFS)
Generic Level-Order Graph Traversal starting from a given node. Essential foundation for shortest path algorithms.
Graphs / Traversal
Cheapest Flights Within K Stops
Apply a level-bounded Bellman-Ford traversal to find the minimum cost trail with at most K transfers.
Bellman-Ford / BFS
Clone Graph
Perform a BFS to deeply copy an undirected graph, resolving cycles using a hash map.
Graph BFS / DFS
Course Schedule
Detect cycles in a directed graph using DFS (visited states) to determine if all courses can be finished.
DFS Cycle Detection
Course Schedule II
Determine the topological order of courses using Kahn's Algorithm (BFS) and detect cycles in prerequisites.
Topological Sort (Kahn's)
Depth First Search (DFS)
Generic Graph Traversal that dives deep into branches before backtracking. Foundational for cycle detection and topological sort.
Graphs / Traversal
Detect Cycle in Undirected Graph
Use DFS to check for cycles. We find a cycle when we explore a node that is already visited and is not the direct parent of the current node.
Graphs / DFS
Dijkstra's Algorithm
Computes the absolute shortest paths sequentially from a source node to all other reachable nodes in a positively edge-weighted graph.
Graphs / Shortest Path
Find if Path Exists in Graph
Convert an edge list to an adjacency list, then run BFS with visited sets until the destination is found.
Graph BFS
Find the City with Smallest Neighbors
Execute Floyd-Warshall to compute all-pairs shortest paths and identify the city with minimal threshold-connectivity.
Floyd-Warshall (All-Pairs)
Floyd Warshall Algorithm
Computes the shortest paths between ALL pairs of nodes simultaneously in a weighted graph using a 2D matrix dynamic programming approach.
Graphs / Shortest Path
Graph Valid Tree
Verify if a graph is a valid tree (connected and no cycles) using Union-Find.
Union-Find
Kahn's Algorithm (BFS Topo Sort)
Computes a Topological Sort of a DAG using BFS by systematically removing nodes with 0 incoming edges. Unreachable nodes indicate a cycle.
Graphs / Topo Sort
Kruskal's Algorithm (MST)
Constructs a Minimum Spanning Tree greedily by sorting edges by weight and using a Disjoint Set structure to safely combine components.
Graphs / Minimum Spanning Tree
Max Area of Island
Scan a grid and launch recursive DFS traversals to sink sub-islands and measure their cumulative area.
Graph Matrix DFS
Min Cost to Connect All Points
Construct a Minimum Spanning Tree (MST) using Prim's algorithm to link 2D points with minimal total Manhattan distance.
Prim's MST
Network Delay Time
Broadcast a signal through a weighted directed graph using Dijkstra's Algorithm to find total transmission time.
Dijkstra's Algorithm
Number of Islands
Identify and count disconnected land masses in a grid using recursive DFS flood filling.
Graph Matrix DFS
Number of Operations to Make Network Connected
Count isolated network clusters using DSU and determine the minimum number of cables needed to bridge them.
Union Find (DSU)
Number of Ways to Arrive at Destination
Extend Dijkstra's algorithm to count the total number of distinct paths that achieve the absolute minimum travel time.
Dijkstra + DP
Pacific Atlantic Water Flow
Multi-source DFS/BFS to find cells that can reach both the Pacific and Atlantic oceans.
Graph Matrix DFS
Prim's Algorithm (MST)
Constructs a Minimum Spanning Tree greedily by growing a single connected component and selecting the cheapest incident edge at each step.
Graphs / Minimum Spanning Tree
Reconstruct Itinerary
Reconstruct a flight itinerary using Hierholzer's algorithm for finding an Eulerian Path.
Hierholzer Algorithm
Redundant Connection
Use a Disjoint Set Union (DSU) structure to identify exactly which edge mathematically creates a cycle in a tree structure.
Union Find (DSU)
Shortest Path in Binary Matrix
Navigate an 8-directional binary grid using BFS to find the minimal distance from start to finish.
Matrix BFS
Shortest Path in Unweighted Graph - BFS
Finds the shortest path from a source node to all other nodes in an unweighted graph using Level Order Traversal (BFS).
Graphs / Shortest Path
Swim in Rising Water
Find the minimum time to swim to the target using Dijkstra on a grid of elevations.
Dijkstra Priority Queue
Topological Sort - DFS
Orders a Directed Acyclic Graph (DAG) linearly such that for every directed edge U -> V, node U comes before V. DFS solves this natively using a post-order stack process.
Graphs / Topo Sort
Word Ladder
Find the shortest transformation sequence between two words using BFS on word mutations.
BFS Shortest Path