Shortest Path Problem

Problem: Find the minimum number of "hops" on a path from node "A" to node "J". Each node visited on a path, including the target node, is called a hop.

Update: Click the "Update" button to start and anytime the applet needs to be redrawn.

Current: There is always a "current" node. Initially it is "A". The current node is shown in the middle box labeled "current:".

Queue: A container of nodes (and even copies of nodes). A node may added to the queue using the button "Current to Queue". Only the current node can be added to the queue. A node may be removed from the queue and made the current node using the "Queue to Current" button. This is the only way the current node can be changed.

Visit: A node may be visited from the current node by pressing one of the letter buttons (the letter of the node to be visited). If there is no line between the current node and the node to be visited, nothing happens. Once a node is visited for the first time it turns red . Thereafter, the shortest distance to a visited node from "A" is given in parentheses alongside the node label. The shortest distance may decrease as the algorithm progresses.

Visible nodes: Only nodes that have been visited or are neighbors of nodes that have been visited are shown. The target node "J" is not shown at the outset.