title: Prolog weighted undirected graph
body: <p>Ik keep struggling with making a weighted undirected graph in Prolog.</p>
  
  <p>The graph is represented by a x-number of predicates like:</p>
  
  <pre><code>% connection(+Source, +Destination, +Weight).
  connection(A,B,2).
  connection(A,C,3). 
  </code></pre>
  
  <p>What i want to achieve is to make an predicate which gives me the route between two given points (like the route between point A and G)</p>
  
  <p>The graph will be like this:</p>
  
  <pre><code>edge(A,B). 
  edge(A,C). 
  edge(B,D). 
  edge(C,D). 
  edge(D,F). 
  edge(D,E). 
  edge(B,F). 
  edge(E,G). 
  </code></pre>
  
  <p>The predicate has to be like this: <code>route(+From, +To, -Path)</code></p>
  
  <p>Any help is really appreciated!</p>
  
  <p>*Edit</p>
  
  <p>When I use this code:</p>
  
  <pre><code>path(Node, Node, _, [Node]).
  path(Start, Finish, Visited, [Start | Path]) :-
      verbinding(Start, X,_),
      not(member(X, Visited)),
      path(X, Finish, [X | Visited], Path).
  </code></pre>
  
  <p>It gives me the result I want, but it is not following the predicate <code>route(+From, +To, -Path)</code>. I would like to get the route from point X to Y without having to worry about the weights.</p>