Shortest Unweighted Path Finder

Breadth-first shortest path between two nodes of an unweighted graph given as an adjacency map; reports the hop count and node sequence, or no path.

Description

Find a minimum-hop path between two named nodes in an unweighted directed or undirected graph.

The shortest unweighted path finder answers reachability and minimum hop count when each graph edge has the same cost. It is useful for social links, simple dependency chains, board moves, and network layers where weighted routing would add no information.

When to use Shortest Unweighted Path Finder

  • Find the fewest edges between two nodes
  • Check whether a target is reachable
  • Compare directed and undirected interpretations of the same adjacency map

How the calculation works

Breadth-first search visits nodes in increasing distance from the source. The first discovery of a node therefore uses a shortest path. Parent links are recorded during the search and followed backward to reconstruct the returned node sequence.

Interpreting the result

A successful result has `found: true`, a `distance` equal to the number of edges, and a path that includes both source and target. An unreachable target returns `found: false`, distance `-1`, and an empty path. A node's path to itself has distance zero.

Important limitations

  • All edges are assumed to have equal cost; use Dijkstra's algorithm for non-negative weighted edges.
  • If several minimum-hop paths exist, adjacency order determines which one is returned.
Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies