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

Function TestToUndirectedGraph

Common/DataModel/Testing/Cxx/TestGraph2.cxx:95–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95int TestToUndirectedGraph()
96{
97 // Create a directed graph
98 vtkSmartPointer<vtkMutableDirectedGraph> dg = vtkSmartPointer<vtkMutableDirectedGraph>::New();
99 vtkIdType v0 = dg->AddVertex();
100 vtkIdType v1 = dg->AddVertex();
101 vtkIdType v2 = dg->AddVertex();
102
103 dg->AddEdge(v0, v1);
104 dg->AddEdge(v1, v2);
105
106 // Convert it to an undirected graph
107 vtkSmartPointer<vtkMutableUndirectedGraph> ug = vtkSmartPointer<vtkMutableUndirectedGraph>::New();
108 dg->ToUndirectedGraph(ug);
109
110 // Check that the number of vertices and edges is unchanged
111 if (ug->GetNumberOfVertices() != dg->GetNumberOfVertices() ||
112 ug->GetNumberOfEdges() != dg->GetNumberOfEdges())
113 {
114 return EXIT_FAILURE;
115 }
116
117 return EXIT_SUCCESS;
118}

Callers 1

TestGraph2Function · 0.85

Calls 6

ToUndirectedGraphMethod · 0.80
GetNumberOfVerticesMethod · 0.80
NewFunction · 0.50
AddVertexMethod · 0.45
AddEdgeMethod · 0.45
GetNumberOfEdgesMethod · 0.45

Tested by

no test coverage detected