DSAVisualiseData Structures & Algorithms Studio
Graphs & Connectivity Hard

Erdős Number

Breadth-first search counts the co-author links from Paul Erdös to each reachable author.

Trace input

Bounded JSON

Edit the lesson input, then build a deterministic source-linked trace.

This lesson validates its own input and operation limits.

Source scenarios

Complexity

BestO(A·M² + V + E)
AverageO(A·M² + V + E)
WorstO(A·M² + V + E)
SpaceO(V + E)

Array state

Follow the active comparisons and writes.

Live snapshot

Current operation

Trace state
Ready to explore
Source behavior & common mistakes

Treat each paper as a clique in an undirected graph. Starting from Paul Erdös, the first FIFO visit gives each reachable author the fewest collaboration links. The pinned findErdosNumber method contradicts its Javadoc for absent or unreachable names: it unboxes null and throws NullPointerException, so the lesson does not report a fabricated -1.

  • Treating one shared paper as a directed relationship.
  • Using depth-first search, which does not guarantee the smallest collaboration distance.
  • Marking an author only after exploring all of their neighbors can leave duplicate queue entries.
  • Assuming the pinned lookup returns -1 for an unreachable author; its null unboxing actually throws.

Algorithm code

Java
Erdos.javaStep linked
The highlighted line follows the current step.

Ready to begin

Press Play to see what happens.

Detailed execution
Snapshot 1 / 1
Visited 0 · Writes 0