title: Get subgraph of shortest path between n nodes
body: <p>I have an unweighted graph and I want to get a subgraph that has just the nodes and edges that contain the shortest paths between n known nodes.  In this case 3 nodes (11, 29, &amp; 13 are the names).</p>
  
  <h2>Question</h2>
  
  <p><strong>How can I get a subgraph of shortest path between n nodes in R?</strong></p>
  
  <h2>MWE</h2>
  
  <pre><code>library(ggraph)
  library(igraph)
  
  hs &lt;- highschool[highschool$year == '1958',]
  set.seed(11)
  graph &lt;- graph_from_data_frame(hs[sample.int(nrow(hs), 60),])
  
  
  # plot using ggraph
  ggraph(graph, layout = 'kk') + 
      geom_edge_fan() + 
      geom_node_text(aes(label = name)) 
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/5QSQq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5QSQq.png" alt="enter image description here"></a></p>
  
  <h2>Desired Output</h2>
  
  <p>The desired output would be the following green subgraph (Or close, I'm eyeballing the graph above and visually picking out what would be the subgraph) ignoring/removing the other nodes and edges.</p>
  
  <p><a href="https://i.stack.imgur.com/2sdHQ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/2sdHQ.png" alt="enter image description here"></a></p>