title: The first 10 shortest paths in a graph - Igraph 0.6 - Python 2.7
body: <p>I was wondering about this ever since I've started to successfully implement Igraph into my coding: Can you retrieve with <strong>get_all_shortest_paths</strong> as many shortest paths as you like. Let's say first 10.</p>
  
  <p>I've understood so far that retrieving ALL shortest paths in a undirected graph is non-sense since in most cases you have infinite amount of them. </p>
  
  <p>But can I <strong>simply retrieve first 10 shortest paths?</strong> </p>
  
  <p>I've tried to achieve this with an undirected g = Graph() :</p>
  
  <pre><code>list = []
  list.append(g.get_all_shortest_paths(index1,index2, "distance")[0])   # shortest path
  list.append(g.get_all_shortest_paths(index1,index2, "distance")[1])   # second shortest path
  list.append(g.get_all_shortest_paths(index1,index2, "distance")[2])   # third shortest path
  list.append(g.get_all_shortest_paths(index1,index2, "distance")[3])   # forth shortest path
  list.append(g.get_all_shortest_paths(index1,index2, "distance")[4])   # fifth shortest path
  list.append(g.get_all_shortest_paths(index1,index2, "distance")[5])   # sixth shortest path
  list.append(g.get_all_shortest_paths(index1,index2, "distance")[6])   # seventh shortest path
  list.append(g.get_all_shortest_paths(index1,index2, "distance")[7])   # eigth shortest path
  list.append(g.get_all_shortest_paths(index1,index2, "distance")[8])   # ninth shortest path
  list.append(g.get_all_shortest_paths(index1,index2, "distance")[9])   # tenth shortest path
  
  #"distance" is from g.es["distance"]
  </code></pre>
  
  <p>It would alway give me error that <strong>list index is out of range</strong>. 
  Actually I can't even get <code>list.append(g.get_all_shortest_paths(index1,index2, "distance")[1])</code>, though I know there are more then 10 paths there.</p>
  
  <p>There is nothing special about the graph. thousands of vertexes, all connected somehow, I mean various vertex degrees. </p>
  
  <p>Finally I would like to have a wx.spin or wx.ComboBox to choose between the paths (i.e. the shortest path which is a national highway in real life has ice on it during winter so I would like to take the second shortest road between City1 and City2... then oh no.. that has kangoroos jumping all over it so I take the third, or better forth path because there I know a McDonalds and I really like to eat junk food bla bla)</p>
  
  <p>I know shortest != short, though I need something like: if shortest no good then ignore that, go to second and so on.
  I've searched Google but it is not clear for me how can I do this.</p>
  
  <p>Thank you in advance! </p>
  
  <p>Edit: I might mention that <code>list.append(g.get_all_shortest_paths(index1,index2, "distance")[1])</code> of course is working when there are exactly 2 shortest paths with naturally the exact same distances.</p>
  
  <p><strong>Important Update:</strong></p>
  
  <p>Since I've ingloriously misunderstood <code>g.get_all_shortest_paths</code> this part will change in my code to <code>g.get_shortest_paths(index1, index2, weights=distance, mode=ALL, output="vpath")</code> and I also mention that the graph is weighted, but that bit is obvious anyway:</p>
  
  <pre><code>list = []
  g.es["weight"] = distance
  list.append(g.get_shortest_paths(index1, index2, weights=distance, mode=ALL, output="vpath")[0])   # shortest path
  list.append(g.get_shortest_paths(index1, index2, weights=distance, mode=ALL, output="vpath")[1])   # second shortest path
  list.append(g.get_shortest_paths(index1, index2, weights=distance, mode=ALL, output="vpath")[2])   # third shortest path
  list.append(g.get_shortest_paths(index1, index2, weights=distance, mode=ALL, output="vpath")[3])   # forth shortest path
  list.append(g.get_shortest_paths(index1, index2, weights=distance, mode=ALL, output="vpath")[4])   # fifth shortest path
  list.append(g.get_shortest_paths(index1, index2, weights=distance, mode=ALL, output="vpath")[5])   # sixth shortest path
  list.append(g.get_shortest_paths(index1, index2, weights=distance, mode=ALL, output="vpath")[6])   # seventh shortest path
  list.append(g.get_shortest_paths(index1, index2, weights=distance, mode=ALL, output="vpath")[7])   # eigth shortest path
  list.append(g.get_shortest_paths(index1, index2, weights=distance, mode=ALL, output="vpath")[8])   # ninth shortest path
  list.append(g.get_shortest_paths(index1, index2, weights=distance, mode=ALL, output="vpath")[9])   # tenth shortest path
  
  #"distance" is a list containing the weights
  # graph is TRUE-ly weighted now
  </code></pre>
  
  <p><strong>How to get the first 10 or all short paths between two vertex's?</strong></p>
  
  <p>This question is still looking for its answer to be accepted. Thank you.</p>
  
  <p><em>(P.S. I've kept the wrong approach in the first part of the question since might be other enormous idiobooms out there like me who try the same thing)</em></p>