Overview & Concept
The Graph List & Matrix Workbench visualizes the two primary representations of graph data structures: Adjacency Lists and Adjacency Matrices, alongside live pathfinding algorithms (BFS, DFS, Dijkstra).
How It Works
Adjacency List: Memory-efficient linked list or dynamic array for each vertex storing its outgoing neighbors (O(V + E) space).
Adjacency Matrix: V × V 2D matrix storing edge existence and weights, allowing O(1) edge lookups (O(V²) space).
Interactive 2D Canvas: Drag-and-drop node positioning with live edge weight manipulation.
Live Execution: Stepping through BFS, DFS, and Dijkstra shortest path finding with animated node discovery and edge relaxation.
Step-by-Step Execution
Asymptotic Complexity Analysis
| Metric | Best Case | Average Case | Worst Case | Space Complexity |
|---|---|---|---|---|
| Complexity Bound | O(V + E) BFS/DFS | O((V + E) log V) Dijkstra | O(V²) dense matrix | O(V + E) list / O(V²) matrix |
| Explanation | Optimal input arrangement minimizing operations. | Expected time for uniformly distributed randomized inputs. | Adversarial degenerate conditions requiring full traversal. | Auxiliary memory allocated beyond original input size. |
Pseudocode & Invariants
// Dijkstra Shortest Path Algorithm
operation dijkstra(graph, source):
dist[source] = 0
pq.push({node: source, dist: 0})
while not pq.isEmpty():
{u, d} = pq.pop()
if d > dist[u]: continue
for {v, weight} in graph.adj[u]:
if dist[u] + weight < dist[v]:
dist[v] = dist[u] + weight
parent[v] = u
pq.push({node: v, dist: dist[v]})- Matrix Symmetry: In undirected graphs, the adjacency matrix is strictly symmetric: M[i][j] == M[j][i].
- Adjacency Sum: In adjacency lists, total entries across all lists equals 2|E| (undirected) or |E| (directed).
Advantages & Disadvantages
Key Advantages
- •Dual representation demonstrates spatial trade-offs between sparse lists and dense matrices.
- •Interactive visual workbench makes abstract graph algorithms concrete and intuitive.
Trade-offs & Limitations
- •Dense matrix visualization becomes crowded beyond 20 vertices.
Real-World Applications
Road Network Routing
GPS road network navigation and transit planning.
Network Flow & Capacity
Telecommunication bandwidth routing and network capacity analysis.
Decision Guide: When to Use
Ideal Scenarios
- ✓When studying or comparing graph representations and pathfinding algorithms.
Consider Alternatives When
- ✕When simple linear arrays suffice for non-relational data.
Explore Related Algorithms
Compare trade-offs and complexity across complementary tools in AlgoViz.