Calculator Input
Example Data Table
| Field | Example Value | Purpose |
|---|---|---|
| Nodes | A, B, C, D, E, F, G | Defines the full graph vertex set. |
| Edges | A,B,2 | A,C,1 | C,D,1 | D,F,2 | F,G,1 | Creates connectivity and optional edge weights. |
| Start Node | A | Sets the source vertex for traversal. |
| Target Node | G | Allows path extraction from source to destination. |
| Method | BFS / DFS / Dijkstra | Selects the search or weighted path strategy. |
| Expected Insight | Order, parent tree, level or depth, path, reachability | Summarizes main graph traversal outcomes. |
Formula Used
1) Breadth-First Search level rule
For each newly discovered node v from parent u,
the level is computed as Level(v) = Level(u) + 1.
This gives the minimum number of edges from the start node in an unweighted graph.
2) Depth-First Search depth rule
When DFS visits a child node v from parent u,
the depth becomes Depth(v) = Depth(u) + 1.
DFS explores one branch deeply before backtracking.
3) Dijkstra relaxation rule
For a weighted edge from u to v with weight w(u,v),
the update is dist(v) = min(dist(v), dist(u) + w(u,v)).
This returns the minimum path cost when all weights are nonnegative.
4) Density formula
For directed graphs, density is E / (V(V-1)).
For undirected graphs, density is 2E / (V(V-1)).
Here V is the number of nodes and E is the number of edges.
5) Average degree
In undirected graphs, average degree is 2E / V.
In directed mode, this calculator reports average outgoing degree as E / V.
This helps estimate how quickly search branches may grow.
BFS ≈
O(V + E)DFS ≈
O(V + E)Dijkstra in this implementation ≈
O(V² + E)
How to Use This Calculator
- Enter nodes using commas, spaces, or separate lines.
- Enter one edge per line using
from,toorfrom,to,weight. - Select whether the graph is directed or undirected.
- Choose BFS for layer discovery, DFS for deep exploration, or Dijkstra for weighted shortest paths.
- Set the start node and optionally add a target node.
- Choose input order or alphabetical neighbor processing.
- Submit the form to display results above the calculator.
- Review traversal order, path details, reachability, tables, and the Plotly chart.
- Use the CSV or PDF buttons to export the generated analysis.
Frequently Asked Questions
1) What does this graph traversal calculator compute?
It computes traversal order, parent relationships, levels or depths, weighted distances, reachability, component counts, density, and the path to a selected target node.
2) When should I use BFS?
Use BFS when you need the shortest path by edge count in an unweighted graph, or when you want to inspect nodes level by level from the start node.
3) When should I use DFS?
Use DFS when you want to explore deep branches first, inspect discovery structure, or build a traversal tree that follows stack-like expansion behavior.
4) Can this calculator work with weighted graphs?
Yes. Weighted edges are accepted. Dijkstra uses them for shortest-path cost calculations. BFS and DFS still traverse by structure and neighbor order, not by total weight.
5) Why do some nodes appear as unreached?
A node is unreached when no valid route exists from the chosen start node under the current graph direction and edge configuration.
6) Does directed mode change the result?
Yes. In directed mode, traversal follows edge direction strictly. A connection from A to B does not automatically allow travel from B back to A.
7) How is the path to the target chosen?
BFS returns the minimum-edge path in unweighted settings. DFS returns the discovered tree path. Dijkstra returns the minimum-cost path for nonnegative weighted graphs.
8) What does the chart represent?
The chart plots the visit order on the horizontal axis and the selected metric, such as level, depth, or distance, on the vertical axis.