MCPcopy Create free account
hub / github.com/Kitware/VTK / TestGraphIterators

Function TestGraphIterators

Common/DataModel/Testing/Cxx/TestGraph.cxx:23–187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21#define VTK_CREATE(type, name) vtkSmartPointer<type> name = vtkSmartPointer<type>::New()
22
23void TestGraphIterators(vtkGraph* g, int& errors)
24{
25 if (g->GetNumberOfVertices() != 10)
26 {
27 std::cerr << "ERROR: Wrong number of vertices." << std::endl;
28 ++errors;
29 }
30 if (g->GetNumberOfEdges() != 9)
31 {
32 std::cerr << "ERROR: Wrong number of edges." << std::endl;
33 ++errors;
34 }
35 VTK_CREATE(vtkVertexListIterator, vertices);
36 g->GetVertices(vertices);
37 vtkIdType numVertices = 0;
38 while (vertices->HasNext())
39 {
40 vertices->Next();
41 ++numVertices;
42 }
43 if (numVertices != 10)
44 {
45 std::cerr << "ERROR: Vertex list iterator failed." << std::endl;
46 ++errors;
47 }
48 VTK_CREATE(vtkEdgeListIterator, edges);
49 g->GetEdges(edges);
50 vtkIdType numEdges = 0;
51 while (edges->HasNext())
52 {
53 vtkEdgeType e = edges->Next();
54 if (g->GetSourceVertex(e.Id) != e.Source)
55 {
56 std::cerr << "ERROR: Source does not match (" << g->GetSourceVertex(e.Id) << "!=" << e.Source
57 << ")" << std::endl;
58 ++errors;
59 }
60 if (g->GetTargetVertex(e.Id) != e.Target)
61 {
62 std::cerr << "ERROR: Target does not match (" << g->GetTargetVertex(e.Id) << "!=" << e.Target
63 << ")" << std::endl;
64 ++errors;
65 }
66 ++numEdges;
67 }
68 if (numEdges != 9)
69 {
70 std::cerr << "ERROR: Edge list iterator failed." << std::endl;
71 ++errors;
72 }
73 numEdges = 0;
74 VTK_CREATE(vtkOutEdgeIterator, outEdges);
75 g->GetVertices(vertices);
76 while (vertices->HasNext())
77 {
78 vtkIdType v = vertices->Next();
79 g->GetOutEdges(v, outEdges);
80 vtkIdType index = 0;

Callers 1

TestGraphFunction · 0.85

Calls 13

GetNumberOfVerticesMethod · 0.80
GetVerticesMethod · 0.80
GetSourceVertexMethod · 0.80
GetTargetVertexMethod · 0.80
GetOutEdgesMethod · 0.80
GetOutEdgeMethod · 0.80
GetAdjacentVerticesMethod · 0.80
GetNumberOfEdgesMethod · 0.45
HasNextMethod · 0.45
NextMethod · 0.45
GetEdgesMethod · 0.45
GetInEdgesMethod · 0.45

Tested by

no test coverage detected