MCPcopy Create free account
hub / github.com/davisking/dlib / copy_graph_structure

Function copy_graph_structure

dlib/graph_utils/graph_utils.h:294–319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292 typename graph_type2
293 >
294 typename enable_if<is_graph<graph_type1> >::type copy_graph_structure (
295 const graph_type1& src,
296 graph_type2& dest
297 )
298 {
299 COMPILE_TIME_ASSERT(is_graph<graph_type1>::value);
300 COMPILE_TIME_ASSERT(is_graph<graph_type2>::value);
301 if (graph_helpers::is_same_object(src,dest))
302 return;
303
304 dest.clear();
305 dest.set_number_of_nodes(src.number_of_nodes());
306
307 // copy all the edges from src into dest
308 for (unsigned long i = 0; i < src.number_of_nodes(); ++i)
309 {
310 for (unsigned long j = 0; j < src.node(i).number_of_neighbors(); ++j)
311 {
312 const unsigned long nidx = src.node(i).neighbor(j).index();
313 if (nidx >= i)
314 {
315 dest.add_edge(i,nidx);
316 }
317 }
318 }
319 }
320
321 template <
322 typename graph_type1,

Callers 7

graph_testFunction · 0.85
copy_graphFunction · 0.85
create_moral_graphFunction · 0.85
create_join_treeFunction · 0.85
operator()Method · 0.85
separation_oracleMethod · 0.85

Calls 7

neighborMethod · 0.80
number_of_childrenMethod · 0.80
is_same_objectFunction · 0.70
clearMethod · 0.45
number_of_nodesMethod · 0.45
number_of_neighborsMethod · 0.45
indexMethod · 0.45

Tested by 1

graph_testFunction · 0.68