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

Function make_random_chain_graph

dlib/test/graph_cuts.cpp:646–667  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

644
645 template <typename dgraph_type>
646 void make_random_chain_graph(
647 dlib::rand& rnd,
648 dgraph_type& g,
649 unsigned long& source,
650 unsigned long& sink
651 )
652 {
653 typedef typename dgraph_type::edge_type edge_weight_type;
654 g.clear();
655 const unsigned int num_nodes = rnd.get_random_32bit_number()%7 + 2;
656 g.set_number_of_nodes(num_nodes);
657
658 for (unsigned long i = 1; i < g.number_of_nodes(); ++i)
659 {
660 g.add_edge(i,i-1);
661 g.add_edge(i-1,i);
662 edge(g, i, i-1) = static_cast<edge_weight_type>(rnd.get_random_double()*50);
663 edge(g, i-1, i) = static_cast<edge_weight_type>(rnd.get_random_double()*50);
664 }
665
666 pick_random_source_and_sink(rnd, g, source, sink);
667 }
668
669// ----------------------------------------------------------------------------------------
670

Callers 1

test_graph_cutsFunction · 0.85

Calls 5

get_random_doubleMethod · 0.80
clearMethod · 0.45
number_of_nodesMethod · 0.45

Tested by

no test coverage detected