AlgoPrecision

Graph Visualizer

Graph Traversal

Trace BFS, DFS, and Dijkstra across a weighted directed graph with frontier, visited, settled, and distance state.

Almost O(1) per operation
4251731A0B1C2D3E4F5

Step Note

Start with each node in its own disjoint set.

Details
function unionFind(edges: Edge[]) {
  const parent = makeSet()
  for (const edge of edges) {
    if (find(edge.u) !== find(edge.v)) {
      union(edge.u, edge.v)
    }
  }
}