title: Finding the shortest route using Dijkstra algorithm
body: <p>I need to find the shortest route between 2 vertices of a graph. I have a matrix, which contains all the weights. How can I do it? Currently, I have the following code: </p>
  
  <pre><code>private int[] Dijkstra(int start, int end)
      {
          bool[] done = new bool[8];
          int[] parent = new int[8];
          for (int i = 0; i &lt; parent.Length; i++)
              parent[i] = -1;
          int[] distances = new int[8];
          for (int i = 0; i &lt; distances.Length; i++)
              distances[i] = int.MaxValue;
          distances[start] = 0;
          int current = start;
          while (!done[current])
          {
              done[current] = true;
              for (int i = 0; i &lt; 8; i++)
              {
                  if (graph[current, i] != int.MaxValue)
                  {
                      int dist = graph[current, i] + distances[current];
                      if (dist &lt; distances[i])
                      {
                          distances[i] = dist;
                          parent[i] = current;
                      }
                  }
              }
              int min = int.MaxValue;
              for (int i = 0; i &lt; 8; i++)
              {
                  if (distances[i] &lt; min&amp;&amp;!done[i])
                  {
                      current = i;
                      min = distances[i];
                  }
              }
          }
          return parent;
      }
  </code></pre>
  
  <p>It works, but, however I don't know how to make it find the shortest route between, for example 1 and 3, and return the route like 1=>4=>2=>3.<br>
  Thanks in advance.</p>