Graph Builder
Interactive Algorithm Visualizer

Graph Controls

Algorithms

Export

Help

Sample graph loaded with source and target selected

Graph Theory & Algorithms

What is a Graph?

A graph is a mathematical structure consisting of vertices (nodes) connected by edges (links). Graphs can be directed (edges have direction) or undirected (edges are bidirectional). They're fundamental in computer science for modeling relationships, networks, and solving complex problems.

Dijkstra's Algorithm

Dijkstra's algorithm finds the shortest path between nodes in a weighted graph. It works by maintaining a set of unvisited nodes and repeatedly selecting the node with the smallest known distance from the source. The algorithm guarantees the shortest path in graphs with non-negative edge weights.

Time Complexity: O((V + E) log V) where V is vertices and E is edges.

Use Cases: GPS navigation, network routing, social network analysis.

Breadth-First Search (BFS)

BFS explores a graph level by level, visiting all neighbors of a node before moving to the next level. It uses a queue data structure and is guaranteed to find the shortest path in unweighted graphs. BFS is excellent for finding the minimum number of steps to reach a goal.

Time Complexity: O(V + E)

Use Cases: Finding shortest path in unweighted graphs, web crawling, social network friend suggestions.

Depth-First Search (DFS)

DFS explores as far as possible along each branch before backtracking. It uses a stack (or recursion) and is useful for detecting cycles, topological sorting, and finding connected components. DFS doesn't guarantee the shortest path but is memory efficient.

Time Complexity: O(V + E)

Use Cases: Cycle detection, topological sorting, maze solving, finding connected components.

How to Use This App

Creating Nodes: Click anywhere on the canvas to create a new node.

Creating Edges: Click and drag from one node to another to create an edge.

Deleting: Right-click on nodes or edges to delete them.

Running Algorithms: Select source and target nodes by clicking them, then run any algorithm.

Visualization: Watch as algorithms explore the graph step by step, with different colors showing visited nodes and the final path.