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

Function TestGraph

Infovis/BoostGraphAlgorithms/Testing/Cxx/TestBoostAdapter.cxx:158–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156
157template <typename Graph>
158void TestGraph(Graph g, vtkIdType numVertices, vtkIdType numEdges, int repeat, int& errors)
159{
160 typedef typename graph_traits<Graph>::edge_descriptor Edge;
161 typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
162
163 VTK_CREATE(vtkTimerLog, timer);
164
165 std::vector<Vertex> graphVerts;
166 std::vector<Edge> graphEdges;
167 typename graph_traits<Graph>::vertex_iterator vi, viEnd;
168
169 // Create a graph
170 timer->StartTimer();
171 for (int i = 0; i < numVertices; ++i)
172 {
173 add_vertex(g);
174 }
175 timer->StopTimer();
176 std::cerr << "vertex insertion: " << timer->GetElapsedTime() / numVertices << " sec."
177 << std::endl;
178
179 if (static_cast<int>(num_vertices(g)) != numVertices)
180 {
181 std::cerr << "ERROR: Number of vertices (" << num_vertices(g) << ") not as expected ("
182 << numVertices << ")." << std::endl;
183 errors++;
184 }
185
186 for (boost::tie(vi, viEnd) = vertices(g); vi != viEnd; ++vi)
187 {
188 graphVerts.push_back(*vi);
189 }
190
191 timer->StartTimer();
192 for (int i = 0; i < numEdges; ++i)
193 {
194 int u = static_cast<int>(vtkMath::Random(0, numVertices));
195 int v = static_cast<int>(vtkMath::Random(0, numVertices));
196 add_edge(graphVerts[u], graphVerts[v], g);
197 }
198 timer->StopTimer();
199 std::cerr << "edge insertion: " << timer->GetElapsedTime() / numEdges << " sec." << std::endl;
200
201 if (static_cast<int>(num_edges(g)) != numEdges)
202 {
203 std::cerr << "ERROR: Number of edges (" << num_edges(g) << ") not as expected (" << numEdges
204 << ")." << std::endl;
205 errors++;
206 }
207
208 typename graph_traits<Graph>::edge_iterator ei, eiEnd;
209 for (boost::tie(ei, eiEnd) = edges(g); ei != eiEnd; ++ei)
210 {
211 graphEdges.push_back(*ei);
212 }
213
214 TestTraversal(g, repeat, errors);
215

Callers 1

TestBoostAdapterFunction · 0.70

Calls 12

add_vertexFunction · 0.85
num_verticesFunction · 0.85
verticesFunction · 0.85
num_edgesFunction · 0.85
edgesFunction · 0.85
TestTraversalFunction · 0.85
remove_edgeFunction · 0.85
add_edgeFunction · 0.50
StartTimerMethod · 0.45
StopTimerMethod · 0.45
GetElapsedTimeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected