Thank you for the quick and helpful response. This works given that I know the vertex id to give to vtkBoostBreadthFirstSearch. In my case I have a graph that was created from vtkTableToGraph so I do not know the ids explicitly but I know the name of the vertex that I am looking for. This name is displayed on the vertex when I set the vertex label array name to "label". How do I go about finding a mapping between this string name and the vertex id? I see that vtkGraph.FindVertex may be of some help but it does not seem to be a valid function when I use it. I am using the Python Binding. Would that cause this issue?<br>
<br>Thanks again for the great help,<br><br>Dirk<br><br><div class="gmail_quote">On Wed, Aug 5, 2009 at 4:43 PM, Jeff Baumes <span dir="ltr"><<a href="mailto:jeff.baumes@kitware.com">jeff.baumes@kitware.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div>Dirk,</div><div><br></div>1. vtkBoostBreadthFirstSearch will create an integer array "BFS" on the vertices, the distance from the starting point. You can set the starting vertex on the filter.<div>
<br></div>
<div>2. Create a vtkSelection representing a threshold 0-2 on the "BFS" array. Something along the lines of:</div><div><br></div><div>vtkIntArray* arr = vtkIntArray::New();</div><div>arr->InsertNextValue(0);</div>
<div>arr->InsertNextValue(2);</div><div>arr->SetName("BFS");</div><div><div>vtkSelectionNode* node = vtkSelectionNode::New();</div><div>node->SetContentType(vtkSelectionNode::THRESHOLDS);</div><div>node->SetFieldType(vtkSelectionNode::VERTICES);</div>
<div>node->SetSelectionList(arr);</div><div>vtkSelection* sel = vtkSelection::New();</div><div>sel->AddNode(node);</div><div><br></div><div>See the source article here</div><div><br></div><div><a href="http://kitware.com/products/thesource/apr2009.html" target="_blank">http://kitware.com/products/thesource/apr2009.html</a></div>
<div><br></div><div>for more details on vtkSelection.</div><div><br></div></div><div>3. Use vtkExtractSelectedGraph, first input the output of the BFS filter, second input the selection.</div><div><br></div><div>HTH,</div>
<div>Jeff<br><br><div class="gmail_quote"><div><div></div><div class="h5">On Wed, Aug 5, 2009 at 3:20 PM, Dirk VanBruggen <span dir="ltr"><<a href="mailto:dirk.c.vanbruggen@gmail.com" target="_blank">dirk.c.vanbruggen@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="h5">
Dear All,<br><br>I am trying to find a way to take a graph, and extract a subgraph that contains a given vertex and all vertices within two hops of the given vertex. Is there a boost algorithm or a different way to accomplish this?<br>
<br>Thank you in advance for all of your help.<br><br>Regards,<br><font color="#888888">Dirk<br>
</font><br></div></div>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br>
</div>
</blockquote></div><br>