```
let bestvert: any = null;
let it = coll.iterator;
while (it.next()) {
let v = it.value;
let dist = v.distance;
if (dist < bestdist) {
bestdist = dist;
bestvert = v;
}
}
return bestvert;
}
// keep track of vertexes we have finished examining;
// this avoids unnecessary traversals and helps keep the SEEN collection small
let finished = new go.Set(RadialVertex);
while (seen.count > 0) {
// look at the unfinished vertex with the shortest distance so far
let least = leastVertex(seen);
let leastdist = least.distance;
// by the end of this loop we will have finished examining this LEAST vertex
seen.remove(least);
finished.add(least);
// look at all edges connected with this vertex
least.edges.each(function(e: any) {
let neighbor = e.getOtherVertex(least);
// skip vertexes that we have finished
if (finished.contains(neighbor)) {return; }
let neighbordist = neighbor.distance;
// assume "distance" along a link is unitary, but could be any non-negative number.
let dist = leastdist + 1;
if (dist < neighbordist) {
```

```
private findDistances(source: RadialVertex) {
let diagram = this.diagram;
// keep track of distances from the source node
this.network.vertexes.each(function(v: RadialVertex) { v.distance = Infinity; });
// the source node starts with distance 0
source.distance = 0;
// keep track of nodes for we have set a non-Infinity distance,
// but which we have not yet finished examining
let seen = new go.Set(RadialVertex);
seen.add(source);
// local function for finding a vertex with the smallest distance in a given collection
function leastVertex(coll: any) {
let bestdist = Infinity;
let bestvert: any = null;
let it = coll.iterator;
while (it.next()) {
let v = it.value;
let dist = v.distance;
if (dist < bestdist) {
bestdist = dist;
bestvert = v;
}
}
return bestvert;
```