title: Remove node from graph during traversal
body: <p>I am trying to delete a node/set of nodes from a defined graph (org.jgrapht.Graph) before doing a Topological traversal on it.</p>
  
  <p>Sample graph definition</p>
  
  <pre><code>        Graph&lt;URI, DefaultEdge&gt; g = new DefaultDirectedGraph&lt;&gt;(DefaultEdge.class);
  
          URI google = new URI("http://www.google.com");
          URI wikipedia = new URI("http://www.wikipedia.org");
          URI jgrapht = new URI("http://www.jgrapht.org");
  
          // add the vertices
          g.addVertex(google);
          g.addVertex(wikipedia);
          g.addVertex(jgrapht);
  
          // add edges to create linking structure
          g.addEdge(jgrapht, wikipedia);
          g.addEdge(google, jgrapht);
          g.addEdge(google, wikipedia);
          g.addEdge(wikipedia, google);
  </code></pre>
  
  <p>How can we remove specific nodes, say <code>wikipedia</code> (and its childs, if any) from this tree?</p>
  
  <p>I have tried different traversals available in <a href="https://jgrapht.org/guide/UserOverview#graph-traversal" rel="nofollow noreferrer">jgrapht library</a>, however all of them explicitly mentions that graph shouldn't be modified during traversal.
  Traversals tried: DepthFirst, RandomWalk, BreadthFirst, ClosestFirst, TopologicalOrder.</p>
  
  <p>Is there any way I can delete nodes with/without traversal from the graph in optimal way?</p>