/usr/include/boost/graph
NameSizeModeActions
detail/-0755rm
distributed/-0755rm
parallel/-0755rm
planar_detail/-0755rm
property_maps/-0755rm
accounting.hpp8760644editdlrm
adjacency_iterator.hpp28990644editdlrm
adjacency_list.hpp136920644editdlrm
adjacency_list_io.hpp118490644editdlrm
adjacency_matrix.hpp457430644editdlrm
adj_list_serialize.hpp45230644editdlrm
astar_search.hpp267360644editdlrm
bandwidth.hpp29920644editdlrm
bc_clustering.hpp59370644editdlrm
bellman_ford_shortest_paths.hpp82290644editdlrm
betweenness_centrality.hpp262900644editdlrm
biconnected_components.hpp167010644editdlrm
bipartite.hpp134920644editdlrm
boyer_myrvold_planar_test.hpp98490644editdlrm
boykov_kolmogorov_max_flow.hpp473420644editdlrm
breadth_first_search.hpp147510644editdlrm
bron_kerbosch_all_cliques.hpp117360644editdlrm
buffer_concepts.hpp24290644editdlrm
chrobak_payne_drawing.hpp86410644editdlrm
circle_layout.hpp19240644editdlrm
closeness_centrality.hpp60570644editdlrm
clustering_coefficient.hpp57260644editdlrm
compressed_sparse_row_graph.hpp698870644editdlrm
connected_components.hpp41340644editdlrm
copy.hpp212250644editdlrm
core_numbers.hpp136630644editdlrm
create_condensation_graph.hpp31590644editdlrm
cuthill_mckee_ordering.hpp59920644editdlrm
cycle_canceling.hpp66450644editdlrm
dag_shortest_paths.hpp60640644editdlrm
degree_centrality.hpp42360644editdlrm
depth_first_search.hpp154300644editdlrm
dijkstra_shortest_paths.hpp236870644editdlrm
dijkstra_shortest_paths_no_color_map.hpp96200644editdlrm
dimacs.hpp104480644editdlrm
directed_graph.hpp242140644editdlrm
dll_import_export.hpp8920644editdlrm
dominator_tree.hpp175530644editdlrm
eccentricity.hpp46110644editdlrm
edge_coloring.hpp68090644editdlrm
edge_connectivity.hpp67960644editdlrm
edge_list.hpp99480644editdlrm
edmonds_karp_max_flow.hpp101770644editdlrm
edmunds_karp_max_flow.hpp9820644editdlrm
erdos_renyi_generator.hpp72570644editdlrm
exception.hpp14660644editdlrm
exterior_property.hpp42890644editdlrm
filtered_graph.hpp200980644editdlrm
find_flow_cost.hpp18590644editdlrm
floyd_warshall_shortest.hpp85100644editdlrm
fruchterman_reingold.hpp173250644editdlrm
geodesic_distance.hpp80150644editdlrm
graphml.hpp134600644editdlrm
graphviz.hpp335030644editdlrm
graph_archetypes.hpp110080644editdlrm
graph_as_tree.hpp45320644editdlrm
graph_concepts.hpp197850644editdlrm
graph_mutability_traits.hpp49950644editdlrm
graph_selectors.hpp12740644editdlrm
graph_stats.hpp43940644editdlrm
graph_traits.hpp130650644editdlrm
graph_utility.hpp161820644editdlrm
grid_graph.hpp338300644editdlrm
gursoy_atun_layout.hpp132480644editdlrm
hawick_circuits.hpp145930644editdlrm
howard_cycle_ratio.hpp231070644editdlrm
incremental_components.hpp82240644editdlrm
isomorphism.hpp263080644editdlrm
is_kuratowski_subgraph.hpp102600644editdlrm
is_straight_line_drawing.hpp72300644editdlrm
iteration_macros.hpp116590644editdlrm
iteration_macros_undef.hpp6730644editdlrm
johnson_all_pairs_shortest.hpp76460644editdlrm
kamada_kawai_spring_layout.hpp280480644editdlrm
king_ordering.hpp121010644editdlrm
kruskal_min_spanning_tree.hpp57430644editdlrm
labeled_graph.hpp309140644editdlrm
leda_graph.hpp287890644editdlrm
lookup_edge.hpp18940644editdlrm
loop_erased_random_walk.hpp44360644editdlrm
make_biconnected_planar.hpp35130644editdlrm
make_connected.hpp26450644editdlrm
make_maximal_planar.hpp75780644editdlrm
matrix_as_graph.hpp72270644editdlrm
maximum_adjacency_search.hpp151250644editdlrm
maximum_weighted_matching.hpp497220644editdlrm
max_cardinality_matching.hpp310000644editdlrm
mcgregor_common_subgraphs.hpp434700644editdlrm
mesh_graph_generator.hpp56160644editdlrm
metis.hpp109820644editdlrm
metric_tsp_approx.hpp108090644editdlrm
minimum_degree_ordering.hpp270870644editdlrm
named_function_params.hpp396390644editdlrm
named_graph.hpp206140644editdlrm
neighbor_bfs.hpp117630644editdlrm
numeric_values.hpp18140644editdlrm
one_bit_color_map.hpp32770644editdlrm
overloading.hpp15840644editdlrm
page_rank.hpp61640644editdlrm
planar_canonical_ordering.hpp72030644editdlrm
planar_face_traversal.hpp60200644editdlrm
plod_generator.hpp77080644editdlrm
point_traits.hpp7820644editdlrm
prim_minimum_spanning_tree.hpp29600644editdlrm
profile.hpp13270644editdlrm
properties.hpp124170644editdlrm
property_iter_range.hpp43450644editdlrm
push_relabel_max_flow.hpp347370644editdlrm
random.hpp96720644editdlrm
random_layout.hpp9880644editdlrm
random_spanning_tree.hpp57750644editdlrm
read_dimacs.hpp120800644editdlrm
relax.hpp44000644editdlrm
reverse_graph.hpp224020644editdlrm
rmat_graph_generator.hpp192910644editdlrm
r_c_shortest_paths.hpp306730644editdlrm
sequential_vertex_coloring.hpp45620644editdlrm
simple_point.hpp6280644editdlrm
sloan_ordering.hpp155400644editdlrm
smallest_last_ordering.hpp54580644editdlrm
small_world_generator.hpp36700644editdlrm
ssca_graph_generator.hpp65640644editdlrm
stanford_graph.hpp201260644editdlrm
stoer_wagner_min_cut.hpp124150644editdlrm
strong_components.hpp130090644editdlrm
st_connected.hpp28520644editdlrm
subgraph.hpp399960644editdlrm
successive_shortest_path_nonnegative_weights.hpp104130644editdlrm
tiernan_all_cycles.hpp125470644editdlrm
topological_sort.hpp26110644editdlrm
topology.hpp203890644editdlrm
transitive_closure.hpp142600644editdlrm
transitive_reduction.hpp53260644editdlrm
transpose_graph.hpp11980644editdlrm
tree_traits.hpp13380644editdlrm
two_bit_color_map.hpp35100644editdlrm
two_graphs_common_spanning_trees.hpp349960644editdlrm
undirected_dfs.hpp106720644editdlrm
undirected_graph.hpp252760644editdlrm
use_mpi.hpp4370644editdlrm
vector_as_graph.hpp104740644editdlrm
vertex_and_edge_range.hpp55280644editdlrm
vf2_sub_graph_iso.hpp485850644editdlrm
visitors.hpp113180644editdlrm
wavefront.hpp39320644editdlrm
write_dimacs.hpp28890644editdlrm
Edit: /usr/include/boost/graph/dominator_tree.hpp (17553B)
//======================================================================= // Copyright (C) 2005-2009 Jongsoo Park // // Distributed under 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_DOMINATOR_HPP #define BOOST_GRAPH_DOMINATOR_HPP #include #include #include #include #include // Dominator tree computation namespace boost { namespace detail { /** * An extended time_stamper which also records vertices for each dfs number */ template < class TimeMap, class VertexVector, class TimeT, class Tag > class time_stamper_with_vertex_vector : public base_visitor< time_stamper_with_vertex_vector< TimeMap, VertexVector, TimeT, Tag > > { public: typedef Tag event_filter; time_stamper_with_vertex_vector( TimeMap timeMap, VertexVector& v, TimeT& t) : timeStamper_(timeMap, t), v_(v) { } template < class Graph > void operator()(const typename property_traits< TimeMap >::key_type& v, const Graph& g) { timeStamper_(v, g); v_[timeStamper_.m_time] = v; } private: time_stamper< TimeMap, TimeT, Tag > timeStamper_; VertexVector& v_; }; /** * A convenient way to create a time_stamper_with_vertex_vector */ template < class TimeMap, class VertexVector, class TimeT, class Tag > time_stamper_with_vertex_vector< TimeMap, VertexVector, TimeT, Tag > stamp_times_with_vertex_vector( TimeMap timeMap, VertexVector& v, TimeT& t, Tag) { return time_stamper_with_vertex_vector< TimeMap, VertexVector, TimeT, Tag >(timeMap, v, t); } template < class Graph, class IndexMap, class TimeMap, class PredMap, class DomTreePredMap > class dominator_visitor { typedef typename graph_traits< Graph >::vertex_descriptor Vertex; typedef typename graph_traits< Graph >::vertices_size_type VerticesSizeType; public: /** * @param g [in] the target graph of the dominator tree * @param entry [in] the entry node of g * @param indexMap [in] the vertex index map for g * @param domTreePredMap [out] the immediate dominator map * (parent map in dominator tree) */ dominator_visitor(const Graph& g, const Vertex& entry, const IndexMap& indexMap, DomTreePredMap domTreePredMap) : semi_(num_vertices(g)) , ancestor_(num_vertices(g), graph_traits< Graph >::null_vertex()) , samedom_(ancestor_) , best_(semi_) , semiMap_(make_iterator_property_map(semi_.begin(), indexMap)) , ancestorMap_(make_iterator_property_map(ancestor_.begin(), indexMap)) , bestMap_(make_iterator_property_map(best_.begin(), indexMap)) , buckets_(num_vertices(g)) , bucketMap_(make_iterator_property_map(buckets_.begin(), indexMap)) , entry_(entry) , domTreePredMap_(domTreePredMap) , numOfVertices_(num_vertices(g)) , samedomMap(make_iterator_property_map(samedom_.begin(), indexMap)) { } void operator()(const Vertex& n, const TimeMap& dfnumMap, const PredMap& parentMap, const Graph& g) { if (n == entry_) return; const Vertex p(get(parentMap, n)); Vertex s(p); // 1. Calculate the semidominator of n, // based on the semidominator thm. // * Semidominator thm. : To find the semidominator of a node n, // consider all predecessors v of n in the CFG (Control Flow // Graph). // - If v is a proper ancestor of n in the spanning tree // (so dfnum(v) < dfnum(n)), then v is a candidate for semi(n) // - If v is a non-ancestor of n (so dfnum(v) > dfnum(n)) // then for each u that is an ancestor of v (or u = v), // Let semi(u) be a candidate for semi(n) // of all these candidates, the one with lowest dfnum is // the semidominator of n. // For each predecessor of n typename graph_traits< Graph >::in_edge_iterator inItr, inEnd; for (boost::tie(inItr, inEnd) = in_edges(n, g); inItr != inEnd; ++inItr) { const Vertex v = source(*inItr, g); // To deal with unreachable nodes if (get(dfnumMap, v) < 0 || get(dfnumMap, v) >= numOfVertices_) continue; Vertex s2; if (get(dfnumMap, v) <= get(dfnumMap, n)) s2 = v; else s2 = get(semiMap_, ancestor_with_lowest_semi_(v, dfnumMap)); if (get(dfnumMap, s2) < get(dfnumMap, s)) s = s2; } put(semiMap_, n, s); // 2. Calculation of n's dominator is deferred until // the path from s to n has been linked into the forest get(bucketMap_, s).push_back(n); get(ancestorMap_, n) = p; get(bestMap_, n) = n; // 3. Now that the path from p to v has been linked into // the spanning forest, these lines calculate the dominator of v, // based on the dominator thm., or else defer the calculation // until y's dominator is known // * Dominator thm. : On the spanning-tree path below semi(n) and // above or including n, let y be the node // with the smallest-numbered semidominator. Then, // // idom(n) = semi(n) if semi(y)=semi(n) or // idom(y) if semi(y) != semi(n) typename std::deque< Vertex >::iterator buckItr; for (buckItr = get(bucketMap_, p).begin(); buckItr != get(bucketMap_, p).end(); ++buckItr) { const Vertex v(*buckItr); const Vertex y(ancestor_with_lowest_semi_(v, dfnumMap)); if (get(semiMap_, y) == get(semiMap_, v)) put(domTreePredMap_, v, p); else put(samedomMap, v, y); } get(bucketMap_, p).clear(); } protected: /** * Evaluate function in Tarjan's path compression */ const Vertex ancestor_with_lowest_semi_( const Vertex& v, const TimeMap& dfnumMap) { const Vertex a(get(ancestorMap_, v)); if (get(ancestorMap_, a) != graph_traits< Graph >::null_vertex()) { const Vertex b(ancestor_with_lowest_semi_(a, dfnumMap)); put(ancestorMap_, v, get(ancestorMap_, a)); if (get(dfnumMap, get(semiMap_, b)) < get(dfnumMap, get(semiMap_, get(bestMap_, v)))) put(bestMap_, v, b); } return get(bestMap_, v); } std::vector< Vertex > semi_, ancestor_, samedom_, best_; PredMap semiMap_, ancestorMap_, bestMap_; std::vector< std::deque< Vertex > > buckets_; iterator_property_map< typename std::vector< std::deque< Vertex > >::iterator, IndexMap > bucketMap_; const Vertex& entry_; DomTreePredMap domTreePredMap_; const VerticesSizeType numOfVertices_; public: PredMap samedomMap; }; } // namespace detail /** * @brief Build dominator tree using Lengauer-Tarjan algorithm. * It takes O((V+E)log(V+E)) time. * * @pre dfnumMap, parentMap and verticesByDFNum have dfs results corresponding * indexMap. * If dfs has already run before, * this function would be good for saving computations. * @pre Unreachable nodes must be masked as * graph_traits::null_vertex in parentMap. * @pre Unreachable nodes must be masked as * (std::numeric_limits::max)() in dfnumMap. * * @param domTreePredMap [out] : immediate dominator map (parent map * in dom. tree) * * @note reference Appel. p. 452~453. algorithm 19.9, 19.10. * * @todo : Optimization in Finding Dominators in Practice, Loukas Georgiadis */ template < class Graph, class IndexMap, class TimeMap, class PredMap, class VertexVector, class DomTreePredMap > void lengauer_tarjan_dominator_tree_without_dfs(const Graph& g, const typename graph_traits< Graph >::vertex_descriptor& entry, const IndexMap& indexMap, TimeMap dfnumMap, PredMap parentMap, VertexVector& verticesByDFNum, DomTreePredMap domTreePredMap) { // Typedefs and concept check typedef typename graph_traits< Graph >::vertex_descriptor Vertex; typedef typename graph_traits< Graph >::vertices_size_type VerticesSizeType; BOOST_CONCEPT_ASSERT((BidirectionalGraphConcept< Graph >)); const VerticesSizeType numOfVertices = num_vertices(g); if (numOfVertices == 0) return; // 1. Visit each vertex in reverse post order and calculate sdom. detail::dominator_visitor< Graph, IndexMap, TimeMap, PredMap, DomTreePredMap > visitor(g, entry, indexMap, domTreePredMap); VerticesSizeType i; for (i = 0; i < numOfVertices; ++i) { const Vertex u(verticesByDFNum[numOfVertices - 1 - i]); if (u != graph_traits< Graph >::null_vertex()) visitor(u, dfnumMap, parentMap, g); } // 2. Now all the deferred dominator calculations, // based on the second clause of the dominator thm., are performed for (i = 0; i < numOfVertices; ++i) { const Vertex n(verticesByDFNum[i]); if (n == entry || n == graph_traits< Graph >::null_vertex()) continue; Vertex u = get(visitor.samedomMap, n); if (u != graph_traits< Graph >::null_vertex()) { put(domTreePredMap, n, get(domTreePredMap, u)); } } } /** * Unlike lengauer_tarjan_dominator_tree_without_dfs, * dfs is run in this function and * the result is written to dfnumMap, parentMap, vertices. * * If the result of dfs required after this algorithm, * this function can eliminate the need of rerunning dfs. */ template < class Graph, class IndexMap, class TimeMap, class PredMap, class VertexVector, class DomTreePredMap > void lengauer_tarjan_dominator_tree(const Graph& g, const typename graph_traits< Graph >::vertex_descriptor& entry, const IndexMap& indexMap, TimeMap dfnumMap, PredMap parentMap, VertexVector& verticesByDFNum, DomTreePredMap domTreePredMap) { // Typedefs and concept check typedef typename graph_traits< Graph >::vertices_size_type VerticesSizeType; BOOST_CONCEPT_ASSERT((BidirectionalGraphConcept< Graph >)); // 1. Depth first visit const VerticesSizeType numOfVertices = num_vertices(g); if (numOfVertices == 0) return; VerticesSizeType time = (std::numeric_limits< VerticesSizeType >::max)(); std::vector< default_color_type > colors( numOfVertices, color_traits< default_color_type >::white()); depth_first_visit(g, entry, make_dfs_visitor( make_pair(record_predecessors(parentMap, on_tree_edge()), detail::stamp_times_with_vertex_vector( dfnumMap, verticesByDFNum, time, on_discover_vertex()))), make_iterator_property_map(colors.begin(), indexMap)); // 2. Run main algorithm. lengauer_tarjan_dominator_tree_without_dfs(g, entry, indexMap, dfnumMap, parentMap, verticesByDFNum, domTreePredMap); } /** * Use vertex_index as IndexMap and make dfnumMap, parentMap, verticesByDFNum * internally. * If we don't need the result of dfs (dfnumMap, parentMap, verticesByDFNum), * this function would be more convenient one. */ template < class Graph, class DomTreePredMap > void lengauer_tarjan_dominator_tree(const Graph& g, const typename graph_traits< Graph >::vertex_descriptor& entry, DomTreePredMap domTreePredMap) { // typedefs typedef typename graph_traits< Graph >::vertex_descriptor Vertex; typedef typename graph_traits< Graph >::vertices_size_type VerticesSizeType; typedef typename property_map< Graph, vertex_index_t >::const_type IndexMap; typedef iterator_property_map< typename std::vector< VerticesSizeType >::iterator, IndexMap > TimeMap; typedef iterator_property_map< typename std::vector< Vertex >::iterator, IndexMap > PredMap; // Make property maps const VerticesSizeType numOfVertices = num_vertices(g); if (numOfVertices == 0) return; const IndexMap indexMap = get(vertex_index, g); std::vector< VerticesSizeType > dfnum(numOfVertices, 0); TimeMap dfnumMap(make_iterator_property_map(dfnum.begin(), indexMap)); std::vector< Vertex > parent( numOfVertices, graph_traits< Graph >::null_vertex()); PredMap parentMap(make_iterator_property_map(parent.begin(), indexMap)); std::vector< Vertex > verticesByDFNum(parent); // Run main algorithm lengauer_tarjan_dominator_tree(g, entry, indexMap, dfnumMap, parentMap, verticesByDFNum, domTreePredMap); } /** * Muchnick. p. 182, 184 * * using iterative bit vector analysis */ template < class Graph, class IndexMap, class DomTreePredMap > void iterative_bit_vector_dominator_tree(const Graph& g, const typename graph_traits< Graph >::vertex_descriptor& entry, const IndexMap& indexMap, DomTreePredMap domTreePredMap) { typedef typename graph_traits< Graph >::vertex_descriptor Vertex; typedef typename graph_traits< Graph >::vertex_iterator vertexItr; typedef typename graph_traits< Graph >::vertices_size_type VerticesSizeType; typedef iterator_property_map< typename std::vector< std::set< Vertex > >::iterator, IndexMap > vertexSetMap; BOOST_CONCEPT_ASSERT((BidirectionalGraphConcept< Graph >)); // 1. Finding dominator // 1.1. Initialize const VerticesSizeType numOfVertices = num_vertices(g); if (numOfVertices == 0) return; vertexItr vi, viend; boost::tie(vi, viend) = vertices(g); const std::set< Vertex > N(vi, viend); bool change = true; std::vector< std::set< Vertex > > dom(numOfVertices, N); vertexSetMap domMap(make_iterator_property_map(dom.begin(), indexMap)); get(domMap, entry).clear(); get(domMap, entry).insert(entry); while (change) { change = false; for (boost::tie(vi, viend) = vertices(g); vi != viend; ++vi) { if (*vi == entry) continue; std::set< Vertex > T(N); typename graph_traits< Graph >::in_edge_iterator inItr, inEnd; for (boost::tie(inItr, inEnd) = in_edges(*vi, g); inItr != inEnd; ++inItr) { const Vertex p = source(*inItr, g); std::set< Vertex > tempSet; std::set_intersection(T.begin(), T.end(), get(domMap, p).begin(), get(domMap, p).end(), std::inserter(tempSet, tempSet.begin())); T.swap(tempSet); } T.insert(*vi); if (T != get(domMap, *vi)) { change = true; get(domMap, *vi).swap(T); } } // end of for (boost::tie(vi, viend) = vertices(g) } // end of while(change) // 2. Build dominator tree for (boost::tie(vi, viend) = vertices(g); vi != viend; ++vi) get(domMap, *vi).erase(*vi); Graph domTree(numOfVertices); for (boost::tie(vi, viend) = vertices(g); vi != viend; ++vi) { if (*vi == entry) continue; // We have to iterate through copied dominator set const std::set< Vertex > tempSet(get(domMap, *vi)); typename std::set< Vertex >::const_iterator s; for (s = tempSet.begin(); s != tempSet.end(); ++s) { typename std::set< Vertex >::iterator t; for (t = get(domMap, *vi).begin(); t != get(domMap, *vi).end();) { typename std::set< Vertex >::iterator old_t = t; ++t; // Done early because t may become invalid if (*old_t == *s) continue; if (get(domMap, *s).find(*old_t) != get(domMap, *s).end()) get(domMap, *vi).erase(old_t); } } } for (boost::tie(vi, viend) = vertices(g); vi != viend; ++vi) { if (*vi != entry && get(domMap, *vi).size() == 1) { Vertex temp = *get(domMap, *vi).begin(); put(domTreePredMap, *vi, temp); } } } template < class Graph, class DomTreePredMap > void iterative_bit_vector_dominator_tree(const Graph& g, const typename graph_traits< Graph >::vertex_descriptor& entry, DomTreePredMap domTreePredMap) { typename property_map< Graph, vertex_index_t >::const_type indexMap = get(vertex_index, g); iterative_bit_vector_dominator_tree(g, entry, indexMap, domTreePredMap); } } // namespace boost #endif // BOOST_GRAPH_DOMINATOR_HPP