Graph Visualizer
Create graphs interactively and visualize algorithms like BFS, DFS, Dijkstra, and topological sort step by step.
About This Tool
The Graph Visualizer is a free, browser-based tool that lets you build directed or undirected graphs on an interactive canvas and watch classic graph algorithms run step by step. Whether you are a computer science student learning about traversals, a developer debugging dependency graphs, or an educator preparing a lecture, this tool provides an intuitive way to experiment with graph structures and algorithms in real time.
You can add nodes by clicking the canvas, draw edges by selecting source and target nodes, and toggle between directed and undirected modes. Edges can be weighted — simply click an edge label to change its weight. A force-directed layout engine repositions nodes automatically to reduce visual clutter, and you can always drag nodes manually for fine-tuning.
The tool supports four classic algorithms with animated, step-by-step playback: Breadth-First Search (BFS), Depth-First Search (DFS), Dijkstra’s shortest-path algorithm, and Topological Sort for directed acyclic graphs. Each step shows the current node, visited set, queue or stack contents, and distance labels (for Dijkstra), making it easy to trace the algorithm’s progress.
A properties panel displays real-time graph statistics: node and edge counts, connectivity status, cycle detection, and bipartiteness. You can also toggle an adjacency matrix or adjacency list view to see the underlying data representation — useful when studying how different representations affect algorithm performance.
All processing runs entirely in your browser. No data is sent to any server, stored, or logged. You can safely visualize private network topologies or proprietary dependency structures. Import and export graphs as simple text for sharing or archiving.
If you work with tree structures, try the Binary Tree Visualizer. For diagram generation from text, check out the Mermaid Editor. To explore sorting algorithms visually, see the Sorting Visualizer.
How to Use
- Add nodes — Click anywhere on the canvas to place a new node.
- Add edges — Select a node, click the Add Edge button, then click the target node.
- Set edge weights — Enable the Weighted checkbox, then click the weight label on any edge to change its value.
- Choose graph type — Toggle between Directed and Undirected in the dropdown.
- Run an algorithm — Select BFS, DFS, Dijkstra, or Topological Sort and click Run. Use Play, Pause, and Step to control the animation.
- Adjust speed — Drag the Speed slider to speed up or slow down the animation (100ms–2000ms per step).
- View representations — Click Adjacency Matrix or Adjacency List to see the graph data structure.
- Import/Export — Click Export to copy the graph as text, or Import to paste a previously exported graph.
Popular Graph Algorithm Examples
FAQ
Is my data safe when using this tool?
Yes. All graph construction and algorithm execution happens entirely in your browser using JavaScript. No data is sent to any server, stored, or logged. You can safely visualize private or sensitive graph structures.
What algorithms are supported?
The tool currently supports four algorithms: Breadth-First Search (BFS), Depth-First Search (DFS), Dijkstra’s shortest-path algorithm (for weighted graphs), and Topological Sort (for directed acyclic graphs). Each algorithm runs with step-by-step visualization.
Can I create weighted graphs?
Yes. Toggle the Weighted checkbox in the toolbar. Once enabled, every edge displays a weight label that you can click to edit. The default weight is 1. Dijkstra’s algorithm uses these weights to compute shortest paths.
What is the difference between directed and undirected graphs?
In an undirected graph, edges have no direction — if node A connects to node B, B also connects to A. In a directed graph, edges have a direction shown by arrowheads, so A→B does not imply B→A. Topological sort only works on directed acyclic graphs (DAGs).
How does the force-directed layout work?
The Auto Layout button applies a force-directed algorithm that treats nodes as repelling charged particles and edges as springs. After several iterations, nodes spread out to reduce edge crossings and overlap, producing a cleaner visual layout.
Can I import and export graphs?
Yes. Click Export to copy the current graph as a simple text format (one line per node and edge). Click Import, paste the text, and click Import again to load it. The format supports directed/undirected and optional edge weights.
What do the graph properties mean?
Node and edge counts show the graph size. Connected means every node can reach every other node. Has Cycles indicates whether the graph contains a cycle. Bipartite means the nodes can be split into two groups with edges only between groups, not within.
Related Tools
Binary Tree Visualizer
Visualize binary trees interactively with BST operations, traversal animations, balance checking, and AVL rotations.
Data Structure Visualizer
Visualize and interact with Stack, Queue, Linked List, Hash Table, and Heap data structures with step-by-step animations.
Sorting Visualizer
Visualize sorting algorithms step by step with animated bar charts. Compare Bubble Sort, Quick Sort, Merge Sort, Heap Sort, and more side by side.
Big-O Reference
Interactive Big-O complexity reference with growth charts, algorithm database, and comparison tools. Visualize O(1) to O(n!) growth curves.
Mermaid Diagram Editor
Write Mermaid diagrams with live preview. Export as SVG or PNG. Supports flowcharts, sequence, ER, and more.