Master Graphs& Network Structures
Learn graph representations, traversals, and operations with interactive visualizations.
Choose OperationStart Visualizing
Click on any operation to see it in action with interactive step-by-step visualization
Add Vertex
EasyAdd new node to the graph.
O(1)Add Edge
EasyConnect two vertices with an edge.
O(1)Remove Vertex
MediumDelete vertex and all connected edges.
O(V + E)Remove Edge
EasyDelete connection between two vertices.
O(1)BFS Traversal
MediumBreadth-first search traversal.
O(V + E)DFS Traversal
MediumDepth-first search traversal.
O(V + E)Check Path
MediumCheck if path exists between vertices.
O(V + E)Get Adjacency
EasyGet all neighbors of a vertex.
O(1) / O(V)Vertex Degree
EasyCount edges connected to vertex.
O(1) / O(V)Detect Cycle
HardCheck if graph contains cycles.
O(V + E)Connected Components
MediumFind all disconnected subgraphs.
O(V + E)Topological Sort
HardLinear ordering of directed acyclic graph.
O(V + E)Each operation includes interactive visualization, code implementation, and complexity analysis
All Graph OperationsDetailed Overview
Explore 12 graph operations with complexity analysis, pros & cons, and use cases
Graph RepresentationsComparison
Compare Adjacency List vs Adjacency Matrix
| Operation | Adjacency List | Adjacency Matrix | Notes |
|---|---|---|---|
| Add Vertex | O(1) | O(V²) | Matrix needs resizing |
| Add Edge | O(1) | O(1) | Both constant time |
| Remove Vertex | O(V + E) | O(V²) | List faster, matrix restructure |
| Remove Edge | O(E) | O(1) | Matrix direct access |
| Query Edge | O(V) | O(1) | Matrix faster lookup |
| Find Neighbors | O(1) | O(V) | List stores neighbors |
| Space | O(V + E) | O(V²) | List better for sparse |
| Best For | Sparse graphs | Dense graphs | Use case dependent |
Graph Characteristics
Vertices (V): Nodes in graph
Edges (E): Connections between nodes
Directed: One-way connections
Undirected: Two-way connections
Weighted: Edges have values
Sparse: E << V2
Dense: E ≈ V²
Adj List: Array of lists
Adj Matrix: 2D array V×V