[vtkusers] Unable to run BFS on graph!

Saad Khan saadkkhan64 at gmail.com
Sun Jul 6 18:32:36 EDT 2014


Hey guys I have been stuck with this for a while now! . 

1) I converted polydata to graph using
https://github.com/daviddoria/VTK-GraphConversions

2) I have displayed(visualised) the graph and converted it back to mesh
again and it is just fine 

3) However, I am trying to run Breadth First Search on a chosen vertex in
the resulting graph(to find a closed path along the polydata, for
segmentation purposes) but it only traverses through 10-15 vertices after
which it stops.

Heres my code for the traversal, can someone PLEASE! let me know what
mistake i have made( or any other solution) :

	vtkIdType root =0;
   	
    vtkSmartPointer<vtkBoostBreadthFirstSearchTree> bfsTree = 
    vtkSmartPointer<vtkBoostBreadthFirstSearchTree>::New();
  bfsTree->SetOriginVertex(root);
  bfsTree->SetInput(polyDataToGraphFilter->GetOutput());
  bfsTree->Update();

  vtkSmartPointer<vtkBoostBreadthFirstSearch> bfs = 
    vtkSmartPointer<vtkBoostBreadthFirstSearch>::New();
  bfs->SetOriginVertex(root);
  bfs->SetInput(polyDataToGraphFilter->GetOutput());
  bfs->Update();
 

  vtkSmartPointer<vtkTreeBFSIterator> bfsIterator = 
		vtkSmartPointer<vtkTreeBFSIterator>::New();
	bfsIterator->SetStartVertex(root);
	bfsIterator->SetTree(bfsTree->GetOutput());

	//traverse the tree in a breadth first fashion
	while(bfsIterator->HasNext())
	{
		
		vtkIdType nextVertex = bfsIterator->Next();
	
		std::cout << "Next vertex: " << nextVertex  <<std::endl;

	}



THANKS!!! ( I have attached an image of the resulting graph)




--
View this message in context: http://vtk.1045678.n5.nabble.com/Unable-to-run-BFS-on-graph-tp5727763.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list