[vtkusers] Strange results with MST filter
David Doria
daviddoria+vtk at gmail.com
Mon Apr 19 08:09:24 EDT 2010
>
> Jeff,
>
> Trying another algorithm is a good idea. I'm curious why Kruskal's
> algorithm is a vtkSelectionAlgorithm subclass, while Prim's algorithm
> is a vtkTreeAlgorithm subclass? Wouldn't it be nice to be able to
> exchange the two directly?
>
> Trying to get Kruskal's algorithm working, I tried this:
>
> vtkSmartPointer<vtkBoostKruskalMinimumSpanningTree> kruskalFilter =
> vtkSmartPointer<vtkBoostKruskalMinimumSpanningTree>::New();
> kruskalFilter->SetInputConnection(reader->GetOutputPort());
> kruskalFilter->SetEdgeWeightArrayName("Weights");
> kruskalFilter->Update();
>
> vtkSmartPointer<vtkExtractSelection> extractSelection =
> vtkSmartPointer<vtkExtractSelection>::New();
> extractSelection->SetInput(0, reader->GetOutput());
> extractSelection->SetInput(1, kruskalFilter->GetOutput());
> extractSelection->Update();
>
> cout << "selection output is type: " <<
> extractSelection->GetOutput()->GetClassName() << endl;
>
> //output information about the minimum spanning tree
> vtkDataObject* dataObject = extractSelection->GetOutput();
> vtkGraph* mst = vtkGraph::SafeDownCast(dataObject);
>
> I tried to cast this 'dataObject' to a vtkGraph and a vtkTree, and
> both failed (mst was NULL).
>
> How would I get the Kruskal MST into a vtkTree?
>
> Thanks,
>
> David
>
Any thoughts on this?
Thanks,
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100419/e3f1d3a1/attachment.htm>
More information about the vtkusers
mailing list