t;distance(&quot; &lt;&lt; index(*vi) &lt;&lt; &quot;) = &quot; 
              &lt;&lt; d[*vi] &lt;&lt; std::endl;
  std::cout &lt;&lt; std::endl;
</pre>
The output is:
<pre>
  distances from start vertex:
  distance(0) = 0
  distance(1) = 6
  distance(2) = 1
  distance(3) = 4
  distance(4) = 5
</pre>
<p>&nbsp;
<h2>Extending Algorithms with Visitors</h2>
<p>Often times an algorithm in a library <i>almost</i> does what you need, but
not quite. For example, in the previous section we used Dijkstra's algorithm