[vtkusers] Minimum Spanning Trees Re: Building VTK-BGL algorithms (using cmake)

Aytekin Vargun varguna at gmail.com
Tue Dec 30 14:54:58 EST 2008


I am posting some more code here. I use this in order to display the trees I
generate in 2D.
The vertex array, ChannelColors, and Edge Weights are defined somewhere
else. This code displays the bfs tree. But if I replace the code under LINE
X below in order to display Kruskal's MST with:

view->AddRepresentationFromInput(mst->GetOutput());

I am getting the following error message:
"Need input data to render labels (2)"

But I am not getting any error messages for the same labels while displaying
the bfs tree.

I tried other ways of displaying too.
Please help.
Thanks alot.

---- Display Code ---

   VTK_CREATE(vtkBoostBreadthFirstSearchTree, bfsTree);
    bfsTree->SetInput(g);

    //Create a graph layout view

    vtkGraphLayoutView* view = vtkGraphLayoutView::New();
    view->SetLayoutStrategyToPassThrough();

    //LINE X
----->    view->AddRepresentationFromInput(bfsTree->GetOutput());
    view->SetVertexLabelArrayName("Label");
    view->SetVertexLabelVisibility(true);
    view->SetVertexColorArrayName("ChannelColors");
    view->SetColorVertices(true);
    view->SetEdgeColorArrayName("ChannelColors");
    view->SetColorEdges(true);
    //view->SetLayoutStrategyToSimple2D();

    VTK_CREATE(vtkRenderWindow, window);
    window->SetSize(1000, 1000);

    view->SetupRenderWindow(window);
    view->GetRenderer()->ResetCamera();
    window->GetInteractor()->Start();



On Tue, Dec 30, 2008 at 10:42 AM, Aytekin Vargun <varguna at gmail.com> wrote:

> Thanks a lot Jeff,
> It looks like I had several versions of VTK and this was causing problems.
>
> Now I have another problem. I am trying to use minimum spanning tree
> programs. I first tried to use vtkBoostPrimMinimumSpanningTree but I am
> getting the following error message:
>
> "The Prim minimal spanning tree filter is still under development...  Use
> at your own risk."
>
> I checked where the error message is and then assumed that I was getting
> this message since the implementation is not complete yet. But should I
> still see some output on the screen?
>
> I then tried to use vtkKruskalMinimumSpanningTree which looks like in
> better shape (whose output is a vtkSelectionAlgorithm). But I am failed to
> display its output since its output is not a tree but a forest whereas
> Prim's version produces a vtkTree . Then how can I display each subtree? One
> way of doing this probably is to cast the result to a graph and then display
> the resulting graph.
>
> I will greatly appreciate if anyone shares his/her experiences.
> Thanks a lot.
>
> Here is a simplified piece of code I am trying to run:
>
>   vtkMutableUndirectedGraph* g=vtkMutableUndirectedGraph::New();
>
>     // This is used for finding minimum-spanning trees
>     vtkIntArray* edgeWeightsArr = vtkIntArray::New();
>     edgeWeightsArr->SetName("EdgeWeights");
>
>   VTK_CREATE(vtkRenderer, ren);
>
>   VTK_CREATE(vtkPoints, pts);
>   g->AddVertex();
>   pts->InsertNextPoint(0, 1, 0);
>   g->AddVertex();
>   pts->InsertNextPoint(0.5, 1, 0);
>   g->AddVertex();
>   pts->InsertNextPoint(0.25, 0.5, 0);
>   g->AddVertex();
>   pts->InsertNextPoint(0, 0, 0);
>   g->AddVertex();
>   pts->InsertNextPoint(0.5, 0, 0);
>   g->AddVertex();
>   pts->InsertNextPoint(1, 0, 0);
>   g->AddVertex();
>   pts->InsertNextPoint(0.75, 0.5, 0);
>   g->SetPoints(pts);
>
>   g->AddEdge(0, 1);
>   edgeWeightsArr->InsertNextValue(1);
>   g->AddEdge(0, 2);
>   edgeWeightsArr->InsertNextValue(1);
>   g->AddEdge(1, 2);
>   edgeWeightsArr->InsertNextValue(1);
>   g->AddEdge(2, 3);
>   edgeWeightsArr->InsertNextValue(1);
>   g->AddEdge(2, 4);
>   edgeWeightsArr->InsertNextValue(1);
>   g->AddEdge(3, 4);
>   edgeWeightsArr->InsertNextValue(1);
>
>   g->GetEdgeData()->AddArray(edgeWeightsArr);
>
>   //VTK_CREATE(vtkBoostPrimMinimumSpanningTree,mst);
>   VTK_CREATE(vtkBoostKruskalMinimumSpanningTree,mst);
>   mst->SetInput(g);
>   mst->SetEdgeWeightArrayName("EdgeWeights");
>   mst->Update();
>
>   // HOW TO DISPLAY
>
>
>
> On Tue, Dec 23, 2008 at 3:14 PM, Jeff Baumes <jeff.baumes at kitware.com>wrote:
>
>> > When I compile the sample file, I get the first error for the following
>> > line:
>> >   VTK_CREATE(vtkBoostBiconnectedComponents, biconn);
>> >
>> > (On CMake, I had set VTK_USE_BOOST set to ON when building VTK)
>>
>> First, make sure that your app is linking against vtkInfovis. If it
>> is, it appears that the Boost algorithms are not being compiled into
>> the vtkInfovis library you are using. Ensure that the vtkInfovis you
>> are linking against is the one in the build where you turned
>> VTK_USE_BOOST on. In Visual Studio, you can check your VTK build by
>> looking at the source files under vtkInfovis. Make sure the vtkBoost*
>> files are there.
>>
>> Jeff
>>
>
>
>
> --
> My web page: http://www.cs.rpi.edu/~vargua<http://www.cs.rpi.edu/%7Evargua>
>



-- 
My web page: http://www.cs.rpi.edu/~vargua
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081230/05db46c8/attachment.htm>


More information about the vtkusers mailing list