/
usr
/
include
/
boost
/
graph
/
/usr/include/boost/graph
mkdir
upload
Name
Size
Mode
Actions
detail/
-
0755
rm
distributed/
-
0755
rm
parallel/
-
0755
rm
planar_detail/
-
0755
rm
property_maps/
-
0755
rm
accounting.hpp
876
0644
edit
dl
rm
adjacency_iterator.hpp
2899
0644
edit
dl
rm
adjacency_list.hpp
13692
0644
edit
dl
rm
adjacency_list_io.hpp
11849
0644
edit
dl
rm
adjacency_matrix.hpp
45743
0644
edit
dl
rm
adj_list_serialize.hpp
4523
0644
edit
dl
rm
astar_search.hpp
26736
0644
edit
dl
rm
bandwidth.hpp
2992
0644
edit
dl
rm
bc_clustering.hpp
5937
0644
edit
dl
rm
bellman_ford_shortest_paths.hpp
8229
0644
edit
dl
rm
betweenness_centrality.hpp
26290
0644
edit
dl
rm
biconnected_components.hpp
16701
0644
edit
dl
rm
bipartite.hpp
13492
0644
edit
dl
rm
boyer_myrvold_planar_test.hpp
9849
0644
edit
dl
rm
boykov_kolmogorov_max_flow.hpp
47342
0644
edit
dl
rm
breadth_first_search.hpp
14751
0644
edit
dl
rm
bron_kerbosch_all_cliques.hpp
11736
0644
edit
dl
rm
buffer_concepts.hpp
2429
0644
edit
dl
rm
chrobak_payne_drawing.hpp
8641
0644
edit
dl
rm
circle_layout.hpp
1924
0644
edit
dl
rm
closeness_centrality.hpp
6057
0644
edit
dl
rm
clustering_coefficient.hpp
5726
0644
edit
dl
rm
compressed_sparse_row_graph.hpp
69887
0644
edit
dl
rm
connected_components.hpp
4134
0644
edit
dl
rm
copy.hpp
21225
0644
edit
dl
rm
core_numbers.hpp
13663
0644
edit
dl
rm
create_condensation_graph.hpp
3159
0644
edit
dl
rm
cuthill_mckee_ordering.hpp
5992
0644
edit
dl
rm
cycle_canceling.hpp
6645
0644
edit
dl
rm
dag_shortest_paths.hpp
6064
0644
edit
dl
rm
degree_centrality.hpp
4236
0644
edit
dl
rm
depth_first_search.hpp
15430
0644
edit
dl
rm
dijkstra_shortest_paths.hpp
23687
0644
edit
dl
rm
dijkstra_shortest_paths_no_color_map.hpp
9620
0644
edit
dl
rm
dimacs.hpp
10448
0644
edit
dl
rm
directed_graph.hpp
24214
0644
edit
dl
rm
dll_import_export.hpp
892
0644
edit
dl
rm
dominator_tree.hpp
17553
0644
edit
dl
rm
eccentricity.hpp
4611
0644
edit
dl
rm
edge_coloring.hpp
6809
0644
edit
dl
rm
edge_connectivity.hpp
6796
0644
edit
dl
rm
edge_list.hpp
9948
0644
edit
dl
rm
edmonds_karp_max_flow.hpp
10177
0644
edit
dl
rm
edmunds_karp_max_flow.hpp
982
0644
edit
dl
rm
erdos_renyi_generator.hpp
7257
0644
edit
dl
rm
exception.hpp
1466
0644
edit
dl
rm
exterior_property.hpp
4289
0644
edit
dl
rm
filtered_graph.hpp
20098
0644
edit
dl
rm
find_flow_cost.hpp
1859
0644
edit
dl
rm
floyd_warshall_shortest.hpp
8510
0644
edit
dl
rm
fruchterman_reingold.hpp
17325
0644
edit
dl
rm
geodesic_distance.hpp
8015
0644
edit
dl
rm
graphml.hpp
13460
0644
edit
dl
rm
graphviz.hpp
33503
0644
edit
dl
rm
graph_archetypes.hpp
11008
0644
edit
dl
rm
graph_as_tree.hpp
4532
0644
edit
dl
rm
graph_concepts.hpp
19785
0644
edit
dl
rm
graph_mutability_traits.hpp
4995
0644
edit
dl
rm
graph_selectors.hpp
1274
0644
edit
dl
rm
graph_stats.hpp
4394
0644
edit
dl
rm
graph_traits.hpp
13065
0644
edit
dl
rm
graph_utility.hpp
16182
0644
edit
dl
rm
grid_graph.hpp
33830
0644
edit
dl
rm
gursoy_atun_layout.hpp
13248
0644
edit
dl
rm
hawick_circuits.hpp
14593
0644
edit
dl
rm
howard_cycle_ratio.hpp
23107
0644
edit
dl
rm
incremental_components.hpp
8224
0644
edit
dl
rm
isomorphism.hpp
26308
0644
edit
dl
rm
is_kuratowski_subgraph.hpp
10260
0644
edit
dl
rm
is_straight_line_drawing.hpp
7230
0644
edit
dl
rm
iteration_macros.hpp
11659
0644
edit
dl
rm
iteration_macros_undef.hpp
673
0644
edit
dl
rm
johnson_all_pairs_shortest.hpp
7646
0644
edit
dl
rm
kamada_kawai_spring_layout.hpp
28048
0644
edit
dl
rm
king_ordering.hpp
12101
0644
edit
dl
rm
kruskal_min_spanning_tree.hpp
5743
0644
edit
dl
rm
labeled_graph.hpp
30914
0644
edit
dl
rm
leda_graph.hpp
28789
0644
edit
dl
rm
lookup_edge.hpp
1894
0644
edit
dl
rm
loop_erased_random_walk.hpp
4436
0644
edit
dl
rm
make_biconnected_planar.hpp
3513
0644
edit
dl
rm
make_connected.hpp
2645
0644
edit
dl
rm
make_maximal_planar.hpp
7578
0644
edit
dl
rm
matrix_as_graph.hpp
7227
0644
edit
dl
rm
maximum_adjacency_search.hpp
15125
0644
edit
dl
rm
maximum_weighted_matching.hpp
49722
0644
edit
dl
rm
max_cardinality_matching.hpp
31000
0644
edit
dl
rm
mcgregor_common_subgraphs.hpp
43470
0644
edit
dl
rm
mesh_graph_generator.hpp
5616
0644
edit
dl
rm
metis.hpp
10982
0644
edit
dl
rm
metric_tsp_approx.hpp
10809
0644
edit
dl
rm
minimum_degree_ordering.hpp
27087
0644
edit
dl
rm
named_function_params.hpp
39639
0644
edit
dl
rm
named_graph.hpp
20614
0644
edit
dl
rm
neighbor_bfs.hpp
11763
0644
edit
dl
rm
numeric_values.hpp
1814
0644
edit
dl
rm
one_bit_color_map.hpp
3277
0644
edit
dl
rm
overloading.hpp
1584
0644
edit
dl
rm
page_rank.hpp
6164
0644
edit
dl
rm
planar_canonical_ordering.hpp
7203
0644
edit
dl
rm
planar_face_traversal.hpp
6020
0644
edit
dl
rm
plod_generator.hpp
7708
0644
edit
dl
rm
point_traits.hpp
782
0644
edit
dl
rm
prim_minimum_spanning_tree.hpp
2960
0644
edit
dl
rm
profile.hpp
1327
0644
edit
dl
rm
properties.hpp
12417
0644
edit
dl
rm
property_iter_range.hpp
4345
0644
edit
dl
rm
push_relabel_max_flow.hpp
34737
0644
edit
dl
rm
random.hpp
9672
0644
edit
dl
rm
random_layout.hpp
988
0644
edit
dl
rm
random_spanning_tree.hpp
5775
0644
edit
dl
rm
read_dimacs.hpp
12080
0644
edit
dl
rm
relax.hpp
4400
0644
edit
dl
rm
reverse_graph.hpp
22402
0644
edit
dl
rm
rmat_graph_generator.hpp
19291
0644
edit
dl
rm
r_c_shortest_paths.hpp
30673
0644
edit
dl
rm
sequential_vertex_coloring.hpp
4562
0644
edit
dl
rm
simple_point.hpp
628
0644
edit
dl
rm
sloan_ordering.hpp
15540
0644
edit
dl
rm
smallest_last_ordering.hpp
5458
0644
edit
dl
rm
small_world_generator.hpp
3670
0644
edit
dl
rm
ssca_graph_generator.hpp
6564
0644
edit
dl
rm
stanford_graph.hpp
20126
0644
edit
dl
rm
stoer_wagner_min_cut.hpp
12415
0644
edit
dl
rm
strong_components.hpp
13009
0644
edit
dl
rm
st_connected.hpp
2852
0644
edit
dl
rm
subgraph.hpp
39996
0644
edit
dl
rm
successive_shortest_path_nonnegative_weights.hpp
10413
0644
edit
dl
rm
tiernan_all_cycles.hpp
12547
0644
edit
dl
rm
topological_sort.hpp
2611
0644
edit
dl
rm
topology.hpp
20389
0644
edit
dl
rm
transitive_closure.hpp
14260
0644
edit
dl
rm
transitive_reduction.hpp
5326
0644
edit
dl
rm
transpose_graph.hpp
1198
0644
edit
dl
rm
tree_traits.hpp
1338
0644
edit
dl
rm
two_bit_color_map.hpp
3510
0644
edit
dl
rm
two_graphs_common_spanning_trees.hpp
34996
0644
edit
dl
rm
undirected_dfs.hpp
10672
0644
edit
dl
rm
undirected_graph.hpp
25276
0644
edit
dl
rm
use_mpi.hpp
437
0644
edit
dl
rm
vector_as_graph.hpp
10474
0644
edit
dl
rm
vertex_and_edge_range.hpp
5528
0644
edit
dl
rm
vf2_sub_graph_iso.hpp
48585
0644
edit
dl
rm
visitors.hpp
11318
0644
edit
dl
rm
wavefront.hpp
3932
0644
edit
dl
rm
write_dimacs.hpp
2889
0644
edit
dl
rm
Edit:
/usr/include/boost/graph/howard_cycle_ratio.hpp
(23107B)
// Copyright (C) 2006-2009 Dmitry Bufistov and Andrey Parfenov // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_GRAPH_CYCLE_RATIO_HOWARD_HPP #define BOOST_GRAPH_CYCLE_RATIO_HOWARD_HPP #include <vector> #include <list> #include <algorithm> #include <functional> #include <limits> #include <boost/bind/bind.hpp> #include <boost/tuple/tuple.hpp> #include <boost/type_traits/is_same.hpp> #include <boost/type_traits/remove_const.hpp> #include <boost/concept_check.hpp> #include <boost/pending/queue.hpp> #include <boost/property_map/property_map.hpp> #include <boost/graph/graph_traits.hpp> #include <boost/graph/graph_concepts.hpp> #include <boost/concept/assert.hpp> /** @file howard_cycle_ratio.hpp * @brief The implementation of the maximum/minimum cycle ratio/mean algorithm. * @author Dmitry Bufistov * @author Andrey Parfenov */ namespace boost { /** * The mcr_float is like numeric_limits, but only for floating point types * and only defines infinity() and epsilon(). This class is primarily used * to encapsulate a less-precise epsilon than natively supported by the * floating point type. */ template < typename Float = double > struct mcr_float { typedef Float value_type; static Float infinity() { return std::numeric_limits< value_type >::infinity(); } static Float epsilon() { return Float(-0.005); } }; namespace detail { template < typename FloatTraits > struct min_comparator_props { typedef std::greater< typename FloatTraits::value_type > comparator; static const int multiplier = 1; }; template < typename FloatTraits > struct max_comparator_props { typedef std::less< typename FloatTraits::value_type > comparator; static const int multiplier = -1; }; template < typename FloatTraits, typename ComparatorProps > struct float_wrapper { typedef typename FloatTraits::value_type value_type; typedef ComparatorProps comparator_props_t; typedef typename ComparatorProps::comparator comparator; static value_type infinity() { return FloatTraits::infinity() * ComparatorProps::multiplier; } static value_type epsilon() { return FloatTraits::epsilon() * ComparatorProps::multiplier; } }; /*! @class mcr_howard * @brief Calculates optimum (maximum/minimum) cycle ratio of a directed * graph. Uses Howard's iteration policy algorithm. </br>(It is described * in the paper "Experimental Analysis of the Fastest Optimum Cycle Ratio * and Mean Algorithm" by Ali Dasdan). */ template < typename FloatTraits, typename Graph, typename VertexIndexMap, typename EdgeWeight1, typename EdgeWeight2 > class mcr_howard { public: typedef typename FloatTraits::value_type float_t; typedef typename FloatTraits::comparator_props_t cmp_props_t; typedef typename FloatTraits::comparator comparator_t; typedef enum { my_white = 0, my_black } my_color_type; typedef typename graph_traits< Graph >::vertex_descriptor vertex_t; typedef typename graph_traits< Graph >::edge_descriptor edge_t; typedef typename graph_traits< Graph >::vertices_size_type vn_t; typedef std::vector< float_t > vp_t; typedef typename boost::iterator_property_map< typename vp_t::iterator, VertexIndexMap > distance_map_t; // V -> float_t typedef typename std::vector< edge_t > ve_t; typedef std::vector< my_color_type > vcol_t; typedef typename ::boost::iterator_property_map< typename ve_t::iterator, VertexIndexMap > policy_t; // Vertex -> Edge typedef typename ::boost::iterator_property_map< typename vcol_t::iterator, VertexIndexMap > color_map_t; typedef typename std::list< vertex_t > pinel_t; // The in_edges list of the policy graph typedef typename std::vector< pinel_t > inedges1_t; typedef typename ::boost::iterator_property_map< typename inedges1_t::iterator, VertexIndexMap > inedges_t; typedef typename std::vector< edge_t > critical_cycle_t; // Bad vertex flag. If true, then the vertex is "bad". // Vertex is "bad" if its out_degree is equal to zero. typedef typename boost::iterator_property_map< std::vector< int >::iterator, VertexIndexMap > badv_t; /*! * Constructor * \param g = (V, E) - a directed multigraph. * \param vim Vertex Index Map. Read property Map: V -> [0, * num_vertices(g)). \param ewm edge weight map. Read property map: E * -> R \param ew2m edge weight map. Read property map: E -> R+ \param * infty A big enough value to guaranty that there exist a cycle with * better ratio. * \param cmp The compare operator for float_ts. */ mcr_howard(const Graph& g, VertexIndexMap vim, EdgeWeight1 ewm, EdgeWeight2 ew2m) : m_g(g) , m_vim(vim) , m_ew1m(ewm) , m_ew2m(ew2m) , m_bound(mcr_bound()) , m_cr(m_bound) , m_V(num_vertices(m_g)) , m_dis(m_V, 0) , m_dm(m_dis.begin(), m_vim) , m_policyc(m_V) , m_policy(m_policyc.begin(), m_vim) , m_inelc(m_V) , m_inel(m_inelc.begin(), m_vim) , m_badvc(m_V, false) , m_badv(m_badvc.begin(), m_vim) , m_colcv(m_V) , m_col_bfs(m_V) { } /*! * \return maximum/minimum_{for all cycles C} * [sum_{e in C} w1(e)] / [sum_{e in C} w2(e)], * or FloatTraits::infinity() if graph has no cycles. */ float_t ocr_howard() { construct_policy_graph(); int k = 0; float_t mcr = 0; do { mcr = policy_mcr(); ++k; } while ( try_improve_policy(mcr) && k < 100); // To avoid infinite loop const float_t eps_ = -0.00000001 * cmp_props_t::multiplier; if (m_cmp(mcr, m_bound + eps_)) { return FloatTraits::infinity(); } else { return mcr; } } virtual ~mcr_howard() {} protected: virtual void store_critical_edge(edge_t, critical_cycle_t&) {} virtual void store_critical_cycle(critical_cycle_t&) {} private: /*! * \return lower/upper bound for the maximal/minimal cycle ratio */ float_t mcr_bound() { typename graph_traits< Graph >::vertex_iterator vi, vie; typename graph_traits< Graph >::out_edge_iterator oei, oeie; float_t cz = (std::numeric_limits< float_t >::max)(); // Closest to // zero value float_t s = 0; const float_t eps_ = std::numeric_limits< float_t >::epsilon(); for (boost::tie(vi, vie) = vertices(m_g); vi != vie; ++vi) { for (boost::tie(oei, oeie) = out_edges(*vi, m_g); oei != oeie; ++oei) { s += std::abs(m_ew1m[*oei]); float_t a = std::abs(m_ew2m[*oei]); if (a > eps_ && a < cz) { cz = a; } } } return cmp_props_t::multiplier * (s / cz); } /*! * Constructs an arbitrary policy graph. */ void construct_policy_graph() { m_sink = graph_traits< Graph >().null_vertex(); typename graph_traits< Graph >::vertex_iterator vi, vie; typename graph_traits< Graph >::out_edge_iterator oei, oeie; for (boost::tie(vi, vie) = vertices(m_g); vi != vie; ++vi) { using namespace boost::placeholders; boost::tie(oei, oeie) = out_edges(*vi, m_g); typename graph_traits< Graph >::out_edge_iterator mei = std::max_element(oei, oeie, boost::bind(m_cmp, boost::bind(&EdgeWeight1::operator[], m_ew1m, _1), boost::bind(&EdgeWeight1::operator[], m_ew1m, _2))); if (mei == oeie) { if (m_sink == graph_traits< Graph >().null_vertex()) { m_sink = *vi; } m_badv[*vi] = true; m_inel[m_sink].push_back(*vi); } else { m_inel[target(*mei, m_g)].push_back(*vi); m_policy[*vi] = *mei; } } } /*! Sets the distance value for all vertices "v" such that there is * a path from "v" to "sv". It does "inverse" breadth first visit of the * policy graph, starting from the vertex "sv". */ void mcr_bfv(vertex_t sv, float_t cr, color_map_t c) { boost::queue< vertex_t > Q; c[sv] = my_black; Q.push(sv); while (!Q.empty()) { vertex_t v = Q.top(); Q.pop(); for (typename pinel_t::const_iterator itr = m_inel[v].begin(); itr != m_inel[v].end(); ++itr) // For all in_edges of the policy graph { if (*itr != sv) { if (m_badv[*itr]) { m_dm[*itr] = m_dm[v] + m_bound - cr; } else { m_dm[*itr] = m_dm[v] + m_ew1m[m_policy[*itr]] - m_ew2m[m_policy[*itr]] * cr; } c[*itr] = my_black; Q.push(*itr); } } } } /*! * \param sv an arbitrary (undiscovered) vertex of the policy graph. * \return a vertex in the policy graph that belongs to a cycle. * Performs a depth first visit until a cycle edge is found. */ vertex_t find_cycle_vertex(vertex_t sv) { vertex_t gv = sv; std::fill(m_colcv.begin(), m_colcv.end(), my_white); color_map_t cm(m_colcv.begin(), m_vim); do { cm[gv] = my_black; if (!m_badv[gv]) { gv = target(m_policy[gv], m_g); } else { gv = m_sink; } } while (cm[gv] != my_black); return gv; } /*! * \param sv - vertex that belongs to a cycle in the policy graph. */ float_t cycle_ratio(vertex_t sv) { if (sv == m_sink) return m_bound; std::pair< float_t, float_t > sums_(float_t(0), float_t(0)); vertex_t v = sv; critical_cycle_t cc; do { store_critical_edge(m_policy[v], cc); sums_.first += m_ew1m[m_policy[v]]; sums_.second += m_ew2m[m_policy[v]]; v = target(m_policy[v], m_g); } while (v != sv); float_t cr = sums_.first / sums_.second; if (m_cmp(m_cr, cr)) { m_cr = cr; store_critical_cycle(cc); } return cr; } /*! * Finds the optimal cycle ratio of the policy graph */ float_t policy_mcr() { using namespace boost::placeholders; std::fill(m_col_bfs.begin(), m_col_bfs.end(), my_white); color_map_t vcm_ = color_map_t(m_col_bfs.begin(), m_vim); typename graph_traits< Graph >::vertex_iterator uv_itr, vie; boost::tie(uv_itr, vie) = vertices(m_g); float_t mcr = m_bound; while ((uv_itr = std::find_if(uv_itr, vie, boost::bind(std::equal_to< my_color_type >(), my_white, boost::bind(&color_map_t::operator[], vcm_, _1)))) != vie) /// While there are undiscovered vertices { vertex_t gv = find_cycle_vertex(*uv_itr); float_t cr = cycle_ratio(gv); mcr_bfv(gv, cr, vcm_); if (m_cmp(mcr, cr)) mcr = cr; ++uv_itr; } return mcr; } /*! * Changes the edge m_policy[s] to the new_edge. */ void improve_policy(vertex_t s, edge_t new_edge) { vertex_t t = target(m_policy[s], m_g); typename property_traits< VertexIndexMap >::value_type ti = m_vim[t]; m_inelc[ti].erase( std::find(m_inelc[ti].begin(), m_inelc[ti].end(), s)); m_policy[s] = new_edge; t = target(new_edge, m_g); m_inel[t].push_back(s); /// Maintain in_edge list } /*! * A negative cycle detector. */ bool try_improve_policy(float_t cr) { bool improved = false; typename graph_traits< Graph >::vertex_iterator vi, vie; typename graph_traits< Graph >::out_edge_iterator oei, oeie; const float_t eps_ = FloatTraits::epsilon(); for (boost::tie(vi, vie) = vertices(m_g); vi != vie; ++vi) { if (!m_badv[*vi]) { for (boost::tie(oei, oeie) = out_edges(*vi, m_g); oei != oeie; ++oei) { vertex_t t = target(*oei, m_g); // Current distance from *vi to some vertex float_t dis_ = m_ew1m[*oei] - m_ew2m[*oei] * cr + m_dm[t]; if (m_cmp(m_dm[*vi] + eps_, dis_)) { improve_policy(*vi, *oei); m_dm[*vi] = dis_; improved = true; } } } else { float_t dis_ = m_bound - cr + m_dm[m_sink]; if (m_cmp(m_dm[*vi] + eps_, dis_)) { m_dm[*vi] = dis_; } } } return improved; } private: const Graph& m_g; VertexIndexMap m_vim; EdgeWeight1 m_ew1m; EdgeWeight2 m_ew2m; comparator_t m_cmp; float_t m_bound; //> The lower/upper bound to the maximal/minimal cycle // ratio float_t m_cr; //>The best cycle ratio that has been found so far vn_t m_V; //>The number of the vertices in the graph vp_t m_dis; //>Container for the distance map distance_map_t m_dm; //>Distance map ve_t m_policyc; //>Container for the policy graph policy_t m_policy; //>The interface for the policy graph inedges1_t m_inelc; //>Container fot in edges list inedges_t m_inel; //>Policy graph, input edges list std::vector< int > m_badvc; badv_t m_badv; // Marks "bad" vertices vcol_t m_colcv, m_col_bfs; // Color maps vertex_t m_sink; // To convert any graph to "good" }; /*! \class mcr_howard1 * \brief Finds optimum cycle raio and a critical cycle */ template < typename FloatTraits, typename Graph, typename VertexIndexMap, typename EdgeWeight1, typename EdgeWeight2 > class mcr_howard1 : public mcr_howard< FloatTraits, Graph, VertexIndexMap, EdgeWeight1, EdgeWeight2 > { public: typedef mcr_howard< FloatTraits, Graph, VertexIndexMap, EdgeWeight1, EdgeWeight2 > inhr_t; mcr_howard1(const Graph& g, VertexIndexMap vim, EdgeWeight1 ewm, EdgeWeight2 ew2m) : inhr_t(g, vim, ewm, ew2m) { } void get_critical_cycle(typename inhr_t::critical_cycle_t& cc) { return cc.swap(m_cc); } protected: void store_critical_edge( typename inhr_t::edge_t ed, typename inhr_t::critical_cycle_t& cc) { cc.push_back(ed); } void store_critical_cycle(typename inhr_t::critical_cycle_t& cc) { m_cc.swap(cc); } private: typename inhr_t::critical_cycle_t m_cc; // Critical cycle }; /*! * \param g a directed multigraph. * \param vim Vertex Index Map. A map V->[0, num_vertices(g)) * \param ewm Edge weight1 map. * \param ew2m Edge weight2 map. * \param pcc pointer to the critical edges list. * \return Optimum cycle ratio of g or FloatTraits::infinity() if g has no * cycles. */ template < typename FT, typename TG, typename TVIM, typename TEW1, typename TEW2, typename EV > typename FT::value_type optimum_cycle_ratio( const TG& g, TVIM vim, TEW1 ewm, TEW2 ew2m, EV* pcc) { typedef typename graph_traits< TG >::directed_category DirCat; BOOST_STATIC_ASSERT( (is_convertible< DirCat*, directed_tag* >::value == true)); BOOST_CONCEPT_ASSERT((IncidenceGraphConcept< TG >)); BOOST_CONCEPT_ASSERT((VertexListGraphConcept< TG >)); typedef typename graph_traits< TG >::vertex_descriptor Vertex; BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept< TVIM, Vertex >)); typedef typename graph_traits< TG >::edge_descriptor Edge; BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept< TEW1, Edge >)); BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept< TEW2, Edge >)); if (pcc == 0) { return detail::mcr_howard< FT, TG, TVIM, TEW1, TEW2 >( g, vim, ewm, ew2m) .ocr_howard(); } detail::mcr_howard1< FT, TG, TVIM, TEW1, TEW2 > obj(g, vim, ewm, ew2m); double ocr = obj.ocr_howard(); obj.get_critical_cycle(*pcc); return ocr; } } // namespace detail // Algorithms // Maximum Cycle Ratio template < typename FloatTraits, typename Graph, typename VertexIndexMap, typename EdgeWeight1Map, typename EdgeWeight2Map > inline typename FloatTraits::value_type maximum_cycle_ratio(const Graph& g, VertexIndexMap vim, EdgeWeight1Map ew1m, EdgeWeight2Map ew2m, std::vector< typename graph_traits< Graph >::edge_descriptor >* pcc = 0, FloatTraits = FloatTraits()) { typedef detail::float_wrapper< FloatTraits, detail::max_comparator_props< FloatTraits > > Traits; return detail::optimum_cycle_ratio< Traits >(g, vim, ew1m, ew2m, pcc); } template < typename Graph, typename VertexIndexMap, typename EdgeWeight1Map, typename EdgeWeight2Map > inline double maximum_cycle_ratio(const Graph& g, VertexIndexMap vim, EdgeWeight1Map ew1m, EdgeWeight2Map ew2m, std::vector< typename graph_traits< Graph >::edge_descriptor >* pcc = 0) { return maximum_cycle_ratio(g, vim, ew1m, ew2m, pcc, mcr_float<>()); } // Minimum Cycle Ratio template < typename FloatTraits, typename Graph, typename VertexIndexMap, typename EdgeWeight1Map, typename EdgeWeight2Map > typename FloatTraits::value_type minimum_cycle_ratio(const Graph& g, VertexIndexMap vim, EdgeWeight1Map ew1m, EdgeWeight2Map ew2m, std::vector< typename graph_traits< Graph >::edge_descriptor >* pcc = 0, FloatTraits = FloatTraits()) { typedef detail::float_wrapper< FloatTraits, detail::min_comparator_props< FloatTraits > > Traits; return detail::optimum_cycle_ratio< Traits >(g, vim, ew1m, ew2m, pcc); } template < typename Graph, typename VertexIndexMap, typename EdgeWeight1Map, typename EdgeWeight2Map > inline double minimum_cycle_ratio(const Graph& g, VertexIndexMap vim, EdgeWeight1Map ew1m, EdgeWeight2Map ew2m, std::vector< typename graph_traits< Graph >::edge_descriptor >* pcc = 0) { return minimum_cycle_ratio(g, vim, ew1m, ew2m, pcc, mcr_float<>()); } // Maximum Cycle Mean template < typename FloatTraits, typename Graph, typename VertexIndexMap, typename EdgeWeightMap, typename EdgeIndexMap > inline typename FloatTraits::value_type maximum_cycle_mean(const Graph& g, VertexIndexMap vim, EdgeWeightMap ewm, EdgeIndexMap eim, std::vector< typename graph_traits< Graph >::edge_descriptor >* pcc = 0, FloatTraits ft = FloatTraits()) { typedef typename remove_const< typename property_traits< EdgeWeightMap >::value_type >::type Weight; typename std::vector< Weight > ed_w2(boost::num_edges(g), 1); return maximum_cycle_ratio( g, vim, ewm, make_iterator_property_map(ed_w2.begin(), eim), pcc, ft); } template < typename Graph, typename VertexIndexMap, typename EdgeWeightMap, typename EdgeIndexMap > inline double maximum_cycle_mean(const Graph& g, VertexIndexMap vim, EdgeWeightMap ewm, EdgeIndexMap eim, std::vector< typename graph_traits< Graph >::edge_descriptor >* pcc = 0) { return maximum_cycle_mean(g, vim, ewm, eim, pcc, mcr_float<>()); } // Minimum Cycle Mean template < typename FloatTraits, typename Graph, typename VertexIndexMap, typename EdgeWeightMap, typename EdgeIndexMap > inline typename FloatTraits::value_type minimum_cycle_mean(const Graph& g, VertexIndexMap vim, EdgeWeightMap ewm, EdgeIndexMap eim, std::vector< typename graph_traits< Graph >::edge_descriptor >* pcc = 0, FloatTraits ft = FloatTraits()) { typedef typename remove_const< typename property_traits< EdgeWeightMap >::value_type >::type Weight; typename std::vector< Weight > ed_w2(boost::num_edges(g), 1); return minimum_cycle_ratio( g, vim, ewm, make_iterator_property_map(ed_w2.begin(), eim), pcc, ft); } template < typename Graph, typename VertexIndexMap, typename EdgeWeightMap, typename EdgeIndexMap > inline double minimum_cycle_mean(const Graph& g, VertexIndexMap vim, EdgeWeightMap ewm, EdgeIndexMap eim, std::vector< typename graph_traits< Graph >::edge_descriptor >* pcc = 0) { return minimum_cycle_mean(g, vim, ewm, eim, pcc, mcr_float<>()); } } // namespace boost #endif
Save
cmd:
run