title: Scheme - Working with List of Lists
body: <p>Currently for an assignment I'm working on a scheme problem where we are representing a graph using scheme lists. The first variation we are using is an edge-list graph represented as </p>
  
  <pre><code>'((x y) (y z) (x z))
  </code></pre>
  
  <p>The second variation of the graph we are using is being called an x-graph represented as </p>
  
  <pre><code>((x (y z)) (y (z)) (z ()))
  </code></pre>
  
  <p>Our task is the write two procedures to convert from each form to the other and I'm at a loss at how to tackle this problem. I understand the general idea of the formula, grabbing a node and constructing a list or deconstructing based on the edges but I don't see how the list is supposed to be built as you go along. Looking for some guidance not an answer. </p>
  
  <p>I'll post the question here just for further clarification if I did not describe it well enough.</p>
  
  <p>Consider two techniques for representing a graph as Scheme lists. We can represent a directed graph as a list of edges. We call this representation an el-graph (i.e. edge-list graph). An edge is itself a list of length two such that the first element is a symbol denoting the source of the edge and the second element is a symbol denoting the target of the edge. Note that an edge is a list (not just a pair). For example, the following is a graph: '((x y) (y z) (x z)). We can also represent a graph similar to an adjacency matrix. We call this representation an x-graph (i.e. matrix-graph). In this case, a graph is a list of adjacencies where an adjacency is a list of length two such that the first element is a node (a symbol) and the second element is a list of the targets of that node. For example, the following is a graph: '((x (y z)) (y (z)) (z ())).</p>
  
  <pre><code>Write function (el-graph-&gt;x-graph g), that accepts an el-graph g and returns an x-graph of g.
  Write function (x-graph-&gt;el-graph g), that accepts an x-graph g and returns an el-graph of g.
  </code></pre>