Skip to content

Frontier and Visited State on Graphs

Simulation loading

Open Model Lab is preparing the live lab, controls, and graph surface for this concept.

Wrap-up

What you learned

Recommended next
Open concept testCheck whether the core ideas are ready without leaving this concept.
Read next
Sorting and Algorithmic Trade-offsCompare graph-traversal bookkeeping with visible list work

Key takeaway

  1. Frontier means discovered and waiting to be expanded.
  2. Visited means the node's neighbors have already been checked.
  3. Repeat edges become safe skips only when the visited set is tracked honestly.

Common misconception

Frontier and visited are not two names for the same set; they mark different stages of graph-search work.

A frontier node has already been discovered, but its neighbors may not have been checked yet.

Keep the update rule and repeat-skip count close to the graph state.

  1. Search bookkeeping

    Expanding the current node adds it to visited, while only newly discovered neighbors join the waiting frontier.

  2. Repeat-skip count

    Counts neighbor checks that point to already handled work instead of producing a new discovery.

Why it behaves this way

Explanation

On a graph with cycles, frontier and visited state answer different questions. The frontier shows discovered nodes still waiting to be expanded. The visited state shows nodes whose neighborhoods have already been checked.

That separation turns a loop from a trap into a bookkeeping event. When an edge points back to a visited node, the search records a repeat skip instead of reopening that node, while the remaining frontier keeps the run moving forward.

Key ideas

01Frontier means discovered and waiting, not finished.
02Visited means expanded already, so an edge back to that node becomes a repeat skip instead of new work.
03Cycles stay manageable when the current node, waiting frontier, and finished visited set stay visually separate.

Worked examples

Worked examples

Open examples when you want to see the same idea walked through step by step.

Frozen walkthrough

Step through the frozen example

Frozen walkthrough
Use the bridge-cycle graph to name what is waiting, what is finished, and what should happen when an edge points backward.

Supporter unlocks saved study tools, exact-state sharing, and the richer review surfaces that support this guided flow.

View plans
Frozen valuesUsing frozen parameters

On the bridge-cycle graph, how can you tell whether a node belongs in the frontier, the visited set, or neither?

Graph layout

Bridge cycle

Traversal mode

claimed but waiting

Target node

already expanded

1. Find the waiting work

A node belongs in the frontier after it has been discovered from an edge, but before the search has checked all of its own neighbors.

2. Mark finished expansions

A node belongs in visited only after its neighborhood has been used, so future edges back to it should not create new frontier work.

3. Read the repeat edge

When the bridge-cycle graph points back to visited work, count that edge as a repeat skip and leave the still-waiting frontier in place.

Frontier-versus-visited rule

Frontier = discovered and waiting; visited = expanded and safe to skip when seen again.
The moment a backward edge appears, this distinction explains why the traversal keeps progressing instead of reopening the cycle.

Quick test

Loading saved test state.

Accessibility

Accessibility

Open the text-first descriptions when you need the simulation and graph translated into words.

The simulation shows one labeled graph. The current node, frontier nodes, and visited nodes are highlighted differently so you can tell what is being processed now, what is waiting next, and what is already expanded.

A readout card reports the traversal mode, current node, frontier size, visited count, and target, while a cue panel shows the frontier order and the current node's neighbor list.

Graph summary

One graph compares visited count with frontier size, a second tracks current depth against deepest reached depth, and a third compares new discoveries with repeat skips.

Together they show why cyclic graph traversal needs frontier and visited state to play different roles.

Bench tools and share links

Keep stable concept links and exact-state sharing tucked away until you actually need to relaunch or share the bench.

Try this setup

Jump to a named bench state or copy the one you are looking at now. Shared links reopen the same controls, graph, overlays, and compare context.

Saved setups

Saved setups are a Supporter study tool. Stable concept links still work for everyone.

Checking saved setup access

Open Model Lab is resolving whether this bench can save locally, sync to an account, or open Supporter-only compare tools.

Copy current setup

Exact-state sharing is part of Supporter. Stable concept and section links still stay available.

Stable links

Progress and next steps

Keep progress signals, starter-track handoffs, and review prompts available without letting them compete with the live lesson flow.

Progress

Loading progress

Loading saved concept progress for this browser or synced account before showing completion status.