title: How to represent directed cyclic graph in Prolog with direct access to neighbour verticies
body: <p>I need to construct directed graph (at runtime) with cycles in Prolog and I am not sure know how to represent it. My requirement is that I need to get from one vertex to his neigbour in a constant time. </p>
  
  <p>Is it possible to represent it as a tree, e.g.:</p> 
  
  <p><code>t(left_son,V,right_son)</code> <p>but how to solve the cycles? </p></p>
  
  <p>I can make a list of edges: </p>
  
  <p><code>graph([a,b,c,d],[e(a,b),e(b,c),e(c,a),e(c,d)])</code> <p>OR just </p> <code>[a-&gt;[b],b-&gt;[c],c-&gt;[a,d],d-&gt;[]]</code> </p> but how to avoid calling function 'member' on list while searching for neighbours, which cost linear time? </p>
  Thanks for your help</p>