title: Graph programming in Scheme
body: <p>I'm new to Scheme, have been using MIT Scheme for sometime now. I'm trying to understand how to implement popular graph algorithms like the shortest path algorithms, BFS, DFS. Are there any tutorials that could help me out understand the recursion that'd be involved, along with the appropriate data structures? I have tried Googling my way around, but that didn't end up giving me good results.</p>
  
  <p><strong>EDIT</strong>: I apologize for not being more specific earlier. My question was pertaining to traversing the whole graph, and not finding the path between a <em>start</em> and <em>goal</em> node. So, given a graph <em>G(V, E)</em>, where <em>V</em> is the vertex set and <em>E</em> is the edge set, starting from any node <em>n</em>, what is the path generated so that at the end of this traversal, all nodes are visited. </p>
  
  <p>Most implementations that I found while Googling were the ones with the <em>start</em> and <em>goal</em> node. My version (one of the answers), chooses one vertex, and visits all others.</p>
  
  <p>Take for example, the following graph:-</p>
  
  <pre><code>1 ----&gt; 2           5
         /|          /|
        / |         / |
       /  |        /  |
      /   |       /   |
     /    |      /    | 
    4&lt;----3 &lt;---6     7
  </code></pre>
  
  <p>This <em>DAG</em> has (4->2), (2->3), (5->6) and (5->7), which I unable to represent in the diagram. :-)</p>
  
  <p>The Path traversed starting from <strong>1</strong> could be:</p>
  
  <p>(1, 2, 3, 4, 5, 6, 7)</p>