[vtkusers] vtk Graph - Extracting a Subgraph

Dirk VanBruggen dirk.c.vanbruggen at gmail.com
Thu Aug 6 12:41:24 EDT 2009


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?

Thanks again for the great help,

Dirk

On Wed, Aug 5, 2009 at 4:43 PM, Jeff Baumes <jeff.baumes at kitware.com> wrote:

> Dirk,
>
> 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.
> 2. Create a vtkSelection representing a threshold 0-2 on the "BFS" array.
> Something along the lines of:
>
> vtkIntArray* arr = vtkIntArray::New();
> arr->InsertNextValue(0);
> arr->InsertNextValue(2);
> arr->SetName("BFS");
> vtkSelectionNode* node = vtkSelectionNode::New();
> node->SetContentType(vtkSelectionNode::THRESHOLDS);
> node->SetFieldType(vtkSelectionNode::VERTICES);
> node->SetSelectionList(arr);
> vtkSelection* sel = vtkSelection::New();
> sel->AddNode(node);
>
> See the source article here
>
> http://kitware.com/products/thesource/apr2009.html
>
> for more details on vtkSelection.
>
> 3. Use vtkExtractSelectedGraph, first input the output of the BFS filter,
> second input the selection.
>
> HTH,
> Jeff
>
> On Wed, Aug 5, 2009 at 3:20 PM, Dirk VanBruggen <
> dirk.c.vanbruggen at gmail.com> wrote:
>
>> Dear All,
>>
>> 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?
>>
>> Thank you in advance for all of your help.
>>
>> Regards,
>> Dirk
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090806/e80f37c7/attachment.htm>


More information about the vtkusers mailing list