title: R: calculating single shortest path between two vertices
body: <p>Currently, I am working on a project that involves NYC Taxi data, in which I am given where a person is picked up and dropped off in a network.</p>
  
  <p>I am working with an <code>ESRI</code> <code>shapefile</code>, which I can load into R as an <code>igraph</code> object with the <code>shp2graph</code> package; I need to utilize Dijkstra's algorithm (or a similar shortest-path algorithm) to find the single shortest path between two given vertices. I thought that the <code>get.shortest.paths()</code> method of the <code>igraph</code> package would be my solution, but to my surprise, this calculates <em>all</em> shortest paths from a vertex to all others in a network. </p>
  
  <p>To me, this seems like overkill, because I need only <em>one</em> single path between <em>two</em> specified nodes. I did some poking around online and in the <code>igraph</code> documentation, but all I can find are methods surrounding calculating many shortest paths from a given vertex to all others.</p>
  
  <p>Due to how computationally expensive it would be to calculate every single shortest path from a vertex, and then just select one from the behemoth of a list, I'm looking for a way to utilize Dijkstra's algorithm between two specified vertices in a graph. Is there a way to do this in the <code>igraph</code> package, or if not, is there a good way to do this with a different package in R?</p>
  
  <p><strong>EDIT:</strong> In the end, I am hoping to look for a function that will take in the graph object and the ID of two vertices I wish to find the shortest path between, then return a list of paths/edges (or IDs) along that shortest path. This would help me to inspect each individual street along the shortest path between the two vertices.</p>
  
  <p><strong>EDIT:</strong> As an example of how I am currently using the function:
  <code>path &lt;- get.shortest.paths(NYCgraph, from=32, mode="out")</code>. Something I would hope to find is <code>path &lt;- shortestPathFunction(NYCgraph, from=32, to=37)</code> to arbitrary calculate a shortest path between vertex ID 32 and vertex ID 37 (two random street intersections in the network).</p>