[vtkusers] Same problem: Removal of graph vertices causes error: Could not find edge in source edge list.

Stefan Höhme stefan.hoehme at gmail.com
Thu Oct 22 14:48:16 EDT 2015


Dear all,

 

I have the same problem as described by Adrian below. Coming from VTK 5.10
to 6.3, I encounter the exact same issue with vtkGraph.

 

Your help would be much appreciated!

 

Best,

Stefan

-------- 


Betreff: 

[vtkusers] Removal of graph vertices causes error: Could not find edge in
source edge list.


Datum: 

Fri, 18 Sep 2015 17:23:27 +0200


Von: 

Adrian Friebel  <mailto:friebel at izbi.uni-leipzig.de>
<friebel at izbi.uni-leipzig.de>


An: 

VTK Users  <mailto:vtkusers at vtk.org> <vtkusers at vtk.org>



Hi everyone,

I recently moved on from VTK 5.8 / 5.10 to the 6.3 build and apparently the
vtkGraph behaves now a bit unexpected.

In the minimal example below I load an undirected graph (points &
pedigreeIDs attached to vertices, spatially neighbouring vertices are
connected), collect all pedIDs and then try to remove one vertex after the
other, using their pedIDs. That worked perfectly fine in 5.8.

And it works fine for the first couple hundred vertices, but occasionally
some throw the following message:
ERROR: In /path/to/
<http://vtk-6.3.0/Common/DataModel/vtkGraphInternals.cxx>
VTK-6.3.0/Common/DataModel/vtkGraphInternals.cxx, line 53 vtkGraphInternals
(0x7ffc54080080): Could not find edge in source edge list.

In another test I tried to manually remove all edges of a vertex before
removing the vertex itself, which didn't help either in the above cases: The
number of edges of the graph was correctly decremented by the number of
egdes the vertex had. But despite the vertices that threw above error
message apparently had still some of the edges they previously had.

Is there a new update-call that is mandatory after removal of
vertices/edges, or is it a bug? Any idea where it is coming from? I tried
6.2 with the same result.


I am a bit lost here, help is much appreciated,

Adrian.



vtkSmartPointer<vtkMutableUndirectedGraph> g =
vtkMutableUndirectedGraph::New(); vtkSmartPointer<vtkGraphReader>
graphReader = vtkSmartPointer<vtkGraphReader>::New();
graphReader->SetFileName("/path/to/ <http://graph.txt/> graph.txt");
graphReader->Update(); graphReader->GetOutput()->ToUndirectedGraph(g);
std::cout << "graph has " << g->GetVertexData()->GetNumberOfArrays() << "
vertex arrays and " << g->GetEdgeData()->GetNumberOfArrays() << " edge
arrays" << std::endl; vtkSmartPointer<vtkUnsignedLongArray> pedigreeIdArray
= vtkUnsignedLongArray::SafeDownCast(g->GetVertexData()->GetPedigreeIds());
vtkSmartPointer<vtkVertexListIterator> it =
vtkSmartPointer<vtkVertexListIterator>::New(); g->GetVertices(it);
std::set<vtkIdType> vertsToDelete; while (it->HasNext()) { vtkIdType v =
it->Next();  <http://vertstodelete.insert%28pedigreeidarray-/>
vertsToDelete.insert(pedigreeIdArray->GetValue(v)); }
for(std::set<vtkIdType>::iterator it= <http://vertstodelete.begin%28%29%3B/>
vertsToDelete.begin(); it!= <http://vertstodelete.end%28%29%3B/>
vertsToDelete.end(); ++it) { g->RemoveVertex(g->FindVertex(*it));
g->Modified(); std::cout << "num verts = " << g->GetNumberOfVertices() << "
and num pedIDEntries = " <<
g->GetVertexData()->GetPedigreeIds()->GetNumberOfTuples() << std::endl;
for(int i=0; i<g->GetVertexData()->GetNumberOfArrays(); i++)
g->GetVertexData()->GetArray(i)->DataChanged(); g->Squeeze(); }
vtkSmartPointer<vtkGraphWriter> graphWriter =
vtkSmartPointer<vtkGraphWriter>::New();
graphWriter->SetFileName("/scratch/friebel/TestData/graphVTKError/
<http://graph_collapsed.txt/> graph_collapsed.txt");
graphWriter->SetInputData(g); graphWriter->Update();

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20151022/97ba4314/attachment.html>


More information about the vtkusers mailing list