Basic structures needed:

- The graph to be analysed. Denote it by G = (V,E), where V is the vertex set and E is the edge set.
- The tree T which is incrementally built, which can also be stored as a graph. Denote it by T = (S,A), where S is the vertex set and A is the edge set. Note that T is a subgraph of G.
- A priority queue in which each element is an edge (u,v) where u is in S and v is in V - S. The edge (u,v) has an associated value equal to the length of (u,v) plus the length of the path from s to u in T.

T is the empty graph; PQ is an empty priority queue; Add s to T; mark s as visited in G; Add each edge (s,v) of G to PQ with appropriate value while (T.size() < G.size() and PQ not empty) do nextEdge = PQ.removeMin(); until(one vertex of nextEdge is visited and the other is unvisited) or until there are no more edges in PQ // assume nextEdge = (v,u) where v is visited (in T) and u is unvisited (not in T) Add u to T; mark u as visited in G; Add (u,v) to T; for each unvisited neighbor w of u add (u,w) to PQ with appropriate weightWhen the procedure finishes, T should contain all vertices reachable from s, along with a shortest path from s to each such vertex.

Disclaimer: Many details still need to be considered, but this is the essential information needed to implement the algorithm.

Consider the following graph:

From that graph, the algorithm would construct the following tree for a start node of Williamstown. Costs on edges indicate total cost from the root.