[vtkusers] Visualizing a vtkGraph

Jeff Baumes jeff.baumes at kitware.com
Fri Nov 6 09:16:59 EST 2009


On Fri, Nov 6, 2009 at 7:33 AM, David Doria
<daviddoria+vtk at gmail.com<daviddoria%2Bvtk at gmail.com>
> wrote:

> I am still having a problem with the minimum spanning tree claiming that it
> is a forest. I wrote a big function to connect the graph so now (according
> to my code, which I suppose could have a bug) every vertex can be reached
> from any vertex - but the MST still claims it is a forest...
>
> I then tried to write out the graph so I could visualize it and see if
> there are any apparent disconnected regions. I did the following:
>

Why not just visualize the graph in VTK? This is the visualization toolkit
after all ...

vtkGraphLayoutView* view = vtkGraphLayoutView::New();
view->AddRepresentationFromInput(G);

view->ResetCamera();
view->Render();
view->GetInteractor()->Start();

The view has a vtkGraphLayout filter inside, and allows you to change the
layout strategy (which defaults to a force-directed strategy).

You can also use vtkBoostConnectedComponents to see if your graph is indeed
connected. Just get the output of the filter, extract the vertex array named
"component", and see if the max value is indeed 0.

Jeff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091106/c9e529a7/attachment.htm>


More information about the vtkusers mailing list