From 06f8e40a123c5988740972de7e5bebfd033945e7 Mon Sep 17 00:00:00 2001 From: Jeremiah Willcock Date: Sat, 3 Jul 2010 18:37:39 +0000 Subject: [PATCH] Merged r62693, r62932, r62933, r62998, r62999, r63000, r63002, r63048, r63049, r63084, r63189, r63190, r63227, r63234, r63241, r63244, r63268, r63269, r63329, r63332, r63333, r63334, r63335, r63405, r63466, r63472, r63511, r63530, r63535, r63536, r61796, and r61841 from trunk [SVN r63554] --- build/Jamfile.v2 | 1 - doc/astar_search.html | 30 +- doc/bibliography.html | 2 +- doc/boykov_kolmogorov_max_flow.html | 395 ++++++++ doc/edmonds_karp_max_flow.html | 6 +- doc/figs/bk_max_flow.gif | Bin 0 -> 10214 bytes doc/figs/warning.png | Bin 0 -> 1241 bytes doc/graph_concepts.html | 4 +- doc/graph_theory_review.html | 4 +- doc/grid_graph.html | 2 +- doc/history.html | 2 +- doc/kolmogorov_max_flow.html | 75 +- doc/push_relabel_max_flow.html | 2 +- doc/quick_tour.html | 2 +- doc/table_of_contents.html | 7 +- doc/write-graphviz.html | 18 +- example/Jamfile.v2 | 5 + example/accum-compile-times.cpp | 4 +- example/astar-cities.cpp | 4 +- example/bellman-example.cpp | 4 +- example/bfs-example2.cpp | 2 +- example/bfs-name-printer.cpp | 14 +- example/biconnected_components.cpp | 2 +- example/bipartite_example.cpp | 2 +- example/boost_web_graph.cpp | 14 +- ...ogorov-eg.cpp => boykov_kolmogorov-eg.cpp} | 19 +- example/cc-internet.cpp | 2 +- example/components_on_edgelist.cpp | 10 +- example/copy-example.cpp | 2 +- example/cycle-file-dep.cpp | 8 +- example/cycle-file-dep2.cpp | 8 +- example/cycle_ratio_example.cpp | 2 +- example/dag_shortest_paths.cpp | 2 +- example/dfs-parenthesis.cpp | 2 +- example/dijkstra-example-listS.cpp | 12 +- example/dijkstra-example.cpp | 6 +- example/dijkstra-no-color-map-example.cpp | 6 +- example/eccentricity.cpp | 4 +- example/edge-connectivity.cpp | 16 +- example/edge-function.cpp | 8 +- example/edge_property.cpp | 4 +- example/edmonds-karp-eg.cpp | 4 +- example/family-tree-eg.cpp | 4 +- example/file_dependencies.cpp | 6 +- example/filtered-copy-example.cpp | 2 +- example/filtered_graph_edge_range.cpp | 4 +- example/fr_layout.cpp | 2 +- example/gerdemann.cpp | 4 +- example/graph-property-iter-eg.cpp | 4 +- example/graphviz.cpp | 2 +- example/in_edges.cpp | 4 +- example/isomorphism.cpp | 4 +- example/johnson-eg.cpp | 2 +- example/kevin-bacon.cpp | 8 +- example/kevin-bacon2.cpp | 4 +- example/knights-tour.cpp | 20 +- example/kruskal-example.cpp | 4 +- example/kruskal-telephone.cpp | 2 +- example/leda-graph-eg.cpp | 2 +- example/loops_dfs.cpp | 8 +- example/max_flow.cpp | 4 +- example/min_max_paths.cpp | 6 +- example/modify_graph.cpp | 26 +- example/ordered_out_edges.cpp | 4 +- example/ospf-example.cpp | 92 +- example/parallel-compile-time.cpp | 22 +- example/prim-example.cpp | 2 +- example/prim-telephone.cpp | 2 +- example/print-adjacent-vertices.cpp | 4 +- example/print-edges.cpp | 2 +- example/print-in-edges.cpp | 4 +- example/print-out-edges.cpp | 4 +- example/push-relabel-eg.cpp | 4 +- example/quick-tour.cpp | 16 +- example/quick_tour.cpp | 10 +- example/reachable-loop-head.cpp | 6 +- example/reachable-loop-tail.cpp | 4 +- example/read_write_dimacs-eg.cpp | 4 +- example/remove_edge_if_bidir.cpp | 2 +- example/remove_edge_if_undir.cpp | 2 +- example/roget_components.cpp | 6 +- example/scc.cpp | 2 +- example/subgraph.cpp | 2 +- example/tiernan_girth_circumference.cpp | 2 +- example/topo-sort-file-dep.cpp | 8 +- example/topo-sort-file-dep2.cpp | 8 +- example/transpose-example.cpp | 4 +- example/undirected.cpp | 12 +- include/boost/graph/adj_list_serialize.hpp | 2 +- include/boost/graph/adjacency_matrix.hpp | 10 +- include/boost/graph/astar_search.hpp | 41 +- include/boost/graph/bandwidth.hpp | 6 +- .../graph/bellman_ford_shortest_paths.hpp | 6 +- .../boost/graph/betweenness_centrality.hpp | 10 +- include/boost/graph/bipartite.hpp | 2 +- .../graph/boykov_kolmogorov_max_flow.hpp | 866 ++++++++++++++++++ include/boost/graph/breadth_first_search.hpp | 4 +- .../boost/graph/bron_kerbosch_all_cliques.hpp | 2 +- .../boost/graph/clustering_coefficient.hpp | 8 +- .../graph/compressed_sparse_row_graph.hpp | 48 +- include/boost/graph/copy.hpp | 40 +- include/boost/graph/core_numbers.hpp | 18 +- .../boost/graph/create_condensation_graph.hpp | 6 +- .../boost/graph/cuthill_mckee_ordering.hpp | 2 +- include/boost/graph/dag_shortest_paths.hpp | 4 +- include/boost/graph/depth_first_search.hpp | 12 +- include/boost/graph/detail/adjacency_list.hpp | 32 +- .../detail/compressed_sparse_row_struct.hpp | 2 +- .../graph/detail/incremental_components.hpp | 2 +- .../boost/graph/detail/sparse_ordering.hpp | 2 +- .../boost/graph/dijkstra_shortest_paths.hpp | 2 +- include/boost/graph/directed_graph.hpp | 6 +- include/boost/graph/dominator_tree.hpp | 16 +- include/boost/graph/eccentricity.hpp | 6 +- include/boost/graph/edge_connectivity.hpp | 20 +- include/boost/graph/edmonds_karp_max_flow.hpp | 6 +- include/boost/graph/filtered_graph.hpp | 20 +- .../boost/graph/floyd_warshall_shortest.hpp | 18 +- include/boost/graph/fruchterman_reingold.hpp | 8 +- include/boost/graph/graph_stats.hpp | 2 +- include/boost/graph/graph_utility.hpp | 40 +- include/boost/graph/graphml.hpp | 4 +- include/boost/graph/graphviz.hpp | 81 +- include/boost/graph/grid_graph.hpp | 8 + include/boost/graph/howard_cycle_ratio.hpp | 14 +- .../boost/graph/incremental_components.hpp | 7 +- .../graph/johnson_all_pairs_shortest.hpp | 24 +- include/boost/graph/king_ordering.hpp | 4 +- include/boost/graph/kolmogorov_max_flow.hpp | 76 +- include/boost/graph/labeled_graph.hpp | 6 +- include/boost/graph/leda_graph.hpp | 8 +- .../boost/graph/loop_erased_random_walk.hpp | 110 +++ include/boost/graph/make_connected.hpp | 2 +- .../boost/graph/max_cardinality_matching.hpp | 30 +- .../boost/graph/mcgregor_common_subgraphs.hpp | 4 +- include/boost/graph/metric_tsp_approx.hpp | 2 +- .../boost/graph/minimum_degree_ordering.hpp | 16 +- include/boost/graph/neighbor_bfs.hpp | 6 +- include/boost/graph/page_rank.hpp | 2 +- .../planar_detail/boyer_myrvold_impl.hpp | 52 +- include/boost/graph/profile.hpp | 2 +- include/boost/graph/push_relabel_max_flow.hpp | 42 +- include/boost/graph/r_c_shortest_paths.hpp | 2 +- include/boost/graph/random.hpp | 47 +- include/boost/graph/random_spanning_tree.hpp | 103 +++ include/boost/graph/read_dimacs.hpp | 4 +- include/boost/graph/reverse_graph.hpp | 2 +- include/boost/graph/rmat_graph_generator.hpp | 10 +- .../graph/sequential_vertex_coloring.hpp | 4 +- include/boost/graph/sloan_ordering.hpp | 12 +- include/boost/graph/strong_components.hpp | 10 +- include/boost/graph/subgraph.hpp | 20 +- include/boost/graph/transitive_closure.hpp | 30 +- include/boost/graph/transitive_reduction.hpp | 2 +- include/boost/graph/tree_traits.hpp | 2 +- include/boost/graph/undirected_dfs.hpp | 12 +- include/boost/graph/undirected_graph.hpp | 6 +- include/boost/graph/wavefront.hpp | 10 +- src/graphml.cpp | 2 +- test/Jamfile.v2 | 5 +- test/astar_search_test.cpp | 4 +- test/betweenness_centrality_test.cpp | 18 +- test/biconnected_components_test.cpp | 4 +- test/bidir_remove_edge.cpp | 4 +- test/bidir_vec_remove_edge.cpp | 2 +- ...pp => boykov_kolmogorov_max_flow_test.cpp} | 196 ++-- test/cycle_ratio_tests.cpp | 2 +- test/dijkstra_heap_performance.cpp | 2 +- test/dijkstra_no_color_map_compare.cpp | 2 +- test/dominator_tree_test.cpp | 6 +- test/graphml_test.cpp | 4 +- test/index_graph.cpp | 2 +- test/layout_test.cpp | 18 +- test/matching_test.cpp | 16 +- test/max_flow_test.cpp | 10 +- test/metric_tsp_approx.cpp | 4 +- test/property_iter.cpp | 4 +- test/random_matching_test.cpp | 8 +- test/random_spanning_tree_test.cpp | 69 ++ test/subgraph.cpp | 2 +- test/subgraph_bundled.cpp | 2 +- test/transitive_closure_test.cpp | 10 +- 182 files changed, 2583 insertions(+), 924 deletions(-) create mode 100644 doc/boykov_kolmogorov_max_flow.html create mode 100644 doc/figs/bk_max_flow.gif create mode 100644 doc/figs/warning.png rename example/{kolmogorov-eg.cpp => boykov_kolmogorov-eg.cpp} (91%) create mode 100644 include/boost/graph/boykov_kolmogorov_max_flow.hpp create mode 100644 include/boost/graph/loop_erased_random_walk.hpp mode change 100755 => 100644 include/boost/graph/profile.hpp create mode 100644 include/boost/graph/random_spanning_tree.hpp rename test/{kolmogorov_max_flow_test.cpp => boykov_kolmogorov_max_flow_test.cpp} (74%) create mode 100644 test/random_spanning_tree_test.cpp diff --git a/build/Jamfile.v2 b/build/Jamfile.v2 index c05fdb31..19cb65f1 100644 --- a/build/Jamfile.v2 +++ b/build/Jamfile.v2 @@ -23,7 +23,6 @@ lib boost_graph msvc-7.1:-GR- : : - ../../regex/build//boost_regex ; boost-install boost_graph ; diff --git a/doc/astar_search.html b/doc/astar_search.html index dbde1080..e2e42c8d 100644 --- a/doc/astar_search.html +++ b/doc/astar_search.html @@ -28,7 +28,7 @@ template <typename VertexListGraph, typename P, typename T, typename R> void astar_search - (VertexListGraph &g, + (const VertexListGraph &g, typename graph_traits<VertexListGraph>::vertex_descriptor s, AStarHeuristic h, const bgl_named_params<P, T, R>& params); @@ -42,7 +42,7 @@ template <typename VertexListGraph, typename AStarHeuristic, typename CostInf, typename CostZero> inline void astar_search - (VertexListGraph &g, + (const VertexListGraph &g, typename graph_traits<VertexListGraph>::vertex_descriptor s, AStarHeuristic h, AStarVisitor vis, PredecessorMap predecessor, CostMap cost, @@ -52,7 +52,7 @@ astar_search CostInf inf, CostZero zero); // Version that does not initialize property maps (used for implicit graphs) -template <typename VertexListGraph, typename AStarHeuristic, +template <typename IncidenceGraph, typename AStarHeuristic, typename AStarVisitor, typename PredecessorMap, typename CostMap, typename DistanceMap, typename WeightMap, typename ColorMap, @@ -61,8 +61,8 @@ template <typename VertexListGraph, typename AStarHeuristic, typename CostInf, typename CostZero> inline void astar_search_no_init - (VertexListGraph &g, - typename graph_traits<VertexListGraph>::vertex_descriptor s, + (const IncidenceGraph &g, + typename graph_traits<IncidenceGraph>::vertex_descriptor s, AStarHeuristic h, AStarVisitor vis, PredecessorMap predecessor, CostMap cost, DistanceMap distance, WeightMap weight, @@ -117,7 +117,10 @@ implementation of A* by creating special visitors that generate neighbors of newly-expanded vertices. Please note that astar_search_no_init() must be used for implicit graphs; the basic astar_search() function requires a graph that models -VertexListGraph. +the Vertex List Graph concept. Both +versions +also require the graph type to model the Incidence Graph concept.

@@ -228,12 +231,21 @@ finish vertex u

Parameters

-IN: VertexListGraph& g +IN: const VertexListGraph& g
- The graph object on which the algorithm will be applied. The type + The graph object on which the algorithm will be applied for astar_search(). The type VertexListGraph must be a model of the - Vertex List Graph concept. + Vertex List Graph and Incidence Graph + concepts. +
+ +IN: const IncidenceGraph& g +
+ The graph object on which the algorithm will be applied for astar_search_no_init(). The type + IncidenceGraph must be a model of the + Incidence Graph + concept.
IN: vertex_descriptor s diff --git a/doc/bibliography.html b/doc/bibliography.html index fb3bbb25..ef8ef626 100644 --- a/doc/bibliography.html +++ b/doc/bibliography.html @@ -409,7 +409,7 @@ PhD thesis, Cornell University, September 2003.

69
Yuri Boykov and Vladimir Kolmogorov
An Experimental Comparison of Min-Cut/Max-Flow Algorithms for Energy Minimization in Vision
- In IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 26, no. 9, pp. 1124-1137, Sept. 2004. + In IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 26, no. 9, pp. 1124-1137, Sept. 2004.

70
John M. Boyer and Wendy J. Myrvold
diff --git a/doc/boykov_kolmogorov_max_flow.html b/doc/boykov_kolmogorov_max_flow.html new file mode 100644 index 00000000..1a5b0312 --- /dev/null +++ b/doc/boykov_kolmogorov_max_flow.html @@ -0,0 +1,395 @@ + + + + + Boost Graph Library: Boykov-Kolmogorov Maximum Flow + + + + + + + + +

C++ Boost +

+

boykov_kolmogorov_max_flow +

+
// named parameter version
+template <class Graph, class P, class T, class R>
+typename property_traits<typename property_map<Graph, edge_capacity_t>::const_type>::value_type
+boykov_kolmogorov_max_flow(Graph& g,
+   typename graph_traits<Graph>::vertex_descriptor src,
+   typename graph_traits<Graph>::vertex_descriptor sink,
+   const bgl_named_params<P, T, R>& params = all defaults)
+
+// non-named parameter version
+template <class Graph, class CapacityEdgeMap, class ResidualCapacityEdgeMap, class ReverseEdgeMap,
+          class PredecessorMap, class ColorMap, class DistanceMap, class IndexMap>
+typename property_traits<CapacityEdgeMap>::value_type
+boykov_kolmogorov_max_flow(Graph& g,
+       CapacityEdgeMap cap,
+       ResidualCapacityEdgeMap res_cap,
+       ReverseEdgeMap rev_map,
+       PredecessorMap pre_map,
+       ColorMap color,
+       DistanceMap dist,
+       IndexMap idx,
+       typename graph_traits <Graph>::vertex_descriptor src,
+       typename graph_traits <Graph >::vertex_descriptor sink)

+Additional overloaded versions for non-named parameters +are provided (without DistanceMap/ColorMap/DistanceMap; for those +iterator_property_maps with the provided index map are used)

+

The boykov_kolmogorov_max_flow() function calculates the maximum +flow of a network. See Section Network +Flow Algorithms for a description of maximum flow. The calculated +maximum flow will be the return value of the function. The function +also calculates the flow values f(u,v) for all (u,v) in +E, which are returned in the form of the residual capacity +r(u,v) = c(u,v) - f(u,v). +

+

Requirements:
The directed graph G=(V,E) that +represents the network must include a reverse edge for every edge in +E. That is, the input graph should be Gin = +(V,{E U ET}). The ReverseEdgeMap argument rev +must map each edge in the original graph to its reverse edge, that is +(u,v) -> (v,u) for all (u,v) in E. +

+ +

Remarks: While the push-relabel method states that each edge in ET +has to have capacity of 0, the reverse edges for this algorithm ARE +allowed to carry capacities. If there are already reverse edges in +the input Graph G, +those can be used. This can halve the amount of edges and will +noticeably increase the performance.

+ +

+Algorithm description:
The Boykov-Kolmogorov max-flow (or often +BK max-flow) algorithm is a variety of the augmenting-path algorithm. Standard +augmenting path algorithms find shortest paths from source to sink vertex and +augment them by substracting the bottleneck capacity found on that path from the +residual capacities of each edge and adding it to the total flow. Additionally +the minimum capacity is added to the residual capacity of the reverse edges. If +no more paths in the residual-edge tree are found, the algorithm terminates. +Instead of finding a new shortest path from source to sink in the graph in each +iteration, the Boykov-Kolmogorov algorithm keeps the already found paths as +follows:

+ +

The algorithm builds up two search trees, a source-tree and a +sink-tree. Each vertex has a label (stored in ColorMap) to +which tree it belongs and a status-flag if this vertex is active or +passive. In the beginning of the algorithm only the source and the +sink are colored (source==black, sink==white) and have active status. +All other vertices are colored gray. The algorithm consists of three +phases:

+

grow-phase: In this phase active vertices are allowed to +acquire neighbor vertices that are connected through an edge that has +a capacity-value greater than zero. Acquiring means that those vertices +become active and belong now to the search tree of the current +active vertex. If there are no more valid connections to neighbor +vertices, the current vertex becomes passive and the grow phase +continues with the next active vertex. The grow phase terminates if +there are no more active vertices left or a vertex discovers a vertex +from the other search tree through an unsaturated edge. In this case +a path from source to sink is found.

+

augment-phase: This phase augments the path that was found +in the grow phase. First it finds the bottleneck capacity of the +found path, and then it updates the residual-capacity of the edges +from this path by substracting the bottleneck capacity from the +residual capacity. Furthermore the residual capacity of the reverse +edges are updated by adding the bottleneck capacity. This phase can +destroy the built up search trees, as it creates at least one +saturated edge. That means, that the search trees collapse to +forests, because a condition for the search trees is, that each +vertex in them has a valid (=non-saturated) connection to a terminal.

+

adoption-phase: Here the search trees are reconstructed. A +simple solution would be to mark all vertices coming after the first +orphan in the found path free vertices (gray). A more sophisticated +solution is to give those orphans new parents: The neighbor vertices +are checked if they have a valid connection to the same terminal like +this vertex had (a path with unsaturated edges). If there is one, +this vertex becomes the new parent of the current orphan and this +forest is re-included into the search tree. If no new valid parent is +found, this vertex becomes a free vertex (marked gray), and it's +children become orphans. The adoption phase terminates if there are +no more orphans.

+


Details:

+
    +
  • Marking heuristics: A timestamp is stored for each vertex + which shows in which iteration of the algorithm the distance to the + corresponding terminal was calculated. +

    +
      +
    • This distance is used and gets calculated in the + adoption-phase. In order to find a valid new parent for an orphan, + the possible parent is checked for a connection to the terminal to + which tree it belongs. If there is such a connection, the path is + tagged with the current time-stamp, and the distance value. If + another orphan has to find a parent and it comes across a vertex + with a current timestamp, this information is used.

      +
    • The distance is also used in the grow-phase. If a vertex + comes across another vertex of the same tree while searching for + new vertices, the other's distance is compared to its distance. If + it is smaller, that other vertex becomes the new parent of the + current. This can decrease the length of the search paths, and so + amount of adoptions.

      +
    +
  • Ordering of orphans: As described above, the augment-phase + and the adoption phase can create orphans. The orphans the + augment-phase generates, are ordered according to their distance to + the terminals (smallest first). This combined with the + distance/timestamp heuristics results in the possibility for not + having to recheck terminal-connections too often. New orphans which + are generated in adoption phase are processed before orphans from + the main queue for the same reason.

    +
+


Implementation notes:

+

The algorithm is mainly implemented as described by Boykov and Kolmogorov in +[69]. An extended version +can be found in the PhD Thesis of Kolmogorov [68]. +The following changes are made to improve performance:

+
    +
  • initialization: the algorithm first augments all paths from + source->sink and all paths from source->VERTEX->sink. This + improves especially graph-cuts used in image vision where nearly + each vertex has a source and sink connect. During this step, all + vertices that have an unsaturated connection from source are added + to the active vertex list and so the source is not.
  • +
  • active vertices: Boykov-Kolmogorov uses two lists for active nodes + and states that new active vertices are added to the rear of the + second. Fetching an active vertex is done from the beginning of the + first list. If the first list is empty, it is exchanged by the + second. This implementation uses just one list.
  • +
  • grow-phase: In the grow phase the first vertex in the + active-list is taken and all outgoing edges are checked if they are + unsaturated. This decreases performance for graphs with high-edge + density. This implementation stores the last accessed edge and + continues with it, if the first vertex in the active-list is the + same one as during the last grow-phase.
  • +
+

Where Defined

+

boost/graph/boykov_kolmogorov_max_flow.hpp +

+

Parameters

+

IN: Graph& g +

+
A directed graph. The graph's type must be a model of +Vertex List Graph, Edge +List Graph and Incidence Graph. +For each edge (u,v) in the graph, the reverse edge (v,u) +must also be in the graph. Performance of the algorithm will be slightly +improved if the graph type also models Adjacency +Matrix. +
+

IN: vertex_descriptor src +

+
The source vertex for the flow network graph. +
+

IN: vertex_descriptor sink +

+
The sink vertex for the flow network graph. +
+

Named Parameters

+

IN: edge_capacity(EdgeCapacityMap cap) +

+
The edge capacity property map. The type must be a model +of a constant Lvalue +Property Map. The key type of the map must be the graph's edge +descriptor type.
Default: get(edge_capacity, g) +
+

OUT: edge_residual_capacity(ResidualCapacityEdgeMap res) +

+
The edge residual capacity property map. The type must be +a model of a mutable Lvalue +Property Map. The key type of the map must be the graph's edge +descriptor type.
Default: get(edge_residual_capacity, +g) +
+

IN: edge_reverse(ReverseEdgeMap rev) +

+
An edge property map that maps every edge (u,v) in +the graph to the reverse edge (v,u). The map must be a model +of constant Lvalue +Property Map. The key type of the map must be the graph's edge +descriptor type.
Default: get(edge_reverse, g) +
+

UTIL: vertex_predecessor(PredecessorMap pre_map) +

+
A vertex property map that stores the edge to the vertex' +predecessor. The map must be a model of mutable Lvalue +Property Map. The key type of the map must be the graph's vertex +descriptor type.
Default: get(vertex_predecessor, g) +
+

OUT/UTIL: vertex_color(ColorMap color) +

+
A vertex property map that stores a color for edge +vertex. If the color of a vertex after running the algorithm is black +the vertex belongs to the source tree else it belongs to the +sink-tree (used for minimum cuts). The map must be a model of mutable +Lvalue Property +Map. The key type of the map must be the graph's vertex +descriptor type.
Default: get(vertex_color, g) +
+

UTIL: vertex_distance(DistanceMap dist) +

+
A vertex property map that stores the distance to the +corresponding terminal. It's a utility-map for speeding up the +algorithm. The map must be a model of mutable Lvalue +Property Map. The key type of the map must be the graph's vertex +descriptor type.
Default: get(vertex_distance, g) +
+

IN: vertex_index(VertexIndexMap index_map) +

+
Maps each vertex of the graph to a unique integer in the +range [0, num_vertices(g)). The map must be a model of +constant LvaluePropertyMap. +The key type of the map must be the graph's vertex descriptor +type.
Default: get(vertex_index, g) +
+

Example

+

This reads an example maximum flow problem (a graph with edge +capacities) from a file in the DIMACS format (example/max_flow.dat). +The source for this example can be found in +example/boykov_kolmogorov-eg.cpp. +

+
#include <boost/config.hpp>
+#include <iostream>
+#include <string>
+#include <boost/graph/adjacency_list.hpp>
+#include <boost/graph/boykov_kolmogorov_max_flow.hpp>
+#include <boost/graph/read_dimacs.hpp>
+#include <boost/graph/graph_utility.hpp>
+
+int
+main()
+{
+  using namespace boost;
+
+  typedef adjacency_list_traits < vecS, vecS, directedS > Traits;
+  typedef adjacency_list < vecS, vecS, directedS,
+    property < vertex_name_t, std::string,
+    property < vertex_index_t, long,
+    property < vertex_color_t, boost::default_color_type,
+    property < vertex_distance_t, long,
+    property < vertex_predecessor_t, Traits::edge_descriptor > > > > >,
+
+    property < edge_capacity_t, long,
+    property < edge_residual_capacity_t, long,
+    property < edge_reverse_t, Traits::edge_descriptor > > > > Graph;
+
+  Graph g;
+  property_map < Graph, edge_capacity_t >::type
+      capacity = get(edge_capacity, g);
+  property_map < Graph, edge_residual_capacity_t >::type
+      residual_capacity = get(edge_residual_capacity, g);
+  property_map < Graph, edge_reverse_t >::type rev = get(edge_reverse, g);
+  Traits::vertex_descriptor s, t;
+  read_dimacs_max_flow(g, capacity, rev, s, t);
+
+  std::vector<default_color_type> color(num_vertices(g));
+  std::vector<long> distance(num_vertices(g));
+  long flow = boykov_kolmogorov_max_flow(g ,s, t);
+
+  std::cout << "c  The total flow:" << std::endl;
+  std::cout << "s " << flow << std::endl << std::endl;
+
+  std::cout << "c flow values:" << std::endl;
+  graph_traits < Graph >::vertex_iterator u_iter, u_end;
+  graph_traits < Graph >::out_edge_iterator ei, e_end;
+  for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter)
+    for (tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei)
+      if (capacity[*ei] > 0)
+        std::cout << "f " << *u_iter << " " << target(*ei, g) << " "
+          << (capacity[*ei] - residual_capacity[*ei]) << std::endl;
+
+  return EXIT_SUCCESS;
+}

+The output is: +

+
c  The total flow:
+s 13
+
+c flow values:
+f 0 6 3
+f 0 1 0
+f 0 2 10
+f 1 5 1
+f 1 0 0
+f 1 3 0
+f 2 4 4
+f 2 3 6
+f 2 0 0
+f 3 7 5
+f 3 2 0
+f 3 1 1
+f 4 5 4
+f 4 6 0
+f 5 4 0
+f 5 7 5
+f 6 7 3
+f 6 4 0
+f 7 6 0
+f 7 5 0

+See Also

+

+edmonds_karp_max_flow(), +push_relabel_max_flow(). +

+
+ + + + + +
+

Copyright © 2006

+
+

Stephan Diederich, University + Mannheim(diederich@ti.uni-manheim.de)

+
+



+

+ + diff --git a/doc/edmonds_karp_max_flow.html b/doc/edmonds_karp_max_flow.html index 4747c6c6..56875369 100644 --- a/doc/edmonds_karp_max_flow.html +++ b/doc/edmonds_karp_max_flow.html @@ -20,7 +20,7 @@
-// named paramter version
+// named parameter version
 template <class Graph, class P, class T, class R>
 typename detail::edge_capacity_value<Graph, P, T, R>::value_type
 edmonds_karp_max_flow(Graph& g, 
@@ -76,7 +76,7 @@ the maximum flow problem. However, there are several reasons why this
 algorithm is not as good as the push_relabel_max_flow()
 or the kolmogorov_max_flow()
+href="./boykov_kolmogorov_max_flow.html">boykov_kolmogorov_max_flow()
 algorithm.
 
 
    @@ -217,7 +217,7 @@ from a file in the DIMACS format and computes the maximum flow.

    See Also

    push_relabel_max_flow()
    -kolmogorov_max_flow(). +boykov_kolmogorov_max_flow().

    diff --git a/doc/figs/bk_max_flow.gif b/doc/figs/bk_max_flow.gif new file mode 100644 index 0000000000000000000000000000000000000000..93732cc74d99f01cd25bca12dc8c9c3d0e5e711b GIT binary patch literal 10214 zcmZ?wbhEHbv}QJE{Qi}Jfq{XMnTvyoiIatsiA9KoU5152j)PTzn?szJOJ0zJMTVV4 zo`YSIgG-!SR*G9(TvlFQUY>SKm(GKu_1u$VgA!Ku^b3SI59W z-@;VS*x1O*%z#6{nN!GHSj34(B85+`L`bGUR>ey|B~DO1NzANV-M~%F#9P5QP~R@p z*dow8K}p3iRL3FK#3@WUuFS+a+uWhp%Dd1mxY|XK(?gy=P=qs1iYG`+I9y)9Q&Yf6 zN7>WLAkfk{WxppiNqCG6IS1>-2E{8;Iqnu z&q{B;uetHA?*7MiEulV5p{ZKJYwe^addbfAkZpBUoD{D=G17WQtjVl2)1{8m>s@8H zg($5~)81BN))((OImKgcw$H4*z=fq@$1=6f))?$;j5yw9bE?noLW}X`Uh|vtY)-Vh z9G~HLa*F$zsks+tWZhcicxQ#VW z=lL(bt~q*p)4@xtZ-3Z$|I?1UAC|uQy5{w_O%FeBdh>1fv#+~ff4jeB!o#h-m+o}G zzuoxm>h$+l7k#+7;?u+Cj}N*(J(&0T@tSY1SATuF>-*cSKi+Ns@qW*>BL{AuJ#^yE z+e06Jp8fdq&daZtzx=xO?f275hrho*`t#$_U!TwZ`f}y>*Bh^Y{r&O!;h!Im{{DLN z@z1}1e?I;H|9|zGwV+gv11tVyVPs(V#-Ia|2jvL{j(-fVIb}RHEI8QAA*>a1V#C72 z?E=bPb38UKI@&E^oOS2K#>L0`6`Z?dJU1;lIawokRm{mvOHWTXNIo^kbMvyZvn`5W z-8s2=`T6+{&0MlxTUK0L>@is@_SBY@m#4jEIpZmDzR#iDVP4kVQ(IS`S`jQ5ws+Rm z)i*b1yzbO8QdYF)%6xq4>q)%>oMN`Ke2-X7e{gFX$Ng`zK07ofr-n3erd)45!m0e# z=Z5XUJg2<@c`Q|v1J}=7=^Z2sNWiXfSP|0~o!gm8)) z%(!aYKTq=QnXhK$^Cm@qxqSa%`*rO)8_PRSzcw6>w7uZzKDYFi>IwztDOUphtvUAy zpJ)6mutcUjTqLMp=-d%u25y}h4Tqal#E!*kCSFMHbJ*6Qc!B9D#}_|agHshz#phkk zV@t1RUVYFkc+Aj{RVMx~e9k3#WkuQ2$qA=I zuXCyiILStk~@t52|e6#U6RL3L`FP{6~oNU4=v(^u^@ zPMOh@^u4Q_>12^?{Z|EXf5vV}$$sXZ7m5L*^&BF8iZ?!K1DLJUxjgj@&v2sIRQ>W=a*GqS$RZAVV&y#UgZg9xhJFf_uf%_y|U!A+3S!k zm&0!RCF`W@&fU)3sGVo~WLEdOT>|bpACH)BjP6&LJRoqqKKMyzlm6F|nnTBzdp&x$ zPi8ByuiQD^6?V;ykCxsf~V{XUj6=TNz}aNx{BBClDfa&E)=&Ff4OIU?XSn{^F?f4 z9}ai14&M0KuKMFv;kAE0=e_2ue!usB-mWk5iT!)NNgCd_ymq1a-QR!*?dxs6#{{n5 z_qAg2{fWQb4&LAU{x)-h-Mdf!pZxjz@bdpDzZg>FZ~S2wVw!ZmLF#0D;Hl&G9~CF4 z|ISwUBG)0p5EaniwD`gARc<1@Y7?5zPJZy&CSx*3S3!$HNEd5($H93MCn)Rh@#HZy zIy`5_hn7vNAA09?IR9C?q4J;ho&@gfWru(2erQ+HRPwF3arnGupej$!qqia&Qxu{K zJB$}6d2ESrQt5lrX^^-`#FX7_vP)r)rOslXH7DG34)t_LhdlOtpkZd|6xfq-XO8US z8OJ%RKBnjJERv4j=6>~WVP|U(hirP$F*~KaiRD}7E7w+daIk&qYL1aq**yIOQ`o2O z`7TdXYIg|R^ab^M?o?4Tw%q9Fr8hK&PFO zQ}YCbm5$$0(7&8DSN7`Wer- zdgi8CY`EW~HJcURZ|Tt8FX>;=RXpePKkG-9D`%byx_Y_jth-?7*v}`T z_}S%!{qgMr6S*cWNvz8B4PE6u?^N(|hTNBKzEQ{fi@q$JqrAemwd3-nUnco>OIHTX zjucvXC}f3R?JA{>Rv~NIzE-3}XEDrv6|(A>;mQ@CS1GREWpZ8e>%^?m*U^C|Pi&KN zS(B`q-PvFjx@}RYLe1V)j&G~3?z~jm8MM|GTphjp z;gan=i*w((XvV}u3GKLYIye8{tEeZd#1^09jVWYxzw>Bb+2-Efb=Rjv&w5^Fs1|Ol zoiyDn_SLnmd*)qzleINFd{L2kUGZ+cvdZ64H;Xp!JlOo!_;PpL??qvI|EK2H{{0>I z>(iU;PqA+kCeM1XLFz{BuUNJE<<`Lr@u3GM7w0!dcA332wU~L&cXh?tjE7ghZQpfh zZ2_-gjU{is#IEea_u4C^l3LH)Sf6n8UFUi4M5g~!j=s44w!2oz>g~=Si{`~_>@V+n zd{QlJnK$2tQt6yzg~RVpIH#R_Rnz`-id*D{{eO$5mY+$!6;!$0Vcn*GGdBM@CGyLE zpK;vg)blkL)}69k6MRj*`{J2r?;C$kw`%-6mwWaj$Ll*cr-yx>_w&y45TOmHZF#>e zkj*)1Q-1NxIeA(wr#j_{Xy(2EnU|ZB+`u637RgxE$@{}%@oc+q+ zyy?YnDeEVv-^~)dJ>$}Yr(2r@SK0@EHah2~TB@@3_Om$Qos&-8TeYEG_RRv99sP^^ zzHPDWjd}cV*H!%|ueTrm^)y30^7bCPFPdlfCOrRFaXV+3^6qA?6ItOGZ}c76y6dxT zUf%t(x({`RD$jYdvR_YmuzAbp%?tn7Kd8ES^HR*}Y0Q1GOv-z%1n~XX>UtwTv%joa zBz&FFzt=ZET7EWb>Dc$Z&iP&8opVBuw#KY9i_H6EZ6&qESwO^M$N0cs~Klw;hdg}DWcS{58 zw!R5C{{7ryxrD9DC%(Pc_TtRpcWy!4GiMj<{}8!-Q~tk&wkJLO@7(SD{*{$k_EoxW za^F{;qFsw`zU4bp9rc^<`hIWY2^*)_{O;TNgF8F!BIDaVs}$F}pI$!qQc*BUXic|hJKfrraHA$~g=fJI>r#!@Vvf)( zk38wJ_6m*m>K$=+p0?L#v^Ab+|F_h&qxD2v`-;|ck2=~rQhIK5bVb-tykTD1(K_8D zZ{`ir2|GGPSvwYVbiBXbIX$9N$)anCM%l88uC*^xR%vvsk?6jx+_iCq!-|OT^*2Nl z97V$d`D+&XZL8@1G`V{}du07Xv9+H%c6a!0u}HVj5Gj4gq&`8sI#4W8Eho82{2Qa- zK@IV>3nfl6N>5Ofto$Um?V@B*fc!P_mKCfmDwn#GK6c;NXjAxNdiw_R$%0Khmx(Y_3X=I{QN4q=dxj8I7hI6RZx(z7Ak~ zpeXlbqnzplrk9SB-Zu7qER=q|LYm)I+-=c6J_SiRbpyGlg>vdA<+L8iO$(IPUfK8N zhKN0rqR=LdmL#3hNh%eK)NfpG`X14FEJNVo4=I%ZgH45fww&^x9!f5_*n6ZsQcjck z!9;a4&q-=4<=#w`)7m+8{=-RPg-V*6l)he2(ic+xYM^XdG~N8r1lCQ;97)9nngSY& zl$Z*+Crp}NkvaYShUu0`3O1KSYCoxmDycMYl4w;Dh`ywHAY;m1*CsKJey*SizZ^9= zD`#3L$HF+1zFmd8DJ0w%{azcNmR9T=}l^}2CCbh2@)bfKA zk8r9>B&mBHVyfJvUi@7+IY{jZ;~bR*YK2DXhhM6l_?M~TQKT+^X^!tjZDvNDC7wDn zoYa3U(phwArqqv_3uY?VKjL##(hw_}>G^W5`U57PMWPI9$?I;;cKI;-VCCF`Npp)Q z&GE_kvEgHRtqg;He9&rk(OB3!d;t0 z8I%RCIPozz>oOG@s0!<8OlH!$JTsu9CFzGsppok2lQaJ{PHCUCaCei~tfz_VUh01R zuz>NAu2R&(ZAls(PCCx31m74bz8BK}9HbvPOMlKL{RNxmIlC8zRxyNY34C+X|5~uj z_`uSWhx8Mqnq;rd6WF2fNK$ih(}ZW8Q(nGYcE+jZUu6P=!Lrm@%l<`rt@yra*{n-T zU)@~3tZ|9>WJ76Xf#3%c^1?>y6PQ#U>v9<{HuXxn^kRj?VndnYl~ZpS&UnRbxXa*) z(_;SMj>4=4?n#S0wG3F24em@@HRslfKdRbi1GV_$E`*5_z<7oMd zRnf1etev^N<*k*(Ve#yTU(FNTD*~I>w;0wcuUPljYW;)o+TB&PH#yuNtCxIj-f*R= zr1|iA!Ih>f!;|9#Ed)-_Q!cHUUb5lll?@wSY+!x5arbvm&fT+Cgl}4$o}&@Han+N5 zoxe*e7n-kI`65F~ZBv8DCZp_v72#Ek9W~D%W~=a)?kudw)$jA<@U|l&)XJ-I?AV)u&!ut z{JrC>@{aA(OFyLU)Y-j5`E^nK>mBhHI~yup=AGW5eciEic6H+I9ihMTbC#~%Ew;0+ z+F@h$&W%fpww|8Pw|w(X>Fuwza+_~gZIUk8(p}teq~O=BX!F;3QM(sbeBXU0I!8>r zwBxqRe2cwl|ElYDwQW1~+Vh)Q{RZjv7qb0y()V7Oo$;i4?}h1mj~~r(pS|_lmYU-~ za_&a&i44vB+P&rC(Zn~}ordfIe9_?<()%xT=S?cx^`d+K?cX)4w>fTL+un2gz$CT< zUsmT%D$DMhp2oW8z(S84zCQ=(<)ZY$lPwMM%pW=2{@MfHK%yZ1jVIn=QF@PV>w3D!eiHiwO3(oE*8 z^WfPWDpP(Tv`u05(Zp*#pYc|B4X%TsyU0-ve=FM?+S8rz< zx9XJRY-jTMk8QBXDNC4o!t>7I``1obNF8d|NvV8ua>bmJH>Pb-b<4K>Rz2V6c=7hs zEi$JXjuro{Je=iv%KOiePW8~KISlCb9|4?IZ5q<9-@{jdCpy$b9VXlGjHykeIj$7b4}+5o%8>y zj-=VdmE4JEI(GispYsfBcb?yKoa4-i`*#9=-%0+v<^p5wg~YCN=XiEr@Hu)m=j@f7 z%^l0Ta~EG&yZvHg&xNyZF05K}CZ*@}k!7cO%>JDf?`;s3z+)Loye8x1TbTJ!vhQK3Duo+_zKKe@?vZ zxxD5~X?pgV!!i4Eq_2AI-8x0)TKb=ZE-R{o{yH)*zoh)uF}8N^{x@5WPQRM*B`Cx9 zTHN$Q_Q#H`zHw;Rj$>i5S;>2oyS97g_d0t`zpSwKx=`+^!nX$xyxEsKr#C<5)WndR z%d$`WICJC6n;ZSS@r}9X=J6g)$hq14_2RDGnHp>MX~`7!y}3R~_SUl_L5(~i?YfRR z*RO0kbE~T-LYC*|zSskk-ySpB)95XByp*?mR_yuRvx6qiJ@)R#e!qV*cecdd3OySg zIOpb^y*KV2^IUZH&;i@q(?o72=G?vhH{j;lyFYjDd;Pa)qwLzA=scUhcjNDbKIpxd zzqE4I*?VWt?qBzMzmLw{+ z?mArfTcK-rjOp$!{dc?Xd+%iXexE&M55v4lkGeezT`$&ZKX!PRYvc3eyV-7cmp${- z{386e`^udSlYU~q;_`yGj}~!1JzVW=sFGLW>oxQDlQ=uyoYxQ4*7_I8JuYl1&9J-n zsdwkU)#_o~zn}8+6-DnpTCBbObhLe&v~T0o#}k)tZ&>%xDSAuN+j}+HTUyFrgx@}O zcgu_Idmq1d+Y-+G+=RDa?vt0B++V5v*qYvb;fPO2cj&f`+*kAOZIbG)^wz!}_Wk*e zdAodmHwC?RH{G4Kzt3sYz2I&4o-d(c0UrEMnKVP?a_uKMI>+Z36 zuVXoVe`)eFu5;Fc*4J;IyKleysuR!aiQ#XW&Q@Pz-(Y8FVPd!C)4eGtQ{TTkci;@~ zd&wQKIuY;KBG!qVd@oVG@!#H?55M+&ombBk{~_>a=%%CZR!PL~xz%`X+XuhUw|=tg zF6*6bcxBAr|7OptHN5Bl<<`zElUaY@PVy30ixlRxTa5mhq2iyOOuuv~rbV@Xx9hhx z-=Ej7QT=G=5xn-MiNpW4ZErp@RNOr@{qx>18x#3uRi<`_gTL(TTm0JPYoo?Qzt3M* zM>Z8{EWhjiRP+B@Qws;5^&2O%H%G~QOR@X5F7{hme1d81w+kHKbLL;nv%hoA?@NsQ z{dwi<{44J#&ilTp=24pe_o@HBe=dK}!1}I5-qTaAwl;oi|8xICeLp6&ex2bF7Q*sD z&-;Eq|JS7%bt)!5%k=Lp{6FVb`%mL{dxcGJt<=A<juJFjpA#>2XcT%Y4GrvU!^Sw>#^vRTmmD z1o|uN=KRW$RkcuY#=)jfdrk;S1U_=<64i}6!g2DDc&y-TmQ~+7c@8&ksKLS6B`xO`iZF0eDBWhTutlZG zc!GnZVb{jxf74RlxScIIve8{$ef7s>70VP3vT(0Xo*+9pt6E@#eC?Buo=nY8G`%!G zetvJEz5dCj(+gI7F*>tslSr_G!D^MwKBq1%>Gw6g-?I6D?&Br@HZQY$&GPBokvm5= zTfF%4#`wbTb0S*;oVc&P3Yf#-TB778SiL3C(>%B&$Vz+b6iuJpu8>Q9!cUEZ1E>Ek z3DGwje<|eL4fFD? zT{mN9M!7dw>UACGYiz46x|;4=Dz^Am1Sh|LYX4G>9feoll&vb+F6uQ!DQ$;`r{4M0 z@25&NSLMn|KAPCnB3xJDwjkImfRQcjmE?|uG!O2hy*FRIOzYxmzB(!Lk=EkvXR7Dl z+7UNzMnoG|0-KTG(JG%0Us>8@*B#gEP-XkJv&Z&d;j;=!9aWyHGlD0?3|am~Es$ya z#Z{GY>A+5h1%CHdu&d3?__hA_d8N&kXZohEnw2(h)5?YOLM{lL*jp7dX}ZdiscE-f z&YW{P>b2zUX)D6TeH4@)WGvC(*;*y_^I=~y%cI-*d)8?zkyD)`_@?C$Uv_cq(G|sO&m%A3;HYgW~|7$dvd|C?+ht?ah1mX z>|Lch`CeQQ+IvjUL%QPPdiTG#o)k6++CG@Pe(SqdagS9`HnZAq{u^9>^gN3a_pFpg z)#SE;{&P?As>V^*(wyG>lH1bP zPnemtee^G#vRLZn4%bB)+ToQf4EhY5Hg<7p{Y_^c%QIS@P`_o^^;=p+`K|jw*F}a| zs~@?lneO!Tdu5mvaY#kob)~0&*Q!a&-}o!aTDpebdfAilNqOlcb`O_Rf`REWsd}zI zPnkKgPT$3nru+KejUB;@E*VXWS<33zsu?F&T$IK0OwGG;Wq_OUjI(d}pLQjk%}Cnp zf0QL%N7ndE$|v>Mdw(WbD1JSYRTMny)s-7&cQbt}tcrcCW~$pxoVmQE{KGFWFctQD_bhqo37aO8-!y}zvT)h=}(a){K zS41__obi-K<+3lc8181cnObT0l}(x2+9LhRsViuD-=!t{o@DyRd##e-5?y3EcY)8; zs(=}{OdOUbsr#B|g~a}wQWRpFr4=d~vgX;Qm1l#pBJ{IDmum?dd6+)&Jbp7Yq3-LN zoU7?(7g@rm9t&QR7&<-rbk;vViJ(nWzZYx7)^=Sh<=VFH#NyBd-q)drK7C$Sadk@E zcdZL0zxbEGiP1@3xa7u}XHI5%|nty7Uj!91)_^KyTi-OwtZVg6`MQKfdwtbbu^gk|+a zwr{z_eJNo3?zd~TXLHBd?9l+P&vV z&-Zi+^-w|e70?R`{JZzUe&&h$F^?U-uo)=-)Yagum64Z6ViIK z{*d97`+Vs;j@qW=p1g2p(z>MC_hRo^{!4pcd2ZV_w$=vuL>79g{9+v!2oHr%L$T=l$DdE-QxXo)q*x(Y*W56wUc6=e}or zt~p$@*AvvqLy-zPh!*Stwte(9F#y>A`vf6ar#cg(we z_x`TuD?da|{JHllU(vq&X?+dbw@LGF{b)FQ_NU5opB}N_{~_*ew#V(f&O%51h`oLP z=B=ByZPT;B^FMF?x_dKx`;Hfh^Egrx`#${Dd3w6t?%(z2mcOF+i3e?R@817?wZ_fgoBmI> zpDldg*JN$!+x!0*8}?1M{WjT-jpe|!>H~~(c7Ba^;5xEaquGw7WclM@!|AUb-YzzN z{o4N0We4FiS^_f0{XqvsTMpQqwBc#7=T%vuqOGj3#j*deF0J`E>C9WV2_7 zb}1g&t~6&2%WWOSBmWku<=E=Ph_z2XG{bwX>Yszb*(+3PGzI5uKI-InrD~_%7pE;= z&f%91RZct@wMx+_MaQ^jjcLkZvnkdVn-8yIa(1ZRXD+hde$G0FJ6#U94}bTvkydo! zX?CeAH#l(V#u98n86}nkB(LkubnTZ*KG*Q9&#n)V-S*ykH|{1xe(-qATTgPrZC z|3`)HuM;{puWVnMIg5KK=M)Xj$tDZFOI%#OvVGCY_I(+$^Exm5Ou6tOgJ}~3>(rJD z(Eg?UumJK9OAX@n;HW+ zbx#SWURr2)-e51+f;Ank4h=8%%-*BP+Ze&lwzK!j3hoNU-XoDRoj)3i7c^yRFy}Bd zzhaPOtvYqfBUsphx9kP4=G5*>2OBLzuiX8>wo+v7Vb3``EqNFVCh5(UllaQ*x|Uu4 z#q9kPI~;XGm@O{e{lT_!&upd6-g^py3Zfkzs81Hs1Su6BQJxS`4@yJ1W3jmXIKtv8o8TwFbNY!#+|h}x1W|MlTQ<_otLigIlH%X06`ttx?ARUUyXUF@sAcC%UC zE;!I?B*DQY%eiLl?W&I3Up?nbuISxVx8>Dp3p7yrMf57CkiSxGJ*f`C4{eg+>t$#m*ZGgkLOp z*c-P}=l;1I_IIKkZ)_Er0v0`g%Hqh-{bcSLUxr4B7e1YW@q&kD|F>Nzvg+O)QI5{Q z#*b(3J+i&`z_zi8NW(e>JaphoO5CF?5GB9W| zFc>m0I59AIF)#!%FhnshWHT@nGcZ&$Ftji*^e`|?VPKe2T|Fl#Xiikroa*YO3=B&x zEth(EEp2I8I%UezrAyZ`FswB+TsvjTRtAQxnwndCdbZA)vvujxty{P5WnkF5cJ1D+ zTaPg?91{>YCLwX`*s*gA4Ce#{&Phm|)6~4iz;I1d^V+p*_ZS%N-Mjakf#JEL;`8Uv z-!m}0=iqq%{{43bhVS3M|7T$MKMF=efJz}yVEuRs0|NtNlDE4HLkFv@2Ll7c3r`ov zkcwNmlWOyu3izvS7ejxP>R-!INP5f(XN|IS^C^Iyp?`SUk1vQO?s(K&l| zi|Nkt0@~*ymDp65*E-HED6u(s{Mfrxmah{JrgAMTIq)Du?nC5nnYTRgThA|azEdIl zD^uvV>~q(b?>`Fd;xnAbe7so1I$-&keKN}|vNNOCvX<~g{)wp7{&hR__v^cBU*Gq* zV3YS!cBPWsl#eNWc|~nAXWMOB8tQWBuXo=4>}cytyX_5F^Az{bVJ>7~U~n#RjVKAu zPb(=;EJ|f?&`{R&%uP&B^-WCAOwLv?(KFJsP_VSrH?Yt*FjPn`$}BFabjYnNF3C*R zOD)z*DJ{s)E742N&z-nSaR&nfgBIAh%=Em(lG377hGY|?B=Z!b6jL*k#Ka_13kwTN zLrZf@a|7cv1EVApQ-8txlNlHo_&~Y>64O%|j7%zwOtcNO4T_>U4H+017(8A5T-G@y GGywozG)2h( literal 0 HcmV?d00001 diff --git a/doc/graph_concepts.html b/doc/graph_concepts.html index 85bba265..f52da899 100644 --- a/doc/graph_concepts.html +++ b/doc/graph_concepts.html @@ -30,7 +30,7 @@ to define a graph implicitly based on some functions.

    The BGL interface does not appear as a single graph concept. Instead -it is factored into much smaller peices. The reason for this is that +it is factored into much smaller pieces. The reason for this is that the purpose of a concept is to summarize the requirements for particular algorithms. Any one algorithm does not need every kind of graph operation, typically only a small subset. Furthermore, @@ -224,7 +224,7 @@ vertex degee. VertexListGraph refines - IncidenceGraph and AdjacencyGraph + Graph boost::graph_traits<G>::vertex_iterator diff --git a/doc/graph_theory_review.html b/doc/graph_theory_review.html index 81801e86..687315fb 100644 --- a/doc/graph_theory_review.html +++ b/doc/graph_theory_review.html @@ -356,8 +356,8 @@ Breadth-first search spreading through a graph.

-We start at vertex , and first visit r and w (the two -neighbors of ). Once both neighbors of are visited, we visit the +We start at vertex s, and first visit r and w (the two +neighbors of s). Once both neighbors of are visited, we visit the neighbor of r (vertex v), then the neighbors of w (the discovery order between r and w does not matter) which are t and x. Finally we visit the neighbors of diff --git a/doc/grid_graph.html b/doc/grid_graph.html index 2ca9b71d..484cea1f 100644 --- a/doc/grid_graph.html +++ b/doc/grid_graph.html @@ -74,7 +74,7 @@

Template Parameters

-template <typename std::size_t Dimensions,
+template <std::size_t Dimensions,
           typename VertexIndex = std::size_t,
           typename EdgeIndex = VertexIndex>
   class grid_graph;
diff --git a/doc/history.html b/doc/history.html
index d89b35df..fbf34a73 100644
--- a/doc/history.html
+++ b/doc/history.html
@@ -84,7 +84,7 @@ September 27, 2000.
 
   
  • Version 1.35.0
    New algorithms and components
      -
    • kolmogorov_max_flow, from Stephan Diederich as part of the 2006 Google Summer of Code.
    • +
    • boykov_kolmogorov_max_flow (formerly kolmogorov_max_flow), from Stephan Diederich as part of the 2006 Google Summer of Code.
    • read_dimacs_max_flow and write_dimacs_max_flow for max-flow problems, from Stephan Diederich.
    • read_graphml and write_graphml for GraphML input/output, from Tiago de Paula Peixoto.
    • minimum_cycle_ratio and maximum_cycle_ratio, from Dmitry Bufistov and Andrey Parfenov.
    • diff --git a/doc/kolmogorov_max_flow.html b/doc/kolmogorov_max_flow.html index 2cafd055..fad87452 100644 --- a/doc/kolmogorov_max_flow.html +++ b/doc/kolmogorov_max_flow.html @@ -2,7 +2,7 @@ - Boost Graph Library: Kolmogorov Maximum Flow + Boost Graph Library: Boykov-Kolmogorov Maximum Flow @@ -53,14 +53,31 @@ -

      C++ Boost + +

      +C++ Boost

      + + + + + + +
      + Warning! This header and its contents are deprecated and + will be removed in a future release. Please update your program to use + boykov_kolmogorov_max_flow + instead. Note that only the name of the algorithm has changed. The template + and function parameters will remain the same. +
      + +

      kolmogorov_max_flow

      // named parameter version
       template <class Graph, class P, class T, class R>
       typename property_traits<typename property_map<Graph, edge_capacity_t>::const_type>::value_type
      -kolmogorov_max_flow(Graph& g, 
      +kolmogorov_max_flow(Graph& g,
          typename graph_traits<Graph>::vertex_descriptor src,
          typename graph_traits<Graph>::vertex_descriptor sink,
          const bgl_named_params<P, T, R>& params = all defaults)
      @@ -88,14 +105,14 @@ Flow Algorithms for a description of maximum flow. The calculated
       maximum flow will be the return value of the function. The function
       also calculates the flow values f(u,v) for all (u,v) in
       E, which are returned in the form of the residual capacity
      -r(u,v) = c(u,v) - f(u,v). 
      +r(u,v) = c(u,v) - f(u,v).
       

      Requirements:
      The directed graph G=(V,E) that represents the network must include a reverse edge for every edge in E. That is, the input graph should be Gin = (V,{E U ET}). The ReverseEdgeMap argument rev must map each edge in the original graph to its reverse edge, that is -(u,v) -> (v,u) for all (u,v) in E. +(u,v) -> (v,u) for all (u,v) in E.

      Remarks: While the push-relabel method states that each edge in ET has to have capacity of 0, the reverse edges for this algorithm ARE @@ -155,7 +172,7 @@ no more orphans.

      • Marking heuristics: A timestamp is stored for each vertex which shows in which iteration of the algorithm the distance to the - corresponding terminal was calculated. + corresponding terminal was calculated.

        • This distance is used and gets calculated in the @@ -190,7 +207,7 @@ of Kolmogorov. Few changes were made for increasing performance:

          improves especially graph-cuts used in image vision where nearly each vertex has a source and sink connect. During this step, all vertices that have an unsaturated connection from source are added - to the active vertex list and so the source is not. + to the active vertex list and so the source is not.

        • active vertices: Kolmogorov uses two lists for active nodes and states that new active vertices are added to the rear of the @@ -210,7 +227,7 @@ of Kolmogorov. Few changes were made for increasing performance:

          boost/graph/kolmogorov_max_flow.hpp

          Parameters

          -

          IN: Graph& g +

          IN: Graph& g

          A directed graph. The graph's type must be a model of Vertex List Graph, Edge @@ -220,46 +237,46 @@ must also be in the graph. Performance of the algorithm will be slightly improved if the graph type also models Adjacency Matrix.
          -

          IN: vertex_descriptor src +

          IN: vertex_descriptor src

          -
          The source vertex for the flow network graph. +
          The source vertex for the flow network graph.
          -

          IN: vertex_descriptor sink +

          IN: vertex_descriptor sink

          -
          The sink vertex for the flow network graph. +
          The sink vertex for the flow network graph.

          Named Parameters

          -

          IN: edge_capacity(EdgeCapacityMap cap) +

          IN: edge_capacity(EdgeCapacityMap cap)

          The edge capacity property map. The type must be a model of a constant Lvalue Property Map. The key type of the map must be the graph's edge -descriptor type.
          Default: get(edge_capacity, g) +descriptor type.
          Default: get(edge_capacity, g)
          -

          OUT: edge_residual_capacity(ResidualCapacityEdgeMap res) +

          OUT: edge_residual_capacity(ResidualCapacityEdgeMap res)

          The edge residual capacity property map. The type must be a model of a mutable Lvalue Property Map. The key type of the map must be the graph's edge descriptor type.
          Default: get(edge_residual_capacity, -g) +g)
          -

          IN: edge_reverse(ReverseEdgeMap rev) +

          IN: edge_reverse(ReverseEdgeMap rev)

          An edge property map that maps every edge (u,v) in the graph to the reverse edge (v,u). The map must be a model of constant Lvalue Property Map. The key type of the map must be the graph's edge -descriptor type.
          Default: get(edge_reverse, g) +descriptor type.
          Default: get(edge_reverse, g)
          -

          UTIL: vertex_predecessor(PredecessorMap pre_map) +

          UTIL: vertex_predecessor(PredecessorMap pre_map)

          A vertex property map that stores the edge to the vertex' predecessor. The map must be a model of mutable Lvalue Property Map. The key type of the map must be the graph's vertex descriptor type.
          Default: get(vertex_predecessor, g)
          -

          OUT/UTIL: vertex_color(ColorMap color) +

          OUT/UTIL: vertex_color(ColorMap color)

          A vertex property map that stores a color for edge vertex. If the color of a vertex after running the algorithm is black @@ -267,29 +284,29 @@ the vertex belongs to the source tree else it belongs to the sink-tree (used for minimum cuts). The map must be a model of mutable Lvalue Property Map. The key type of the map must be the graph's vertex -descriptor type.
          Default: get(vertex_color, g) +descriptor type.
          Default: get(vertex_color, g)
          -

          UTIL: vertex_distance(DistanceMap dist) +

          UTIL: vertex_distance(DistanceMap dist)

          A vertex property map that stores the distance to the corresponding terminal. It's a utility-map for speeding up the algorithm. The map must be a model of mutable Lvalue Property Map. The key type of the map must be the graph's vertex -descriptor type.
          Default: get(vertex_distance, g) +descriptor type.
          Default: get(vertex_distance, g)
          -

          IN: vertex_index(VertexIndexMap index_map) +

          IN: vertex_index(VertexIndexMap index_map)

          Maps each vertex of the graph to a unique integer in the range [0, num_vertices(g)). The map must be a model of constant LvaluePropertyMap. The key type of the map must be the graph's vertex descriptor -type.
          Default: get(vertex_index, g) +type.
          Default: get(vertex_index, g)

          Example

          This reads an example maximum flow problem (a graph with edge capacities) from a file in the DIMACS format (example/max_flow.dat). The source for this example can be found in -example/kolmogorov-eg.cpp. +example/boykov_kolmogorov-eg.cpp.

          #include <boost/config.hpp>
           #include <iostream>
          @@ -311,11 +328,11 @@ main()
               property < vertex_color_t, boost::default_color_type,
               property < vertex_distance_t, long,
               property < vertex_predecessor_t, Traits::edge_descriptor > > > > >,
          -    
          +
               property < edge_capacity_t, long,
               property < edge_residual_capacity_t, long,
               property < edge_reverse_t, Traits::edge_descriptor > > > > Graph;
          - 
          +
             Graph g;
             property_map < Graph, edge_capacity_t >::type
                 capacity = get(edge_capacity, g);
          @@ -343,7 +360,7 @@ main()
           
             return EXIT_SUCCESS;
           }

          -The output is: +The output is:

          c  The total flow:
           s 13
          diff --git a/doc/push_relabel_max_flow.html b/doc/push_relabel_max_flow.html
          index 45dc6db8..4fcab20a 100644
          --- a/doc/push_relabel_max_flow.html
          +++ b/doc/push_relabel_max_flow.html
          @@ -226,7 +226,7 @@ f 6 7 1
           

          See Also

          edmonds_karp_max_flow()
          -kolmogorov_max_flow(). +boykov_kolmogorov_max_flow().

          diff --git a/doc/quick_tour.html b/doc/quick_tour.html index c95fae84..5ae9ffe9 100644 --- a/doc/quick_tour.html +++ b/doc/quick_tour.html @@ -445,7 +445,7 @@ of iterators (a pointer qualifies as a edmonds_karp_max_flow
        • push_relabel_max_flow -
        • kolmogorov_max_flow
        • +
        • + kolmogorov_max_flow (Deprecated. + Use boykov_kolmogorov_max_flow + instead.) +
        • +
        • boykov_kolmogorov_max_flow
        • edmonds_maximum_cardinality_matching diff --git a/doc/write-graphviz.html b/doc/write-graphviz.html index c441ac2f..5ae376c5 100644 --- a/doc/write-graphviz.html +++ b/doc/write-graphviz.html @@ -57,15 +57,15 @@ write_graphviz(std::ostream& out, const VertexAndEdgeListGraph& g, // Graph structure with dynamic property output template<typename Graph> void -write_graphviz(std::ostream& out, const Graph& g, - const dynamic_properties& dp, - const std::string& node_id = "node_id"); +write_graphviz_dp(std::ostream& out, const Graph& g, + const dynamic_properties& dp, + const std::string& node_id = "node_id"); template<typename Graph, typename VertexID> void -write_graphviz(std::ostream& out, const Graph& g, - const dynamic_properties& dp, const std::string& node_id, - VertexID vertex_id); +write_graphviz_dp(std::ostream& out, const Graph& g, + const dynamic_properties& dp, const std::string& node_id, + VertexID vertex_id);
        • @@ -92,7 +92,7 @@ version and fourth version require vertex PropertyWriter, respectively. -

          The final two overloads of write_graphviz will emit +

          The two overloads of write_graphviz_dp will emit all of the properties stored in the dynamic_properties object, thereby retaining the properties that have been read in @@ -329,10 +329,6 @@ href="../example/graphviz.cpp">example using read_graphviz -

          Notes

          -Note that you can use Graphviz dot file write facilities -without the library libbglviz.a. -

          diff --git a/example/Jamfile.v2 b/example/Jamfile.v2 index 5a0ad7e2..48dcc1ae 100644 --- a/example/Jamfile.v2 +++ b/example/Jamfile.v2 @@ -22,3 +22,8 @@ exe mcgregor_subgraphs_example : mcgregor_subgraphs_example.cpp ; exe grid_graph_example : grid_graph_example.cpp ; exe bipartite_example : bipartite_example.cpp ; exe fr_layout : fr_layout.cpp ; +exe canonical_ordering : canonical_ordering.cpp ; +exe components_on_edgelist : components_on_edgelist.cpp ; +exe boykov_kolmogorov-eg : boykov_kolmogorov-eg.cpp ; +exe ospf-example : ospf-example.cpp ../build//boost_graph ; +# exe cc-internet : cc-internet.cpp ../build//boost_graph ; diff --git a/example/accum-compile-times.cpp b/example/accum-compile-times.cpp index 0cc66b60..385d86c9 100644 --- a/example/accum-compile-times.cpp +++ b/example/accum-compile-times.cpp @@ -85,14 +85,14 @@ main() std::ifstream name_in("makefile-target-names.dat"); std::ifstream compile_cost_in("target-compile-costs.dat"); graph_traits < file_dep_graph2 >::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { name_in >> name_map[*vi]; compile_cost_in >> compile_cost_map[*vi]; } graph_property_iter_range < file_dep_graph2, vertex_compile_cost_t >::iterator ci, ci_end; - tie(ci, ci_end) = get_property_iter_range(g, vertex_compile_cost); + boost::tie(ci, ci_end) = get_property_iter_range(g, vertex_compile_cost); std::cout << "total (sequential) compile time: " << std::accumulate(ci, ci_end, 0.0) << std::endl; diff --git a/example/astar-cities.cpp b/example/astar-cities.cpp index a2a11544..d5affd11 100644 --- a/example/astar-cities.cpp +++ b/example/astar-cities.cpp @@ -164,8 +164,8 @@ int main(int argc, char **argv) WeightMap weightmap = get(edge_weight, g); for(std::size_t j = 0; j < num_edges; ++j) { edge_descriptor e; bool inserted; - tie(e, inserted) = add_edge(edge_array[j].first, - edge_array[j].second, g); + boost::tie(e, inserted) = add_edge(edge_array[j].first, + edge_array[j].second, g); weightmap[e] = weights[j]; } diff --git a/example/bellman-example.cpp b/example/bellman-example.cpp index 4e0b27d3..e6ec8750 100644 --- a/example/bellman-example.cpp +++ b/example/bellman-example.cpp @@ -74,7 +74,7 @@ main() property_map::type weight_pmap = get(&EdgeProperties::weight, g); int i = 0; - for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei, ++i) + for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei, ++i) weight_pmap[*ei] = weight[i]; std::vector distance(N, (std::numeric_limits < short >::max)()); @@ -108,7 +108,7 @@ main() << " edge[style=\"bold\"]\n" << " node[shape=\"circle\"]\n"; { - for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { + for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { graph_traits < Graph >::edge_descriptor e = *ei; graph_traits < Graph >::vertex_descriptor u = source(e, g), v = target(e, g); diff --git a/example/bfs-example2.cpp b/example/bfs-example2.cpp index ca8e8774..8225327e 100644 --- a/example/bfs-example2.cpp +++ b/example/bfs-example2.cpp @@ -78,7 +78,7 @@ main() std::vector < Size > dtime(num_vertices(g)); graph_traits::vertex_iterator vi, vi_end; std::size_t c = 0; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi, ++c) + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi, ++c) dtime[c] = dtime_map[*vi]; // Use std::sort to order the vertices by their discover time diff --git a/example/bfs-name-printer.cpp b/example/bfs-name-printer.cpp index eba6dc43..aab408d9 100644 --- a/example/bfs-name-printer.cpp +++ b/example/bfs-name-printer.cpp @@ -32,19 +32,19 @@ build_router_network(Graph & g, VertexNameMap name_map, typename graph_traits::edge_descriptor ed; bool inserted; - tie(ed, inserted) = add_edge(a, b, g); + boost::tie(ed, inserted) = add_edge(a, b, g); delay_map[ed] = 1.2; - tie(ed, inserted) = add_edge(a, d, g); + boost::tie(ed, inserted) = add_edge(a, d, g); delay_map[ed] = 4.5; - tie(ed, inserted) = add_edge(b, d, g); + boost::tie(ed, inserted) = add_edge(b, d, g); delay_map[ed] = 1.8; - tie(ed, inserted) = add_edge(c, a, g); + boost::tie(ed, inserted) = add_edge(c, a, g); delay_map[ed] = 2.6; - tie(ed, inserted) = add_edge(c, e, g); + boost::tie(ed, inserted) = add_edge(c, e, g); delay_map[ed] = 5.2; - tie(ed, inserted) = add_edge(d, c, g); + boost::tie(ed, inserted) = add_edge(d, c, g); delay_map[ed] = 0.4; - tie(ed, inserted) = add_edge(d, e, g); + boost::tie(ed, inserted) = add_edge(d, e, g); delay_map[ed] = 3.3; } diff --git a/example/biconnected_components.cpp b/example/biconnected_components.cpp index e05d32e3..0406dcba 100644 --- a/example/biconnected_components.cpp +++ b/example/biconnected_components.cpp @@ -63,7 +63,7 @@ main() } graph_traits < graph_t >::edge_iterator ei, ei_end; - for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) std::cout << (char)(source(*ei, g) + 'A') << " -- " << (char)(target(*ei, g) + 'A') << "[label=\"" << component[*ei] << "\"]\n"; diff --git a/example/bipartite_example.cpp b/example/bipartite_example.cpp index b1a912e8..05dd9cd8 100644 --- a/example/bipartite_example.cpp +++ b/example/bipartite_example.cpp @@ -41,7 +41,7 @@ void print_bipartite (const Graph& g) is_bipartite (g, get (vertex_index, g), partition_map); - for (tie (vertex_iter, vertex_end) = vertices (g); vertex_iter != vertex_end; ++vertex_iter) + for (boost::tie (vertex_iter, vertex_end) = vertices (g); vertex_iter != vertex_end; ++vertex_iter) { std::cout << "Vertex " << *vertex_iter << " has color " << (get (partition_map, *vertex_iter) == color_traits < default_color_type>::white () ? "white" : "black") << std::endl; diff --git a/example/boost_web_graph.cpp b/example/boost_web_graph.cpp index eec82184..53da8263 100644 --- a/example/boost_web_graph.cpp +++ b/example/boost_web_graph.cpp @@ -116,7 +116,7 @@ main() std::list::iterator i = line_toks.begin(); - tie(pos, inserted) = name2vertex.insert(std::make_pair(*i, Vertex())); + boost::tie(pos, inserted) = name2vertex.insert(std::make_pair(*i, Vertex())); if (inserted) { u = add_vertex(g); put(node_name, u, *i); @@ -127,7 +127,7 @@ main() std::string hyperlink_name = *i++; - tie(pos, inserted) = name2vertex.insert(std::make_pair(*i, Vertex())); + boost::tie(pos, inserted) = name2vertex.insert(std::make_pair(*i, Vertex())); if (inserted) { v = add_vertex(g); put(node_name, v, *i); @@ -136,7 +136,7 @@ main() v = pos->second; Edge e; - tie(e, inserted) = add_edge(u, v, g); + boost::tie(e, inserted) = add_edge(u, v, g); if (inserted) { put(link_name, e, hyperlink_name); } @@ -170,7 +170,7 @@ main() std::cout << "Number of clicks from the home page: " << std::endl; Traits::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) std::cout << d_matrix[0][*vi] << "\t" << node_name[*vi] << std::endl; std::cout << std::endl; @@ -179,7 +179,7 @@ main() // Create storage for a mapping from vertices to their parents std::vector parent(num_vertices(g)); - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) parent[*vi] = *vi; // Do a BFS starting at the home page, recording the parent of each @@ -192,7 +192,7 @@ main() // Add all the search tree edges into a new graph Graph search_tree(num_vertices(g)); - tie(vi, vi_end) = vertices(g); + boost::tie(vi, vi_end) = vertices(g); ++vi; for (; vi != vi_end; ++vi) add_edge(parent[*vi], *vi, search_tree); @@ -205,7 +205,7 @@ main() std::vector dfs_distances(num_vertices(g), 0); print_tree_visitor tree_printer(node_name, &dfs_distances[0]); - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) get(vertex_color, g)[*vi] = white_color; depth_first_visit(search_tree, src, tree_printer, get(vertex_color, g)); diff --git a/example/kolmogorov-eg.cpp b/example/boykov_kolmogorov-eg.cpp similarity index 91% rename from example/kolmogorov-eg.cpp rename to example/boykov_kolmogorov-eg.cpp index daf766be..dec3474f 100644 --- a/example/kolmogorov-eg.cpp +++ b/example/boykov_kolmogorov-eg.cpp @@ -32,18 +32,18 @@ #include #include #include -#include #include +#include #include #include // Use a DIMACS network flow file as stdin. -// kolmogorov-eg < max_flow.dat +// boykov_kolmogorov-eg < max_flow.dat // // Sample output: // c The total flow: // s 13 -// +// // c flow values: // f 0 6 3 // f 0 1 6 @@ -66,8 +66,7 @@ // f 7 6 0 // f 7 5 0 -int -main() +int main() { using namespace boost; @@ -78,11 +77,11 @@ main() property < vertex_color_t, boost::default_color_type, property < vertex_distance_t, long, property < vertex_predecessor_t, Traits::edge_descriptor > > > > >, - + property < edge_capacity_t, long, property < edge_residual_capacity_t, long, property < edge_reverse_t, Traits::edge_descriptor > > > > Graph; - + Graph g; property_map < Graph, edge_capacity_t >::type capacity = get(edge_capacity, g); @@ -94,7 +93,7 @@ main() std::vector color(num_vertices(g)); std::vector distance(num_vertices(g)); - long flow = kolmogorov_max_flow(g ,s, t); + long flow = boykov_kolmogorov_max_flow(g ,s, t); std::cout << "c The total flow:" << std::endl; std::cout << "s " << flow << std::endl << std::endl; @@ -102,8 +101,8 @@ main() std::cout << "c flow values:" << std::endl; graph_traits < Graph >::vertex_iterator u_iter, u_end; graph_traits < Graph >::out_edge_iterator ei, e_end; - for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) - for (tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) + for (boost::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) + for (boost::tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) if (capacity[*ei] > 0) std::cout << "f " << *u_iter << " " << target(*ei, g) << " " << (capacity[*ei] - residual_capacity[*ei]) << std::endl; diff --git a/example/cc-internet.cpp b/example/cc-internet.cpp index dbd29f0e..0f2d930b 100644 --- a/example/cc-internet.cpp +++ b/example/cc-internet.cpp @@ -30,7 +30,7 @@ main() std::string color[] = { "white", "gray", "black", "lightgray"}; graph_traits < GraphvizGraph >::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { vertex_attr_map[*vi]["color"] = color[component[*vi]]; vertex_attr_map[*vi]["style"] = "filled"; if (vertex_attr_map[*vi]["color"] == "black") diff --git a/example/components_on_edgelist.cpp b/example/components_on_edgelist.cpp index 1d76fc0e..685f86eb 100644 --- a/example/components_on_edgelist.cpp +++ b/example/components_on_edgelist.cpp @@ -68,7 +68,7 @@ int main(int , char* []) print_edges(g, identity_property_map()); cout << endl; - disjoint_sets_with_storage<> ds; + disjoint_sets_with_storage<> ds(N); incremental_components(g, ds); component_index components(&ds.parents()[0], @@ -80,11 +80,11 @@ int main(int , char* []) << ds.find_set(k) << endl; cout << endl; - for (component_index::size_type i = 0; i < components.size(); ++i) { + for (std::size_t i = 0; i < components.size(); ++i) { cout << "component " << i << " contains: "; - component_index::value_type::iterator - j = components[i].begin(), - jend = components[i].end(); + component_index::component_iterator + j = components[i].first, + jend = components[i].second; for ( ; j != jend; ++j) cout << *j << " "; cout << endl; diff --git a/example/copy-example.cpp b/example/copy-example.cpp index b2af240e..41a0178a 100644 --- a/example/copy-example.cpp +++ b/example/copy-example.cpp @@ -26,7 +26,7 @@ main() name_map = get(vertex_name, G); char name = 'a'; graph_traits < graph_t >::vertex_iterator v, v_end; - for (tie(v, v_end) = vertices(G); v != v_end; ++v, ++name) + for (boost::tie(v, v_end) = vertices(G); v != v_end; ++v, ++name) name_map[*v] = name; typedef std::pair < int, int >E; diff --git a/example/cycle-file-dep.cpp b/example/cycle-file-dep.cpp index 23a33b1f..b7b22fac 100644 --- a/example/cycle-file-dep.cpp +++ b/example/cycle-file-dep.cpp @@ -38,7 +38,7 @@ has_cycle_dfs(const file_dep_graph & g, vertex_t u, { color[u] = gray_color; graph_traits < file_dep_graph >::adjacency_iterator vi, vi_end; - for (tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi) if (color[*vi] == white_color) { if (has_cycle_dfs(g, *vi, color)) return true; // cycle detected, return immediately @@ -53,7 +53,7 @@ has_cycle(const file_dep_graph & g) { std::vector < default_color_type > color(num_vertices(g), white_color); graph_traits < file_dep_graph >::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) if (color[*vi] == white_color) if (has_cycle_dfs(g, *vi, &color[0])) return true; @@ -75,7 +75,7 @@ main() file_dep_graph g(n_vertices); while (input_begin != input_end) { size_type i, j; - tie(i, j) = *input_begin++; + boost::tie(i, j) = *input_begin++; add_edge(i, j, g); } #else @@ -85,7 +85,7 @@ main() std::vector < std::string > name(num_vertices(g)); std::ifstream name_in("makefile-target-names.dat"); graph_traits < file_dep_graph >::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) name_in >> name[*vi]; assert(has_cycle(g) == false); diff --git a/example/cycle-file-dep2.cpp b/example/cycle-file-dep2.cpp index 4f55da15..0b04ff41 100644 --- a/example/cycle-file-dep2.cpp +++ b/example/cycle-file-dep2.cpp @@ -42,7 +42,7 @@ dfs_v1(const file_dep_graph & g, vertex_t u, default_color_type * color, color[u] = gray_color; vis.discover_vertex(u, g); graph_traits < file_dep_graph >::out_edge_iterator ei, ei_end; - for (tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) { + for (boost::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) { if (color[target(*ei, g)] == white_color) { vis.tree_edge(*ei, g); dfs_v1(g, target(*ei, g), color, vis); @@ -60,7 +60,7 @@ generic_dfs_v1(const file_dep_graph & g, Visitor vis) { std::vector < default_color_type > color(num_vertices(g), white_color); graph_traits < file_dep_graph >::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { if (color[*vi] == white_color) dfs_v1(g, *vi, &color[0], vis); } @@ -132,7 +132,7 @@ main() file_dep_graph g(n_vertices); while (input_begin != input_end) { size_type i, j; - tie(i, j) = *input_begin++; + boost::tie(i, j) = *input_begin++; add_edge(i, j, g); } #else @@ -142,7 +142,7 @@ main() std::vector < std::string > name(num_vertices(g)); std::ifstream name_in("makefile-target-names.dat"); graph_traits < file_dep_graph >::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) name_in >> name[*vi]; assert(has_cycle(g) == false); diff --git a/example/cycle_ratio_example.cpp b/example/cycle_ratio_example.cpp index 68846456..b65fdead 100644 --- a/example/cycle_ratio_example.cpp +++ b/example/cycle_ratio_example.cpp @@ -60,7 +60,7 @@ int main(int argc, char* argv[]) cout << "Edges number: " << num_edges(tgr) << endl; int i = 0; graph_traits::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(tgr); vi != vi_end; vi++) { + for (boost::tie(vi, vi_end) = vertices(tgr); vi != vi_end; vi++) { vim[*vi] = i++; ///Initialize vertex index property } max_cr = maximum_cycle_ratio(tgr, vim, ew1, ew2); diff --git a/example/dag_shortest_paths.cpp b/example/dag_shortest_paths.cpp index b86896f1..97140c8e 100644 --- a/example/dag_shortest_paths.cpp +++ b/example/dag_shortest_paths.cpp @@ -60,7 +60,7 @@ int main() #endif graph_traits::vertex_iterator vi , vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) if (d_map[*vi] == (std::numeric_limits::max)()) std::cout << name[*vi] << ": inifinity\n"; else diff --git a/example/dfs-parenthesis.cpp b/example/dfs-parenthesis.cpp index e3426417..1078f90b 100644 --- a/example/dfs-parenthesis.cpp +++ b/example/dfs-parenthesis.cpp @@ -36,7 +36,7 @@ main() GraphvizGraph g; read_graphviz("figs/dfs-example.dot", g); graph_traits < GraphvizGraph >::edge_iterator e, e_end; - for (tie(e, e_end) = edges(g); e != e_end; ++e) + for (boost::tie(e, e_end) = edges(g); e != e_end; ++e) std::cout << '(' << name[source(*e, g)] << ' ' << name[target(*e, g)] << ')' << std::endl; parenthesis_visitor diff --git a/example/dijkstra-example-listS.cpp b/example/dijkstra-example-listS.cpp index 775bcc2e..1c934207 100644 --- a/example/dijkstra-example-listS.cpp +++ b/example/dijkstra-example-listS.cpp @@ -43,13 +43,13 @@ main(int, char *[]) property_map::type weightmap = get(edge_weight, g); std::vector msvc_vertices; - for (tie(i, iend) = vertices(g); i != iend; ++i) + for (boost::tie(i, iend) = vertices(g); i != iend; ++i) msvc_vertices.push_back(*i); for (std::size_t j = 0; j < num_arcs; ++j) { edge_descriptor e; bool inserted; - tie(e, inserted) = add_edge(msvc_vertices[edge_array[j].first], - msvc_vertices[edge_array[j].second], g); + boost::tie(e, inserted) = add_edge(msvc_vertices[edge_array[j].first], + msvc_vertices[edge_array[j].second], g); weightmap[e] = weights[j]; } @@ -62,7 +62,7 @@ main(int, char *[]) property_map::type indexmap = get(vertex_index, g); property_map::type name = get(vertex_name, g); int c = 0; - for (tie(i, iend) = vertices(g); i != iend; ++i, ++c) { + for (boost::tie(i, iend) = vertices(g); i != iend; ++i, ++c) { indexmap[*i] = c; name[*i] = 'A' + c; } @@ -86,7 +86,7 @@ main(int, char *[]) std::cout << "distances and parents:" << std::endl; graph_traits < graph_t >::vertex_iterator vi, vend; - for (tie(vi, vend) = vertices(g); vi != vend; ++vi) { + for (boost::tie(vi, vend) = vertices(g); vi != vend; ++vi) { std::cout << "distance(" << name[*vi] << ") = " << d[*vi] << ", "; std::cout << "parent(" << name[*vi] << ") = " << name[p[*vi]] << std:: endl; @@ -101,7 +101,7 @@ main(int, char *[]) << " edge[style=\"bold\"]\n" << " node[shape=\"circle\"]\n"; graph_traits < graph_t >::edge_iterator ei, ei_end; - for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { + for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { graph_traits < graph_t >::edge_descriptor e = *ei; graph_traits < graph_t >::vertex_descriptor u = source(e, g), v = target(e, g); diff --git a/example/dijkstra-example.cpp b/example/dijkstra-example.cpp index f1a34d5a..6a77dded 100644 --- a/example/dijkstra-example.cpp +++ b/example/dijkstra-example.cpp @@ -37,7 +37,7 @@ main(int, char *[]) property_map::type weightmap = get(edge_weight, g); for (std::size_t j = 0; j < num_arcs; ++j) { edge_descriptor e; bool inserted; - tie(e, inserted) = add_edge(edge_array[j].first, edge_array[j].second, g); + boost::tie(e, inserted) = add_edge(edge_array[j].first, edge_array[j].second, g); weightmap[e] = weights[j]; } #else @@ -61,7 +61,7 @@ main(int, char *[]) std::cout << "distances and parents:" << std::endl; graph_traits < graph_t >::vertex_iterator vi, vend; - for (tie(vi, vend) = vertices(g); vi != vend; ++vi) { + for (boost::tie(vi, vend) = vertices(g); vi != vend; ++vi) { std::cout << "distance(" << name[*vi] << ") = " << d[*vi] << ", "; std::cout << "parent(" << name[*vi] << ") = " << name[p[*vi]] << std:: endl; @@ -77,7 +77,7 @@ main(int, char *[]) << " edge[style=\"bold\"]\n" << " node[shape=\"circle\"]\n"; graph_traits < graph_t >::edge_iterator ei, ei_end; - for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { + for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { graph_traits < graph_t >::edge_descriptor e = *ei; graph_traits < graph_t >::vertex_descriptor u = source(e, g), v = target(e, g); diff --git a/example/dijkstra-no-color-map-example.cpp b/example/dijkstra-no-color-map-example.cpp index a52b9e31..cc89ab4f 100644 --- a/example/dijkstra-no-color-map-example.cpp +++ b/example/dijkstra-no-color-map-example.cpp @@ -41,7 +41,7 @@ main(int, char *[]) property_map::type weightmap = get(edge_weight, g); for (std::size_t j = 0; j < num_arcs; ++j) { edge_descriptor e; bool inserted; - tie(e, inserted) = add_edge(edge_array[j].first, edge_array[j].second, g); + boost::tie(e, inserted) = add_edge(edge_array[j].first, edge_array[j].second, g); weightmap[e] = weights[j]; } #else @@ -66,7 +66,7 @@ main(int, char *[]) std::cout << "distances and parents:" << std::endl; graph_traits < graph_t >::vertex_iterator vi, vend; - for (tie(vi, vend) = vertices(g); vi != vend; ++vi) { + for (boost::tie(vi, vend) = vertices(g); vi != vend; ++vi) { std::cout << "distance(" << name[*vi] << ") = " << d[*vi] << ", "; std::cout << "parent(" << name[*vi] << ") = " << name[p[*vi]] << std:: endl; @@ -82,7 +82,7 @@ main(int, char *[]) << " edge[style=\"bold\"]\n" << " node[shape=\"circle\"]\n"; graph_traits < graph_t >::edge_iterator ei, ei_end; - for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { + for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { graph_traits < graph_t >::edge_descriptor e = *ei; graph_traits < graph_t >::vertex_descriptor u = source(e, g), v = target(e, g); diff --git a/example/eccentricity.cpp b/example/eccentricity.cpp index c49c2825..3e16e6f2 100644 --- a/example/eccentricity.cpp +++ b/example/eccentricity.cpp @@ -73,11 +73,11 @@ main(int argc, char *argv[]) int r, d; EccentricityContainer eccs(num_vertices(g)); EccentricityMap em(eccs, g); - tie(r, d) = all_eccentricities(g, dm, em); + boost::tie(r, d) = all_eccentricities(g, dm, em); // Print the closeness centrality of each vertex. graph_traits::vertex_iterator i, end; - for(tie(i, end) = vertices(g); i != end; ++i) { + for(boost::tie(i, end) = vertices(g); i != end; ++i) { cout << setw(12) << setiosflags(ios::left) << g[*i].name << get(em, *i) << endl; } diff --git a/example/edge-connectivity.cpp b/example/edge-connectivity.cpp index f51694e2..bd33ca72 100644 --- a/example/edge-connectivity.cpp +++ b/example/edge-connectivity.cpp @@ -24,7 +24,7 @@ namespace boost typedef typename graph_traits < Graph >::degree_size_type size_type; size_type delta = (std::numeric_limits < size_type >::max)(); typename graph_traits < Graph >::vertex_iterator i, iend; - for (tie(i, iend) = vertices(g); i != iend; ++i) + for (boost::tie(i, iend) = vertices(g); i != iend; ++i) if (degree(*i, g) < delta) { delta = degree(*i, g); @@ -39,7 +39,7 @@ namespace boost OutputIterator result) { typename graph_traits < Graph >::adjacency_iterator ai, aend; - for (tie(ai, aend) = adjacent_vertices(u, g); ai != aend; ++ai) + for (boost::tie(ai, aend) = adjacent_vertices(u, g); ai != aend; ++ai) *result++ = *ai; } template < typename Graph, typename VertexIterator, @@ -87,17 +87,17 @@ namespace boost rev_edge = get(edge_reverse, flow_g); typename graph_traits < VertexListGraph >::edge_iterator ei, ei_end; - for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { + for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { u = source(*ei, g), v = target(*ei, g); - tie(e1, inserted) = add_edge(u, v, flow_g); + boost::tie(e1, inserted) = add_edge(u, v, flow_g); cap[e1] = 1; - tie(e2, inserted) = add_edge(v, u, flow_g); + boost::tie(e2, inserted) = add_edge(v, u, flow_g); cap[e2] = 1; rev_edge[e1] = e2; rev_edge[e2] = e1; } - tie(p, delta) = min_degree_vertex(g); + boost::tie(p, delta) = min_degree_vertex(g); S_star.push_back(p); alpha_star = delta; S.insert(p); @@ -115,7 +115,7 @@ namespace boost if (alpha_S_k < alpha_star) { alpha_star = alpha_S_k; S_star.clear(); - for (tie(vi, vi_end) = vertices(flow_g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = vertices(flow_g); vi != vi_end; ++vi) if (color[*vi] != Color::white()) S_star.push_back(*vi); } @@ -135,7 +135,7 @@ namespace boost degree_size_type c = 0; for (si = S_star.begin(); si != S_star.end(); ++si) { typename graph_traits < VertexListGraph >::out_edge_iterator ei, ei_end; - for (tie(ei, ei_end) = out_edges(*si, g); ei != ei_end; ++ei) + for (boost::tie(ei, ei_end) = out_edges(*si, g); ei != ei_end; ++ei) if (!in_S_star[target(*ei, g)]) { *disconnecting_set++ = *ei; ++c; diff --git a/example/edge-function.cpp b/example/edge-function.cpp index 48a0667b..6ee0b666 100644 --- a/example/edge-function.cpp +++ b/example/edge-function.cpp @@ -43,7 +43,7 @@ output_adjacent_vertices(std::ostream & out, { typename graph_traits < Graph >::adjacency_iterator vi, vi_end; out << get(name_map, u) << " -> { "; - for (tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi) out << get(name_map, *vi) << " "; out << "}" << std::endl; } @@ -108,7 +108,7 @@ main() name_map_t name = get(vertex_name, g); // Get iterators for the vertex set graph_traits < graph_type >::vertex_iterator i, end; - tie(i, end) = vertices(g); + boost::tie(i, end) = vertices(g); // Find yow.h name_equals_t < name_map_t > predicate1("yow.h", name); yow = *std::find_if(i, end, predicate1); @@ -123,13 +123,13 @@ main() bool exists; // Get the edge connecting yow.h to zag.o - tie(e1, exists) = edge(yow, zag, g); + boost::tie(e1, exists) = edge(yow, zag, g); assert(exists == true); assert(source(e1, g) == yow); assert(target(e1, g) == zag); // Discover that there is no edge connecting zag.o to bar.o - tie(e2, exists) = edge(zag, bar, g); + boost::tie(e2, exists) = edge(zag, bar, g); assert(exists == false); assert(num_vertices(g) == 15); diff --git a/example/edge_property.cpp b/example/edge_property.cpp index 5adac08e..3bfe575c 100644 --- a/example/edge_property.cpp +++ b/example/edge_property.cpp @@ -151,8 +151,8 @@ int main(int , char* []) boost::graph_traits::vertex_iterator v, v_end; boost::graph_traits::out_edge_iterator e, e_end; int f = 0; - for (tie(v, v_end) = vertices(G); v != v_end; ++v) - for (tie(e, e_end) = out_edges(*v, G); e != e_end; ++e) + for (boost::tie(v, v_end) = vertices(G); v != v_end; ++v) + for (boost::tie(e, e_end) = out_edges(*v, G); e != e_end; ++e) flow[*e] = ++f; cout << endl << endl; diff --git a/example/edmonds-karp-eg.cpp b/example/edmonds-karp-eg.cpp index 4b5c6fac..688cb674 100644 --- a/example/edmonds-karp-eg.cpp +++ b/example/edmonds-karp-eg.cpp @@ -80,8 +80,8 @@ main() std::cout << "c flow values:" << std::endl; graph_traits < Graph >::vertex_iterator u_iter, u_end; graph_traits < Graph >::out_edge_iterator ei, e_end; - for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) - for (tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) + for (boost::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) + for (boost::tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) if (capacity[*ei] > 0) std::cout << "f " << *u_iter << " " << target(*ei, g) << " " << (capacity[*ei] - residual_capacity[*ei]) << std::endl; diff --git a/example/family-tree-eg.cpp b/example/family-tree-eg.cpp index ab2b0bcc..c3623935 100644 --- a/example/family-tree-eg.cpp +++ b/example/family-tree-eg.cpp @@ -34,9 +34,9 @@ main() property_map < adjacency_list <>, vertex_index_t >::type index_map = get(vertex_index, g); - for (tie(i, end) = vertices(g); i != end; ++i) { + for (boost::tie(i, end) = vertices(g); i != end; ++i) { std::cout << name[get(index_map, *i)]; - tie(ai, a_end) = adjacent_vertices(*i, g); + boost::tie(ai, a_end) = adjacent_vertices(*i, g); if (ai == a_end) std::cout << " has no children"; else diff --git a/example/file_dependencies.cpp b/example/file_dependencies.cpp index e96369ca..9bce7334 100644 --- a/example/file_dependencies.cpp +++ b/example/file_dependencies.cpp @@ -104,7 +104,7 @@ int main(int,char*[]) Graph g(N); for (std::size_t j = 0; j < nedges; ++j) { graph_traits::edge_descriptor e; bool inserted; - tie(e, inserted) = add_edge(used_by[j].first, used_by[j].second, g); + boost::tie(e, inserted) = add_edge(used_by[j].first, used_by[j].second, g); } #else Graph g(used_by, used_by + nedges, N); @@ -135,7 +135,7 @@ int main(int,char*[]) int maxdist=0; // Through the order from topological sort, we are sure that every // time we are using here is already initialized. - for (tie(j, j_end) = in_edges(*i, g); j != j_end; ++j) + for (boost::tie(j, j_end) = in_edges(*i, g); j != j_end; ++j) maxdist=(std::max)(time[source(*j, g)], maxdist); time[*i]=maxdist+1; } @@ -145,7 +145,7 @@ int main(int,char*[]) << "vertices with same group number can be made in parallel" << endl; { graph_traits::vertex_iterator i, iend; - for (tie(i,iend) = vertices(g); i != iend; ++i) + for (boost::tie(i,iend) = vertices(g); i != iend; ++i) cout << "time_slot[" << name[*i] << "] = " << time[*i] << endl; } diff --git a/example/filtered-copy-example.cpp b/example/filtered-copy-example.cpp index f1ee142b..d16dee2d 100644 --- a/example/filtered-copy-example.cpp +++ b/example/filtered-copy-example.cpp @@ -39,7 +39,7 @@ main() name_map = get(vertex_name, G); char name = 'a'; graph_traits < graph_t >::vertex_iterator v, v_end; - for (tie(v, v_end) = vertices(G); v != v_end; ++v, ++name) + for (boost::tie(v, v_end) = vertices(G); v != v_end; ++v, ++name) name_map[*v] = name; typedef std::pair < int, int >E; diff --git a/example/filtered_graph_edge_range.cpp b/example/filtered_graph_edge_range.cpp index 6a00789d..eb140f64 100644 --- a/example/filtered_graph_edge_range.cpp +++ b/example/filtered_graph_edge_range.cpp @@ -61,7 +61,7 @@ int main() std::cout << "unfiltered edge_range(C,D)\n"; graph_traits::out_edge_iterator f, l; - for (tie(f, l) = edge_range(C, D, g); f != l; ++f) + for (boost::tie(f, l) = edge_range(C, D, g); f != l; ++f) std::cout << name[source(*f, g)] << " --" << weight[*f] << "-> " << name[target(*f, g)] << "\n"; @@ -71,7 +71,7 @@ int main() std::cout << "filtered edge_range(C,D)\n"; graph_traits::out_edge_iterator first, last; - for (tie(first, last) = edge_range(C, D, fg); first != last; ++first) + for (boost::tie(first, last) = edge_range(C, D, fg); first != last; ++first) std::cout << name[source(*first, fg)] << " --" << weight[*first] << "-> " << name[target(*first, fg)] << "\n"; diff --git a/example/fr_layout.cpp b/example/fr_layout.cpp index 6fb8b733..2f7e4fea 100644 --- a/example/fr_layout.cpp +++ b/example/fr_layout.cpp @@ -128,7 +128,7 @@ int main(int argc, char* argv[]) cooling(progress_cooling(iterations))); graph_traits::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { std::cout << get(vertex_name, g, *vi) << '\t' << position[*vi][0] << '\t' << position[*vi][1] << std::endl; } diff --git a/example/gerdemann.cpp b/example/gerdemann.cpp index d4b9fbaf..ceb8a235 100644 --- a/example/gerdemann.cpp +++ b/example/gerdemann.cpp @@ -46,13 +46,13 @@ void merge_vertex typedef boost::graph_traits Traits; typename Traits::edge_descriptor e; typename Traits::out_edge_iterator out_i, out_end; - for (tie(out_i, out_end) = out_edges(v, g); out_i != out_end; ++out_i) { + for (boost::tie(out_i, out_end) = out_edges(v, g); out_i != out_end; ++out_i) { e = *out_i; typename Traits::vertex_descriptor targ = target(e, g); add_edge(u, targ, getp(e), g); } typename Traits::in_edge_iterator in_i, in_end; - for (tie(in_i, in_end) = in_edges(v, g); in_i != in_end; ++in_i) { + for (boost::tie(in_i, in_end) = in_edges(v, g); in_i != in_end; ++in_i) { e = *in_i; typename Traits::vertex_descriptor src = source(e, g); add_edge(src, u, getp(e), g); diff --git a/example/graph-property-iter-eg.cpp b/example/graph-property-iter-eg.cpp index f471b0e0..0c11914a 100644 --- a/example/graph-property-iter-eg.cpp +++ b/example/graph-property-iter-eg.cpp @@ -23,11 +23,11 @@ main() const char *vertex_names[] = { "Kubrick", "Clark", "Hal" }; int i = 0; graph_property_iter_range < graph_t, vertex_name_t >::iterator v, v_end; - for (tie(v, v_end) = get_property_iter_range(g, vertex_name); + for (boost::tie(v, v_end) = get_property_iter_range(g, vertex_name); v != v_end; ++v, ++i) *v = vertex_names[i]; - tie(v, v_end) = get_property_iter_range(g, vertex_name); + boost::tie(v, v_end) = get_property_iter_range(g, vertex_name); std::copy(v, v_end, std::ostream_iterator < std::string > (std::cout, " ")); std::cout << std::endl; return 0; diff --git a/example/graphviz.cpp b/example/graphviz.cpp index e3ac9b8f..a21d8541 100644 --- a/example/graphviz.cpp +++ b/example/graphviz.cpp @@ -68,7 +68,7 @@ void test_graph_read_write(const std::string& filename) == 10.0); // Write out the graph - write_graphviz(std::cout, g, dp, std::string("id")); + write_graphviz_dp(std::cout, g, dp, std::string("id")); } int test_main(int, char*[]) diff --git a/example/in_edges.cpp b/example/in_edges.cpp index cceb5538..f729c44d 100644 --- a/example/in_edges.cpp +++ b/example/in_edges.cpp @@ -43,9 +43,9 @@ int main(int , char* []) boost::graph_traits::vertex_iterator i, end; boost::graph_traits::in_edge_iterator ei, edge_end; - for(tie(i,end) = vertices(g); i != end; ++i) { + for(boost::tie(i,end) = vertices(g); i != end; ++i) { cout << *i << " <-- "; - for (tie(ei,edge_end) = in_edges(*i, g); ei != edge_end; ++ei) + for (boost::tie(ei,edge_end) = in_edges(*i, g); ei != edge_end; ++ei) cout << source(*ei, g) << " "; cout << endl; } diff --git a/example/isomorphism.cpp b/example/isomorphism.cpp index 8882f751..c11d70fa 100644 --- a/example/isomorphism.cpp +++ b/example/isomorphism.cpp @@ -35,12 +35,12 @@ main() graph_traits::vertex_iterator i, end; int id = 0; - for (tie(i, end) = vertices(g1); i != end; ++i, ++id) { + for (boost::tie(i, end) = vertices(g1); i != end; ++i, ++id) { put(v1_index_map, *i, id); v1[id] = *i; } id = 0; - for (tie(i, end) = vertices(g2); i != end; ++i, ++id) { + for (boost::tie(i, end) = vertices(g2); i != end; ++i, ++id) { put(v2_index_map, *i, id); v2[id] = *i; } diff --git a/example/johnson-eg.cpp b/example/johnson-eg.cpp index fa56081a..557b1733 100644 --- a/example/johnson-eg.cpp +++ b/example/johnson-eg.cpp @@ -73,7 +73,7 @@ main() << "edge[style=\"bold\"]\n" << "node[shape=\"circle\"]\n"; graph_traits < Graph >::edge_iterator ei, ei_end; - for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) fout << source(*ei, g) << " -> " << target(*ei, g) << "[label=" << get(edge_weight, g)[*ei] << "]\n"; diff --git a/example/kevin-bacon.cpp b/example/kevin-bacon.cpp index 2678bb05..5b1dd8b5 100644 --- a/example/kevin-bacon.cpp +++ b/example/kevin-bacon.cpp @@ -74,7 +74,7 @@ main() NameVertexMap::iterator pos; bool inserted; Vertex u, v; - tie(pos, inserted) = actors.insert(std::make_pair(actors_name, Vertex())); + boost::tie(pos, inserted) = actors.insert(std::make_pair(actors_name, Vertex())); if (inserted) { u = add_vertex(g); actor_name[u] = actors_name; @@ -84,7 +84,7 @@ main() std::string movie_name = *i++; - tie(pos, inserted) = actors.insert(std::make_pair(*i, Vertex())); + boost::tie(pos, inserted) = actors.insert(std::make_pair(*i, Vertex())); if (inserted) { v = add_vertex(g); actor_name[v] = *i; @@ -93,7 +93,7 @@ main() v = pos->second; graph_traits < Graph >::edge_descriptor e; - tie(e, inserted) = add_edge(u, v, g); + boost::tie(e, inserted) = add_edge(u, v, g); if (inserted) connecting_movie[e] = movie_name; @@ -108,7 +108,7 @@ main() visitor(record_bacon_number(&bacon_number[0]))); graph_traits < Graph >::vertex_iterator i, end; - for (tie(i, end) = vertices(g); i != end; ++i) { + for (boost::tie(i, end) = vertices(g); i != end; ++i) { std::cout << actor_name[*i] << " has a Bacon number of " << bacon_number[*i] << std::endl; } diff --git a/example/kevin-bacon2.cpp b/example/kevin-bacon2.cpp index 719d24c6..79fb9a58 100644 --- a/example/kevin-bacon2.cpp +++ b/example/kevin-bacon2.cpp @@ -71,7 +71,7 @@ int main() // Get the vertex for Kevin Bacon Vertex src; graph_traits::vertex_iterator i, end; - for (tie(i, end) = vertices(g); i != end; ++i) + for (boost::tie(i, end) = vertices(g); i != end; ++i) if (g[*i].name == "Kevin Bacon") src = *i; @@ -82,7 +82,7 @@ int main() breadth_first_search(g, src, visitor(bacon_number_recorder(&bacon_number[0]))); - for (tie(i, end) = vertices(g); i != end; ++i) + for (boost::tie(i, end) = vertices(g); i != end; ++i) std::cout << g[*i].name << " has a Bacon number of " << bacon_number[*i] << std::endl; diff --git a/example/knights-tour.cpp b/example/knights-tour.cpp index bbd0d800..048cbde4 100644 --- a/example/knights-tour.cpp +++ b/example/knights-tour.cpp @@ -179,7 +179,7 @@ template < typename Graph, typename TimePropertyMap > S.push(std::make_pair(time_stamp, src)); while (!S.empty()) { Vertex x; - tie(time_stamp, x) = S.top(); + boost::tie(time_stamp, x) = S.top(); put(time_map, x, time_stamp); // all vertices have been visited, success! if (time_stamp == num_vertices(g) - 1) @@ -187,7 +187,7 @@ template < typename Graph, typename TimePropertyMap > bool deadend = true; typename graph_traits < Graph >::adjacency_iterator i, end; - for (tie(i, end) = adjacent_vertices(x, g); i != end; ++i) + for (boost::tie(i, end) = adjacent_vertices(x, g); i != end; ++i) if (get(time_map, *i) == -1) { S.push(std::make_pair(time_stamp + 1, *i)); deadend = false; @@ -196,11 +196,11 @@ template < typename Graph, typename TimePropertyMap > if (deadend) { put(time_map, x, -1); S.pop(); - tie(time_stamp, x) = S.top(); + boost::tie(time_stamp, x) = S.top(); while (get(time_map, x) != -1) { // unwind stack to last unexplored vertex put(time_map, x, -1); S.pop(); - tie(time_stamp, x) = S.top(); + boost::tie(time_stamp, x) = S.top(); } } @@ -213,7 +213,7 @@ number_of_successors(Vertex x, Graph & g, TimePropertyMap time_map) { int s_x = 0; typename graph_traits < Graph >::adjacency_iterator i, end; - for (tie(i, end) = adjacent_vertices(x, g); i != end; ++i) + for (boost::tie(i, end) = adjacent_vertices(x, g); i != end; ++i) if (get(time_map, *i) == -1) ++s_x; return s_x; @@ -232,7 +232,7 @@ template < typename Graph, typename TimePropertyMap > S.push(std::make_pair(time_stamp, src)); while (!S.empty()) { Vertex x; - tie(time_stamp, x) = S.top(); + boost::tie(time_stamp, x) = S.top(); put(time_map, x, time_stamp); // all vertices have been visited, success! if (time_stamp == num_vertices(g) - 1) @@ -242,7 +242,7 @@ template < typename Graph, typename TimePropertyMap > std::priority_queue < P, std::vector < P >, compare_first > Q; typename graph_traits < Graph >::adjacency_iterator i, end; int num_succ; - for (tie(i, end) = adjacent_vertices(x, g); i != end; ++i) + for (boost::tie(i, end) = adjacent_vertices(x, g); i != end; ++i) if (get(time_map, *i) == -1) { num_succ = number_of_successors(*i, g, time_map); Q.push(std::make_pair(num_succ, *i)); @@ -250,17 +250,17 @@ template < typename Graph, typename TimePropertyMap > bool deadend = Q.empty(); // move vertices from local priority queue to the stack for (; !Q.empty(); Q.pop()) { - tie(num_succ, x) = Q.top(); + boost::tie(num_succ, x) = Q.top(); S.push(std::make_pair(time_stamp + 1, x)); } if (deadend) { put(time_map, x, -1); S.pop(); - tie(time_stamp, x) = S.top(); + boost::tie(time_stamp, x) = S.top(); while (get(time_map, x) != -1) { // unwind stack to last unexplored vertex put(time_map, x, -1); S.pop(); - tie(time_stamp, x) = S.top(); + boost::tie(time_stamp, x) = S.top(); } } diff --git a/example/kruskal-example.cpp b/example/kruskal-example.cpp index 23d36057..ca27eb74 100644 --- a/example/kruskal-example.cpp +++ b/example/kruskal-example.cpp @@ -31,7 +31,7 @@ main() property_map::type weightmap = get(edge_weight, g); for (std::size_t j = 0; j < num_edges; ++j) { Edge e; bool inserted; - tie(e, inserted) = add_edge(edge_array[j].first, edge_array[j].second, g); + boost::tie(e, inserted) = add_edge(edge_array[j].first, edge_array[j].second, g); weightmap[e] = weights[j]; } #else @@ -57,7 +57,7 @@ main() << " ratio=\"filled\"\n" << " edge[style=\"bold\"]\n" << " node[shape=\"circle\"]\n"; graph_traits::edge_iterator eiter, eiter_end; - for (tie(eiter, eiter_end) = edges(g); eiter != eiter_end; ++eiter) { + for (boost::tie(eiter, eiter_end) = edges(g); eiter != eiter_end; ++eiter) { fout << source(*eiter, g) << " -- " << target(*eiter, g); if (std::find(spanning_tree.begin(), spanning_tree.end(), *eiter) != spanning_tree.end()) diff --git a/example/kruskal-telephone.cpp b/example/kruskal-telephone.cpp index 1a24e77f..7e53d70a 100644 --- a/example/kruskal-telephone.cpp +++ b/example/kruskal-telephone.cpp @@ -25,7 +25,7 @@ main() property_map < GraphvizGraph, edge_attribute_t >::type edge_attr_map = get(edge_attribute, g_dot); graph_traits < GraphvizGraph >::edge_iterator ei, ei_end; - for (tie(ei, ei_end) = edges(g_dot); ei != ei_end; ++ei) { + for (boost::tie(ei, ei_end) = edges(g_dot); ei != ei_end; ++ei) { int weight = lexical_cast < int >(edge_attr_map[*ei]["label"]); property < edge_weight_t, int >edge_property(weight); add_edge(source(*ei, g_dot), target(*ei, g_dot), edge_property, g); diff --git a/example/leda-graph-eg.cpp b/example/leda-graph-eg.cpp index 81449a66..4fddab84 100644 --- a/example/leda-graph-eg.cpp +++ b/example/leda-graph-eg.cpp @@ -22,7 +22,7 @@ main() typedef property_map < graph_t, vertex_all_t >::type NodeMap; NodeMap node_name_map = get(vertex_all, g); graph_traits < graph_t >::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) std::cout << node_name_map[*vi] << std::endl; return EXIT_SUCCESS; } diff --git a/example/loops_dfs.cpp b/example/loops_dfs.cpp index 66855b88..c6babb1e 100644 --- a/example/loops_dfs.cpp +++ b/example/loops_dfs.cpp @@ -91,7 +91,7 @@ compute_loop_extent(typename graph_traits < get(vertex_index, g), c)); typename graph_traits < Graph >::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) if (reachable_from_head[*vi] != Color::white() && reachable_to_tail[*vi] != Color::white()) loop_set.insert(*vi); @@ -138,7 +138,7 @@ main(int argc, char *argv[]) vattr_map[*j]["color"] = "gray"; in_loop[*j] = true; } - for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) if (in_loop[source(*ei, g)] && in_loop[target(*ei, g)]) eattr_map[*ei]["color"] = "gray"; } @@ -151,7 +151,7 @@ main(int argc, char *argv[]) << "ratio=\"fill\"\n" << "shape=\"box\"\n"; graph_traits::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { loops_out << *vi << "["; for (std::map::iterator ai = vattr_map[*vi].begin(); ai != vattr_map[*vi].end(); ++ai) { @@ -162,7 +162,7 @@ main(int argc, char *argv[]) loops_out<< "]"; } - for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { + for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { loops_out << source(*ei, g) << " -> " << target(*ei, g) << "["; std::map& attr_map = eattr_map[*ei]; for (std::map::iterator eai = attr_map.begin(); diff --git a/example/max_flow.cpp b/example/max_flow.cpp index 16a0c9ed..fc9f17c1 100644 --- a/example/max_flow.cpp +++ b/example/max_flow.cpp @@ -85,8 +85,8 @@ main() std::cout << "c flow values:" << std::endl; graph_traits::vertex_iterator u_iter, u_end; graph_traits::out_edge_iterator ei, e_end; - for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) - for (tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) + for (boost::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) + for (boost::tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) if (capacity[*ei] > 0) std::cout << "f " << *u_iter << " " << target(*ei, g) << " " << (capacity[*ei] - residual_capacity[*ei]) << std::endl; diff --git a/example/min_max_paths.cpp b/example/min_max_paths.cpp index d9da0ff4..42a740b6 100644 --- a/example/min_max_paths.cpp +++ b/example/min_max_paths.cpp @@ -58,7 +58,7 @@ main(int , char* []) property_map::type weightmap = get(edge_weight, G); for (std::size_t j = 0; j < sizeof(edges) / sizeof(E); ++j) { graph_traits::edge_descriptor e; bool inserted; - tie(e, inserted) = add_edge(edges[j].first, edges[j].second, G); + boost::tie(e, inserted) = add_edge(edges[j].first, edges[j].second, G); weightmap[e] = weights[j]; } #else @@ -85,14 +85,14 @@ main(int , char* []) std::cout << "distances from start vertex:" << std::endl; graph_traits::vertex_iterator vi, vend; - for(tie(vi,vend) = vertices(G); vi != vend; ++vi) + for(boost::tie(vi,vend) = vertices(G); vi != vend; ++vi) std::cout << "distance(" << name[*vi] << ") = " << d[*vi] << std::endl; std::cout << std::endl; std::cout << "min-max paths tree" << std::endl; adjacency_list<> tree(num_nodes); - for(tie(vi,vend) = vertices(G); vi != vend; ++vi) + for(boost::tie(vi,vend) = vertices(G); vi != vend; ++vi) if (*vi != p[*vi]) add_edge(p[*vi], *vi, tree); diff --git a/example/modify_graph.cpp b/example/modify_graph.cpp index 4cd93306..42b668cb 100644 --- a/example/modify_graph.cpp +++ b/example/modify_graph.cpp @@ -86,7 +86,7 @@ void modify_demo(MutableGraph& g) u = add_vertex(g); v = add_vertex(g); - tie(e, added) = add_edge(u, v, g); + boost::tie(e, added) = add_edge(u, v, g); assert(num_edges(g) == m + 2); assert(added == true); // edge should have been added @@ -102,14 +102,14 @@ void modify_demo(MutableGraph& g) assert(num_edges(g) == m + 1); bool exists; - tie(e, exists) = edge(u, v, g); + boost::tie(e, exists) = edge(u, v, g); assert(exists == false); assert(out_degree(u, g) == 0); assert(in_degree(v, g) == 0); } { e = *edges(g).first; - tie(u, v) = incident(e, g); + boost::tie(u, v) = incident(e, g); remove_edge(e, g); @@ -121,7 +121,7 @@ void modify_demo(MutableGraph& g) add_edge(u, v, g); typename GraphTraits::out_edge_iterator iter, iter_end; - tie(iter, iter_end) = out_edges(u, g); + boost::tie(iter, iter_end) = out_edges(u, g); remove_edge(iter, g); @@ -131,13 +131,13 @@ void modify_demo(MutableGraph& g) } { w = add_vertex(g); - tie(e1, added) = add_edge(u, v, g); - tie(e2, added) = add_edge(v, w, g); + boost::tie(e1, added) = add_edge(u, v, g); + boost::tie(e2, added) = add_edge(v, w, g); name_map[e1] = "I-5"; name_map[e2] = "Route 66"; typename GraphTraits::out_edge_iterator iter, iter_end; - tie(iter, iter_end) = out_edges(u, g); + boost::tie(iter, iter_end) = out_edges(u, g); remove_edge_if(name_equals("Route 66", name_map), g); @@ -152,8 +152,8 @@ void modify_demo(MutableGraph& g) assert(in_degree(w, g) == 0); } { - tie(e1, added) = add_edge(u, v, g); - tie(e2, added) = add_edge(u, w, g); + boost::tie(e1, added) = add_edge(u, v, g); + boost::tie(e2, added) = add_edge(u, w, g); name_map[e1] = "foo"; name_map[e2] = "foo"; @@ -163,8 +163,8 @@ void modify_demo(MutableGraph& g) assert(out_degree(u, g) == 0); } { - tie(e1, added) = add_edge(u, v, g); - tie(e2, added) = add_edge(w, v, g); + boost::tie(e1, added) = add_edge(u, v, g); + boost::tie(e2, added) = add_edge(w, v, g); name_map[e1] = "bar"; name_map[e2] = "bar"; @@ -183,9 +183,9 @@ void modify_demo(MutableGraph& g) assert(out_degree(u, g) == 0); - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { typename GraphTraits::adjacency_iterator ai, ai_end; - for (tie(ai, ai_end) = adjacent_vertices(*vi, g); + for (boost::tie(ai, ai_end) = adjacent_vertices(*vi, g); ai != ai_end; ++ai) assert(*ai != u); } diff --git a/example/ordered_out_edges.cpp b/example/ordered_out_edges.cpp index 93613332..5c45373a 100644 --- a/example/ordered_out_edges.cpp +++ b/example/ordered_out_edges.cpp @@ -108,14 +108,14 @@ main() Traits::edge_descriptor e; Traits::out_edge_iterator e_first, e_last; - tie(e, found) = edge(0, 1, g); + boost::tie(e, found) = edge(0, 1, g); if (found) std::cout << "name(0,1) = " << name[e] << std::endl; else std::cout << "not found" << std::endl; std::cout << std::endl; - tie(e_first, e_last) = edge_range(0, 1, g); + boost::tie(e_first, e_last) = edge_range(0, 1, g); while (e_first != e_last) std::cout << "name(0,1) = " << name[*e_first++] << std::endl; #endif diff --git a/example/ospf-example.cpp b/example/ospf-example.cpp index 15332889..3d0e53b7 100644 --- a/example/ospf-example.cpp +++ b/example/ospf-example.cpp @@ -9,32 +9,50 @@ #include // for read/write_graphviz() #include #include + +namespace boost { + enum graph_color_t { graph_color = 5556 }; + BOOST_INSTALL_PROPERTY(graph, color); +} + int main() { using namespace boost; - GraphvizDigraph g_dot; - read_graphviz("figs/ospf-graph.dot", g_dot); + typedef + adjacency_list, + property >, + property > + g_dot_type; + g_dot_type g_dot; + + dynamic_properties dp(ignore_other_properties); + dp.property("node_id", get(vertex_name, g_dot)); + dp.property("label", get(edge_weight, g_dot)); + dp.property("color", get(edge_color, g_dot)); + dp.property("color", ref_property_map(get_property(g_dot, graph_color))); + { + std::ifstream infile("figs/ospf-graph.dot"); + read_graphviz(infile, g_dot, dp); + } typedef adjacency_list < vecS, vecS, directedS, no_property, property < edge_weight_t, int > > Graph; typedef graph_traits < Graph >::vertex_descriptor vertex_descriptor; Graph g(num_vertices(g_dot)); - property_map < GraphvizDigraph, edge_attribute_t >::type - edge_attr_map = get(edge_attribute, g_dot); - graph_traits < GraphvizDigraph >::edge_iterator ei, ei_end; - for (tie(ei, ei_end) = edges(g_dot); ei != ei_end; ++ei) { - int weight = lexical_cast < int >(edge_attr_map[*ei]["label"]); + graph_traits < g_dot_type >::edge_iterator ei, ei_end; + for (boost::tie(ei, ei_end) = edges(g_dot); ei != ei_end; ++ei) { + int weight = get(edge_weight, g_dot, *ei); property < edge_weight_t, int >edge_property(weight); add_edge(source(*ei, g_dot), target(*ei, g_dot), edge_property, g); } vertex_descriptor router_six; - property_map < GraphvizDigraph, vertex_attribute_t >::type - vertex_attr_map = get(vertex_attribute, g_dot); - graph_traits < GraphvizDigraph >::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g_dot); vi != vi_end; ++vi) - if ("RT6" == vertex_attr_map[*vi]["label"]) { + graph_traits < g_dot_type >::vertex_iterator vi, vi_end; + for (boost::tie(vi, vi_end) = vertices(g_dot); vi != vi_end; ++vi) + if ("RT6" == get(vertex_name, g_dot, *vi)) { router_six = *vi; break; } @@ -57,58 +75,24 @@ main() dijkstra_shortest_paths(g, router_six, predecessor_map(&parent[0])); #endif - graph_traits < GraphvizDigraph >::edge_descriptor e; + graph_traits < g_dot_type >::edge_descriptor e; for (size_type i = 0; i < num_vertices(g); ++i) if (parent[i] != i) { e = edge(parent[i], i, g_dot).first; - edge_attr_map[e]["color"] = "black"; + put(edge_color, g_dot, e, "black"); } -#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 - // VC++ can't handle write_graphviz :( + get_property(g_dot, graph_color) = "grey"; { - std::ofstream out("figs/ospf-sptree.dot"); - out << "digraph loops {\n" - << "size=\"3,3\"\n" - << "ratio=\"fill\"\n" - << "shape=\"box\"\n"; - graph_traits::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { - out << *vi << "["; - for (std::map::iterator ai = vattr_map[*vi].begin(); - ai != vattr_map[*vi].end(); ++ai) { - out << ai->first << "=" << ai->second; - if (next(ai) != vattr_map[*vi].end()) - out << ", "; - } - out<< "]"; - } - - for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { - out << source(*ei, g) << " -> " << target(*ei, g) << "["; - std::map& attr_map = eattr_map[*ei]; - for (std::map::iterator eai = attr_map.begin(); - eai != attr_map.end(); ++eai) { - out << eai->first << "=" << eai->second; - if (next(eai) != attr_map.end()) - out << ", "; - } - out<< "]"; - } - out << "}\n"; + std::ofstream outfile("figs/ospf-sptree.dot"); + write_graphviz_dp(outfile, g_dot, dp); } -#else - graph_property < GraphvizDigraph, graph_edge_attribute_t >::type & - graph_edge_attr_map = get_property(g_dot, graph_edge_attribute); - graph_edge_attr_map["color"] = "grey"; - write_graphviz("figs/ospf-sptree.dot", g_dot); -#endif std::ofstream rtable("routing-table.dat"); rtable << "Dest Next Hop Total Cost" << std::endl; - for (tie(vi, vi_end) = vertices(g_dot); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = vertices(g_dot); vi != vi_end; ++vi) if (parent[*vi] != *vi) { - rtable << vertex_attr_map[*vi]["label"] << " "; + rtable << get(vertex_name, g_dot, *vi) << " "; vertex_descriptor v = *vi, child; int path_cost = 0; property_map < Graph, edge_weight_t >::type @@ -118,7 +102,7 @@ main() child = v; v = parent[v]; } while (v != parent[v]); - rtable << vertex_attr_map[child]["label"] << " "; + rtable << get(vertex_name, g_dot, child) << " "; rtable << path_cost << std::endl; } diff --git a/example/parallel-compile-time.cpp b/example/parallel-compile-time.cpp index f66d1bd9..271cdec6 100644 --- a/example/parallel-compile-time.cpp +++ b/example/parallel-compile-time.cpp @@ -59,7 +59,7 @@ dfs_v2(const Graph & g, color[u] = ColorT::gray(); vis.discover_vertex(u, g); typename graph_traits < Graph >::out_edge_iterator ei, ei_end; - for (tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) + for (boost::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) if (color[target(*ei, g)] == ColorT::white()) { vis.tree_edge(*ei, g); dfs_v2(g, target(*ei, g), color, vis); @@ -77,9 +77,9 @@ generic_dfs_v2(const Graph & g, Visitor vis, ColorMap color) typedef typename property_traits ::value_type ColorValue; typedef color_traits < ColorValue > ColorT; typename graph_traits < Graph >::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) color[*vi] = ColorT::white(); - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) if (color[*vi] == ColorT::white()) dfs_v2(g, *vi, color, vis); } @@ -134,7 +134,7 @@ main() id2vertex.push_back(add_vertex(g)); while (input_begin != input_end) { size_type i, j; - tie(i, j) = *input_begin++; + boost::tie(i, j) = *input_begin++; add_edge(id2vertex[i], id2vertex[j], g); } #else @@ -158,7 +158,7 @@ main() std::ifstream name_in("makefile-target-names.dat"); std::ifstream compile_cost_in("target-compile-costs.dat"); graph_traits < file_dep_graph2 >::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { name_in >> name_map[*vi]; compile_cost_in >> compile_cost_map[*vi]; } @@ -171,14 +171,14 @@ main() graph_traits < file_dep_graph2 >::adjacency_iterator vi, vi_end; // find source vertices with zero in-degree by marking all vertices with incoming edges - for (tie(i, i_end) = vertices(g); i != i_end; ++i) + for (boost::tie(i, i_end) = vertices(g); i != i_end; ++i) color_map[*i] = white_color; - for (tie(i, i_end) = vertices(g); i != i_end; ++i) - for (tie(vi, vi_end) = adjacent_vertices(*i, g); vi != vi_end; ++vi) + for (boost::tie(i, i_end) = vertices(g); i != i_end; ++i) + for (boost::tie(vi, vi_end) = adjacent_vertices(*i, g); vi != vi_end; ++vi) color_map[*vi] = black_color; // initialize distances to zero, or for source vertices, to the compile cost - for (tie(i, i_end) = vertices(g); i != i_end; ++i) + for (boost::tie(i, i_end) = vertices(g); i != i_end; ++i) if (color_map[*i] == white_color) distance_map[*i] = compile_cost_map[*i]; else @@ -189,14 +189,14 @@ main() vertex_t u = * ui; - for (tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi) if (distance_map[*vi] < distance_map[u] + compile_cost_map[*vi]) distance_map[*vi] = distance_map[u] + compile_cost_map[*vi]; } graph_property_iter_range < file_dep_graph2, vertex_distance_t >::iterator ci, ci_end; - tie(ci, ci_end) = get_property_iter_range(g, vertex_distance); + boost::tie(ci, ci_end) = get_property_iter_range(g, vertex_distance); std::cout << "total (parallel) compile time: " << *std::max_element(ci, ci_end) << std::endl; diff --git a/example/prim-example.cpp b/example/prim-example.cpp index cdd93f76..ba44aa9b 100644 --- a/example/prim-example.cpp +++ b/example/prim-example.cpp @@ -27,7 +27,7 @@ main() property_map::type weightmap = get(edge_weight, g); for (std::size_t j = 0; j < sizeof(edges) / sizeof(E); ++j) { graph_traits::edge_descriptor e; bool inserted; - tie(e, inserted) = add_edge(edges[j].first, edges[j].second, g); + boost::tie(e, inserted) = add_edge(edges[j].first, edges[j].second, g); weightmap[e] = weights[j]; } #else diff --git a/example/prim-telephone.cpp b/example/prim-telephone.cpp index 34d9dacd..6b6f914f 100644 --- a/example/prim-telephone.cpp +++ b/example/prim-telephone.cpp @@ -25,7 +25,7 @@ main() property_map < GraphvizGraph, edge_attribute_t >::type edge_attr_map = get(edge_attribute, g_dot); graph_traits < GraphvizGraph >::edge_iterator ei, ei_end; - for (tie(ei, ei_end) = edges(g_dot); ei != ei_end; ++ei) { + for (boost::tie(ei, ei_end) = edges(g_dot); ei != ei_end; ++ei) { int weight = lexical_cast < int >(edge_attr_map[*ei]["label"]); property < edge_weight_t, int >edge_property(weight); add_edge(source(*ei, g_dot), target(*ei, g_dot), edge_property, g); diff --git a/example/print-adjacent-vertices.cpp b/example/print-adjacent-vertices.cpp index 7b1c4b1c..6c20941d 100644 --- a/example/print-adjacent-vertices.cpp +++ b/example/print-adjacent-vertices.cpp @@ -43,7 +43,7 @@ output_adjacent_vertices(std::ostream & out, { typename graph_traits < Graph >::adjacency_iterator vi, vi_end; out << get(name_map, u) << " -> { "; - for (tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi) out << get(name_map, *vi) << " "; out << "}" << std::endl; } @@ -101,7 +101,7 @@ main() read_graph_file(file_in, name_in, g, name_map); graph_traits < graph_type >::vertex_iterator i, end; - tie(i, end) = vertices(g); + boost::tie(i, end) = vertices(g); i = std::find_if(i, end, name_equals("dax.h", get(vertex_name, g))); output_adjacent_vertices(std::cout, *i, g, get(vertex_name, g)); diff --git a/example/print-edges.cpp b/example/print-edges.cpp index 6c982675..7616022b 100644 --- a/example/print-edges.cpp +++ b/example/print-edges.cpp @@ -41,7 +41,7 @@ print_dependencies(std::ostream & out, const Graph & g, VertexNameMap name_map) { typename graph_traits < Graph >::edge_iterator ei, ei_end; - for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) out << get(name_map, source(*ei, g)) << " -$>$ " << get(name_map, target(*ei, g)) << std::endl; } diff --git a/example/print-in-edges.cpp b/example/print-in-edges.cpp index d2a6f15d..f558d4e9 100644 --- a/example/print-in-edges.cpp +++ b/example/print-in-edges.cpp @@ -42,7 +42,7 @@ output_in_edges(std::ostream & out, const Graph & g, VertexNameMap name_map) { typename graph_traits < Graph >::in_edge_iterator ei, ei_end; - for (tie(ei, ei_end) = in_edges(v, g); ei != ei_end; ++ei) + for (boost::tie(ei, ei_end) = in_edges(v, g); ei != ei_end; ++ei) out << get(name_map, source(*ei, g)) << " -> " << get(name_map, target(*ei, g)) << std::endl; } @@ -101,7 +101,7 @@ main() read_graph_file(file_in, name_in, g, name_map); graph_traits < graph_type >::vertex_iterator i, end; - tie(i, end) = vertices(g); + boost::tie(i, end) = vertices(g); typedef property_map < graph_type, vertex_name_t >::type name_map_t; i = std::find_if(i, end, name_equals("libzigzag.a", get(vertex_name, g))); output_in_edges(std::cout, g, *i, get(vertex_name, g)); diff --git a/example/print-out-edges.cpp b/example/print-out-edges.cpp index e5532f00..7e3cbef6 100644 --- a/example/print-out-edges.cpp +++ b/example/print-out-edges.cpp @@ -42,7 +42,7 @@ output_out_edges(std::ostream & out, const Graph & g, VertexNameMap name_map) { typename graph_traits < Graph >::out_edge_iterator ei, ei_end; - for (tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) + for (boost::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) out << get(name_map, source(*ei, g)) << " -> " << get(name_map, target(*ei, g)) << std::endl; } @@ -100,7 +100,7 @@ main() read_graph_file(file_in, name_in, g, name_map); graph_traits < graph_type >::vertex_iterator i, end; - tie(i, end) = vertices(g); + boost::tie(i, end) = vertices(g); typedef property_map < graph_type, vertex_name_t >::type name_map_t; name_equals_t < name_map_t > predicate("dax.h", get(vertex_name, g)); i = std::find_if(i, end, predicate); diff --git a/example/push-relabel-eg.cpp b/example/push-relabel-eg.cpp index 2015ebcb..407045f5 100644 --- a/example/push-relabel-eg.cpp +++ b/example/push-relabel-eg.cpp @@ -75,8 +75,8 @@ main() std::cout << "c flow values:" << std::endl; graph_traits < Graph >::vertex_iterator u_iter, u_end; graph_traits < Graph >::out_edge_iterator ei, e_end; - for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) - for (tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) + for (boost::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) + for (boost::tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) if (capacity[*ei] > 0) std::cout << "f " << *u_iter << " " << target(*ei, g) << " " << (capacity[*ei] - residual_capacity[*ei]) << std::endl; diff --git a/example/quick-tour.cpp b/example/quick-tour.cpp index 2db005f6..31ffb606 100644 --- a/example/quick-tour.cpp +++ b/example/quick-tour.cpp @@ -46,7 +46,7 @@ print_trans_delays(const Graph & g, TransDelayMap trans_delay_map, VertexNameMap name_map) { typename graph_traits < Graph >::edge_iterator first, last; - for (tie(first, last) = edges(g); first != last; ++first) { + for (boost::tie(first, last) = edges(g); first != last; ++first) { print_trans_delay(*first, g, trans_delay_map, name_map); std::cout << std::endl; } @@ -71,19 +71,19 @@ build_router_network(Graph & g, VertexNameMap name_map, typename graph_traits < Graph >::edge_descriptor ed; bool inserted; - tie(ed, inserted) = add_edge(a, b, g); + boost::tie(ed, inserted) = add_edge(a, b, g); delay_map[ed] = 1.2; - tie(ed, inserted) = add_edge(a, d, g); + boost::tie(ed, inserted) = add_edge(a, d, g); delay_map[ed] = 4.5; - tie(ed, inserted) = add_edge(b, d, g); + boost::tie(ed, inserted) = add_edge(b, d, g); delay_map[ed] = 1.8; - tie(ed, inserted) = add_edge(c, a, g); + boost::tie(ed, inserted) = add_edge(c, a, g); delay_map[ed] = 2.6; - tie(ed, inserted) = add_edge(c, e, g); + boost::tie(ed, inserted) = add_edge(c, e, g); delay_map[ed] = 5.2; - tie(ed, inserted) = add_edge(d, c, g); + boost::tie(ed, inserted) = add_edge(d, c, g); delay_map[ed] = 0.4; - tie(ed, inserted) = add_edge(d, e, g); + boost::tie(ed, inserted) = add_edge(d, e, g); delay_map[ed] = 3.3; } diff --git a/example/quick_tour.cpp b/example/quick_tour.cpp index ffb08488..e639fc5a 100644 --- a/example/quick_tour.cpp +++ b/example/quick_tour.cpp @@ -31,7 +31,7 @@ template struct exercise_vertex { std::cout << "\tout-edges: "; typename graph_traits::out_edge_iterator out_i, out_end; typename graph_traits::edge_descriptor e; - for (tie(out_i, out_end) = out_edges(v, g); + for (boost::tie(out_i, out_end) = out_edges(v, g); out_i != out_end; ++out_i) { e = *out_i; @@ -44,7 +44,7 @@ template struct exercise_vertex { // Write out the incoming edges std::cout << "\tin-edges: "; typename graph_traits::in_edge_iterator in_i, in_end; - for (tie(in_i, in_end) = in_edges(v, g); in_i != in_end; ++in_i) + for (boost::tie(in_i, in_end) = in_edges(v, g); in_i != in_end; ++in_i) { e = *in_i; Vertex src = source(e, g), targ = target(e, g); @@ -56,7 +56,7 @@ template struct exercise_vertex { // Write out all adjacent vertices std::cout << "\tadjacent vertices: "; typename graph_traits::adjacency_iterator ai, ai_end; - for (tie(ai,ai_end) = adjacent_vertices(v, g); ai != ai_end; ++ai) + for (boost::tie(ai,ai_end) = adjacent_vertices(v, g); ai != ai_end; ++ai) std::cout << name[get(vertex_id, *ai)] << " "; std::cout << std::endl; } @@ -93,7 +93,7 @@ int main(int,char*[]) property_map::type weightmap = get(edge_weight, g); for (std::size_t j = 0; j < num_edges; ++j) { graph_traits::edge_descriptor e; bool inserted; - tie(e, inserted) = add_edge(edge_array[j].first, edge_array[j].second, g); + boost::tie(e, inserted) = add_edge(edge_array[j].first, edge_array[j].second, g); weightmap[e] = transmission_delay[j]; } #else @@ -115,7 +115,7 @@ int main(int,char*[]) std::cout << "edges(g) = "; graph_traits::edge_iterator ei, ei_end; - for (tie(ei,ei_end) = edges(g); ei != ei_end; ++ei) + for (boost::tie(ei,ei_end) = edges(g); ei != ei_end; ++ei) std::cout << "(" << name[get(vertex_id, source(*ei, g))] << "," << name[get(vertex_id, target(*ei, g))] << ") "; std::cout << std::endl; diff --git a/example/reachable-loop-head.cpp b/example/reachable-loop-head.cpp index 729335e6..2183eab1 100644 --- a/example/reachable-loop-head.cpp +++ b/example/reachable-loop-head.cpp @@ -38,7 +38,7 @@ main(int argc, char *argv[]) vattr_map = get(vertex_attribute, g); graph_traits < GraphvizDigraph >::vertex_iterator i, i_end; - for (tie(i, i_end) = vertices(g); i != i_end; ++i) + for (boost::tie(i, i_end) = vertices(g); i != i_end; ++i) if (reachable_from_head[*i] != Color::white()) { vattr_map[*i]["color"] = "gray"; vattr_map[*i]["style"] = "filled"; @@ -52,7 +52,7 @@ main(int argc, char *argv[]) << "ratio=\"fill\"\n" << "shape=\"box\"\n"; graph_traits::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { loops_out << *vi << "["; for (std::map::iterator ai = vattr_map[*vi].begin(); ai != vattr_map[*vi].end(); ++ai) { @@ -65,7 +65,7 @@ main(int argc, char *argv[]) property_map::type eattr_map = get(edge_attribute, g); graph_traits::edge_iterator ei, ei_end; - for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { + for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { loops_out << source(*ei, g) << " -> " << target(*ei, g) << "["; std::map& attr_map = eattr_map[*ei]; for (std::map::iterator eai = attr_map.begin(); diff --git a/example/reachable-loop-tail.cpp b/example/reachable-loop-tail.cpp index b4ca439a..a723d143 100644 --- a/example/reachable-loop-tail.cpp +++ b/example/reachable-loop-tail.cpp @@ -50,7 +50,7 @@ main(int argc, char *argv[]) property_map::type vattr_map = get(vertex_attribute, g); graph_traits < GraphvizDigraph >::vertex_iterator i, i_end; - for (tie(i, i_end) = vertices(g_in); i != i_end; ++i) { + for (boost::tie(i, i_end) = vertices(g_in); i != i_end; ++i) { loops_out << *i << "[label=\"" << vattr_map[*i]["label"] << "\""; if (reachable_to_tail[*i] != Color::white()) { @@ -59,7 +59,7 @@ main(int argc, char *argv[]) loops_out << "]\n"; } graph_traits < GraphvizDigraph >::edge_iterator e, e_end; - for (tie(e, e_end) = edges(g_in); e != e_end; ++e) + for (boost::tie(e, e_end) = edges(g_in); e != e_end; ++e) loops_out << source(*e, g) << " -> " << target(*e, g) << ";\n"; loops_out << "}\n"; return EXIT_SUCCESS; diff --git a/example/read_write_dimacs-eg.cpp b/example/read_write_dimacs-eg.cpp index f5c19809..64ac43b7 100644 --- a/example/read_write_dimacs-eg.cpp +++ b/example/read_write_dimacs-eg.cpp @@ -90,12 +90,12 @@ int main() //we take the source node and check for each outgoing edge e which has a target(p) if we can augment that path out_edge_iterator oei,oe_end; - for(tie(oei, oe_end) = out_edges(s, g); oei != oe_end; ++oei){ + for(boost::tie(oei, oe_end) = out_edges(s, g); oei != oe_end; ++oei){ edge_descriptor from_source = *oei; vertex_descriptor v = target(from_source, g); edge_descriptor to_sink; bool is_there; - tie(to_sink, is_there) = edge(v, t, g); + boost::tie(to_sink, is_there) = edge(v, t, g); if( is_there ){ if( get(capacity, to_sink) > get(capacity, from_source) ){ tCapMapValue to_augment = get(capacity, from_source); diff --git a/example/remove_edge_if_bidir.cpp b/example/remove_edge_if_bidir.cpp index 09ddea09..9b7ef69f 100644 --- a/example/remove_edge_if_bidir.cpp +++ b/example/remove_edge_if_bidir.cpp @@ -79,7 +79,7 @@ main() int w = 0; graph_traits::edge_iterator ei, ei_end; - for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) weight[*ei] = ++w; property_map::type indexmap = get(vertex_index, g); diff --git a/example/remove_edge_if_undir.cpp b/example/remove_edge_if_undir.cpp index 7af8131b..3fc5b571 100644 --- a/example/remove_edge_if_undir.cpp +++ b/example/remove_edge_if_undir.cpp @@ -78,7 +78,7 @@ main() int w = 0; graph_traits::edge_iterator ei, ei_end; - for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) weight[*ei] = ++w; std::cout << "original graph:" << std::endl; diff --git a/example/roget_components.cpp b/example/roget_components.cpp index c5d2efa0..8a34f22e 100644 --- a/example/roget_components.cpp +++ b/example/roget_components.cpp @@ -72,12 +72,12 @@ int main(int argc, char* argv[]) // First add representative vertices to each component's list graph_traits::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) if (root[*vi] == *vi) strong_comp[comp[index_map[*vi]]].push_back(*vi); // Then add the other vertices of the component - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) if (root[*vi] != *vi) strong_comp[comp[index_map[*vi]]].push_back(*vi); @@ -117,7 +117,7 @@ int main(int argc, char* argv[]) for (i = 0; i < strong_comp[c].size(); ++i) { vertex_t v = strong_comp[c][i]; graph_traits::out_edge_iterator ei, ei_end; - for (tie(ei, ei_end) = out_edges(v, g); ei != ei_end; ++ei) { + for (boost::tie(ei, ei_end) = out_edges(v, g); ei != ei_end; ++ei) { vertex_t x = target(*ei, g); int comp_x = comp[index_map[x]]; if (comp_x != c && mark[comp_x] != c) { diff --git a/example/scc.cpp b/example/scc.cpp index 0851d321..e34fe582 100644 --- a/example/scc.cpp +++ b/example/scc.cpp @@ -29,7 +29,7 @@ main() std::string color[] = { "white", "gray", "black", "lightgray"}; graph_traits < GraphvizDigraph >::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { vertex_attr_map[*vi]["color"] = color[component[*vi]]; vertex_attr_map[*vi]["style"] = "filled"; if (vertex_attr_map[*vi]["color"] == "black") diff --git a/example/subgraph.cpp b/example/subgraph.cpp index 25db1960..a28a6cab 100644 --- a/example/subgraph.cpp +++ b/example/subgraph.cpp @@ -77,7 +77,7 @@ int main(int,char*[]) Graph::children_iterator ci, ci_end; int num = 1; - for (tie(ci, ci_end) = G0.children(); ci != ci_end; ++ci) { + for (boost::tie(ci, ci_end) = G0.children(); ci != ci_end; ++ci) { std::cout << "G" << num++ << ":" << std::endl; print_graph(*ci, get(vertex_index, *ci)); print_edges2(*ci, get(vertex_index, *ci), get(edge_index, *ci)); diff --git a/example/tiernan_girth_circumference.cpp b/example/tiernan_girth_circumference.cpp index 06a996ab..a277a3fd 100644 --- a/example/tiernan_girth_circumference.cpp +++ b/example/tiernan_girth_circumference.cpp @@ -29,7 +29,7 @@ main(int argc, char *argv[]) // Compute the girth and circumference simulataneously size_t girth, circ; - tie(girth, circ) = tiernan_girth_and_circumference(g); + boost::tie(girth, circ) = tiernan_girth_and_circumference(g); // Print the result cout << "girth: " << girth << endl; diff --git a/example/topo-sort-file-dep.cpp b/example/topo-sort-file-dep.cpp index 21d0d326..98cca5f0 100644 --- a/example/topo-sort-file-dep.cpp +++ b/example/topo-sort-file-dep.cpp @@ -38,7 +38,7 @@ topo_sort_dfs(const file_dep_graph & g, vertex_t u, vertex_t * &topo_order, { mark[u] = 1; // 1 means visited, 0 means not yet visited graph_traits < file_dep_graph >::adjacency_iterator vi, vi_end; - for (tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = adjacent_vertices(u, g); vi != vi_end; ++vi) if (mark[*vi] == 0) topo_sort_dfs(g, *vi, topo_order, mark); @@ -50,7 +50,7 @@ topo_sort(const file_dep_graph & g, vertex_t * topo_order) { std::vector < int >mark(num_vertices(g), 0); graph_traits < file_dep_graph >::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) if (mark[*vi] == 0) topo_sort_dfs(g, *vi, topo_order, &mark[0]); } @@ -70,7 +70,7 @@ main() file_dep_graph g(n_vertices); while (input_begin != input_end) { size_type i, j; - tie(i, j) = *input_begin++; + boost::tie(i, j) = *input_begin++; add_edge(i, j, g); } #else @@ -80,7 +80,7 @@ main() std::vector < std::string > name(num_vertices(g)); std::ifstream name_in("makefile-target-names.dat"); graph_traits < file_dep_graph >::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) name_in >> name[*vi]; std::vector < vertex_t > order(num_vertices(g)); diff --git a/example/topo-sort-file-dep2.cpp b/example/topo-sort-file-dep2.cpp index 05024761..5d9f2098 100644 --- a/example/topo-sort-file-dep2.cpp +++ b/example/topo-sort-file-dep2.cpp @@ -42,7 +42,7 @@ dfs_v1(const file_dep_graph & g, vertex_t u, default_color_type * color, color[u] = gray_color; vis.discover_vertex(u, g); graph_traits < file_dep_graph >::out_edge_iterator ei, ei_end; - for (tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) { + for (boost::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) { if (color[target(*ei, g)] == white_color) { vis.tree_edge(*ei, g); dfs_v1(g, target(*ei, g), color, vis); @@ -60,7 +60,7 @@ generic_dfs_v1(const file_dep_graph & g, Visitor vis) { std::vector < default_color_type > color(num_vertices(g), white_color); graph_traits < file_dep_graph >::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { if (color[*vi] == white_color) dfs_v1(g, *vi, &color[0], vis); } @@ -130,7 +130,7 @@ main() file_dep_graph g(n_vertices); while (input_begin != input_end) { size_type i, j; - tie(i, j) = *input_begin++; + boost::tie(i, j) = *input_begin++; add_edge(i, j, g); } #else @@ -140,7 +140,7 @@ main() std::vector < std::string > name(num_vertices(g)); std::ifstream name_in("makefile-target-names.dat"); graph_traits < file_dep_graph >::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) name_in >> name[*vi]; std::vector < vertex_t > order(num_vertices(g)); diff --git a/example/transpose-example.cpp b/example/transpose-example.cpp index 0231027f..252901bb 100644 --- a/example/transpose-example.cpp +++ b/example/transpose-example.cpp @@ -25,7 +25,7 @@ main() name_map = get(vertex_name, G); char name = 'a'; graph_traits < graph_t >::vertex_iterator v, v_end; - for (tie(v, v_end) = vertices(G); v != v_end; ++v, ++name) + for (boost::tie(v, v_end) = vertices(G); v != v_end; ++v, ++name) name_map[*v] = name; typedef std::pair < int, int >E; @@ -44,7 +44,7 @@ main() print_graph(G_T, name_map); graph_traits < graph_t >::edge_iterator ei, ei_end; - for (tie(ei, ei_end) = edges(G); ei != ei_end; ++ei) + for (boost::tie(ei, ei_end) = edges(G); ei != ei_end; ++ei) assert(edge(target(*ei, G), source(*ei, G), G_T).second == true); return 0; } diff --git a/example/undirected.cpp b/example/undirected.cpp index 49a7ed7d..97b14d99 100644 --- a/example/undirected.cpp +++ b/example/undirected.cpp @@ -27,10 +27,10 @@ undirected_graph_demo1() add_edge(one, two, undigraph); std::cout << "out_edges(0): "; - for (tie(out, out_end) = out_edges(zero, undigraph); out != out_end; ++out) + for (boost::tie(out, out_end) = out_edges(zero, undigraph); out != out_end; ++out) std::cout << *out; std::cout << std::endl << "in_edges(0): "; - for (tie(in, in_end) = in_edges(zero, undigraph); in != in_end; ++in) + for (boost::tie(in, in_end) = in_edges(zero, undigraph); in != in_end; ++in) std::cout << *in; std::cout << std::endl; } @@ -51,8 +51,8 @@ directed_graph_demo() v = vertex(1, digraph); add_edge(u, v, Weight(1.2), digraph); add_edge(v, u, Weight(2.4), digraph); - tie(e1, found) = edge(u, v, digraph); - tie(e2, found) = edge(v, u, digraph); + boost::tie(e1, found) = edge(u, v, digraph); + boost::tie(e2, found) = edge(v, u, digraph); std::cout << "in a directed graph is "; #ifdef __GNUC__ // no boolalpha @@ -80,8 +80,8 @@ undirected_graph_demo2() u = vertex(0, undigraph); v = vertex(1, undigraph); add_edge(u, v, Weight(3.1), undigraph); - tie(e1, found) = edge(u, v, undigraph); - tie(e2, found) = edge(v, u, undigraph); + boost::tie(e1, found) = edge(u, v, undigraph); + boost::tie(e2, found) = edge(v, u, undigraph); std::cout << "in an undirected graph is "; #ifdef __GNUC__ std::cout << "(u,v) == (v,u) ? " << (e1 == e2) << std::endl; diff --git a/include/boost/graph/adj_list_serialize.hpp b/include/boost/graph/adj_list_serialize.hpp index af0c0d89..c1ff4111 100644 --- a/include/boost/graph/adj_list_serialize.hpp +++ b/include/boost/graph/adj_list_serialize.hpp @@ -92,7 +92,7 @@ inline void load( ar >> BOOST_SERIALIZATION_NVP(u); ar >> BOOST_SERIALIZATION_NVP(v); Edge e; bool inserted; - tie(e,inserted) = add_edge(verts[u], verts[v], graph); + boost::tie(e,inserted) = add_edge(verts[u], verts[v], graph); ar >> serialization::make_nvp("edge_property", get(edge_all_t(), graph, e) ); } } diff --git a/include/boost/graph/adjacency_matrix.hpp b/include/boost/graph/adjacency_matrix.hpp index a3694dab..e841333b 100644 --- a/include/boost/graph/adjacency_matrix.hpp +++ b/include/boost/graph/adjacency_matrix.hpp @@ -766,7 +766,7 @@ namespace boost { { typename adjacency_matrix::degree_size_type n = 0; typename adjacency_matrix::out_edge_iterator f, l; - for (tie(f, l) = out_edges(u, g); f != l; ++f) + for (boost::tie(f, l) = out_edges(u, g); f != l; ++f) ++n; return n; } @@ -848,7 +848,7 @@ namespace boost { { typename adjacency_matrix::degree_size_type n = 0; typename adjacency_matrix::in_edge_iterator f, l; - for (tie(f, l) = in_edges(u, g); f != l; ++f) + for (boost::tie(f, l) = in_edges(u, g); f != l; ++f) ++n; return n; } @@ -1017,9 +1017,9 @@ namespace boost { { typename adjacency_matrix::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) remove_edge(u, *vi, g); - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) remove_edge(*vi, u, g); } @@ -1032,7 +1032,7 @@ namespace boost { { typename adjacency_matrix::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) remove_edge(u, *vi, g); } diff --git a/include/boost/graph/astar_search.hpp b/include/boost/graph/astar_search.hpp index 47474337..cd312f2e 100644 --- a/include/boost/graph/astar_search.hpp +++ b/include/boost/graph/astar_search.hpp @@ -83,18 +83,18 @@ namespace boost { : bfs_visitor(vis) {} template - void edge_relaxed(Edge e, Graph& g) { + void edge_relaxed(Edge e, const Graph& g) { invoke_visitors(this->m_vis, e, g, on_edge_relaxed()); } template - void edge_not_relaxed(Edge e, Graph& g) { + void edge_not_relaxed(Edge e, const Graph& g) { invoke_visitors(this->m_vis, e, g, on_edge_not_relaxed()); } private: template - void tree_edge(Edge e, Graph& g) {} + void tree_edge(Edge e, const Graph& g) {} template - void non_tree_edge(Edge e, Graph& g) {} + void non_tree_edge(Edge e, const Graph& g) {} }; template astar_visitor @@ -130,34 +130,34 @@ namespace boost { template - void initialize_vertex(Vertex u, Graph& g) { + void initialize_vertex(Vertex u, const Graph& g) { m_vis.initialize_vertex(u, g); } template - void discover_vertex(Vertex u, Graph& g) { + void discover_vertex(Vertex u, const Graph& g) { m_vis.discover_vertex(u, g); } template - void examine_vertex(Vertex u, Graph& g) { + void examine_vertex(Vertex u, const Graph& g) { m_vis.examine_vertex(u, g); } template - void finish_vertex(Vertex u, Graph& g) { + void finish_vertex(Vertex u, const Graph& g) { m_vis.finish_vertex(u, g); } template - void examine_edge(Edge e, Graph& g) { + void examine_edge(Edge e, const Graph& g) { if (m_compare(get(m_weight, e), m_zero)) BOOST_THROW_EXCEPTION(negative_edge()); m_vis.examine_edge(e, g); } template - void non_tree_edge(Edge, Graph&) {} + void non_tree_edge(Edge, const Graph&) {} template - void tree_edge(Edge e, Graph& g) { + void tree_edge(Edge e, const Graph& g) { m_decreased = relax(e, g, m_weight, m_predecessor, m_distance, m_combine, m_compare); @@ -172,7 +172,7 @@ namespace boost { template - void gray_target(Edge e, Graph& g) { + void gray_target(Edge e, const Graph& g) { m_decreased = relax(e, g, m_weight, m_predecessor, m_distance, m_combine, m_compare); @@ -188,7 +188,7 @@ namespace boost { template - void black_target(Edge e, Graph& g) { + void black_target(Edge e, const Graph& g) { m_decreased = relax(e, g, m_weight, m_predecessor, m_distance, m_combine, m_compare); @@ -234,7 +234,7 @@ namespace boost { typename CostInf, typename CostZero> inline void astar_search_no_init - (VertexListGraph &g, + (const VertexListGraph &g, typename graph_traits::vertex_descriptor s, AStarHeuristic h, AStarVisitor vis, PredecessorMap predecessor, CostMap cost, @@ -271,7 +271,7 @@ namespace boost { typename CostInf, typename CostZero> inline void astar_search - (VertexListGraph &g, + (const VertexListGraph &g, typename graph_traits::vertex_descriptor s, AStarHeuristic h, AStarVisitor vis, PredecessorMap predecessor, CostMap cost, @@ -284,7 +284,7 @@ namespace boost { typedef typename property_traits::value_type ColorValue; typedef color_traits Color; typename graph_traits::vertex_iterator ui, ui_end; - for (tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui) { + for (boost::tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui) { put(color, *ui, Color::white()); put(distance, *ui, inf); put(cost, *ui, inf); @@ -308,7 +308,7 @@ namespace boost { class IndexMap, class ColorMap, class Params> inline void astar_dispatch2 - (VertexListGraph& g, + (const VertexListGraph& g, typename graph_traits::vertex_descriptor s, AStarHeuristic h, CostMap cost, DistanceMap distance, WeightMap weight, IndexMap index_map, ColorMap color, @@ -337,16 +337,13 @@ namespace boost { class IndexMap, class ColorMap, class Params> inline void astar_dispatch1 - (VertexListGraph& g, + (const VertexListGraph& g, typename graph_traits::vertex_descriptor s, AStarHeuristic h, CostMap cost, DistanceMap distance, WeightMap weight, IndexMap index_map, ColorMap color, const Params& params) { typedef typename property_traits::value_type D; - std::vector distance_map; - std::vector cost_map; - std::vector color_map; detail::astar_dispatch2 (g, s, h, @@ -365,7 +362,7 @@ namespace boost { typename P, typename T, typename R> void astar_search - (VertexListGraph &g, + (const VertexListGraph &g, typename graph_traits::vertex_descriptor s, AStarHeuristic h, const bgl_named_params& params) { diff --git a/include/boost/graph/bandwidth.hpp b/include/boost/graph/bandwidth.hpp index ea44b317..0bfeefb9 100644 --- a/include/boost/graph/bandwidth.hpp +++ b/include/boost/graph/bandwidth.hpp @@ -24,7 +24,7 @@ namespace boost { typedef typename graph_traits::vertices_size_type size_type; size_type b = 0; typename graph_traits::out_edge_iterator e, end; - for (tie(e, end) = out_edges(i, g); e != end; ++e) { + for (boost::tie(e, end) = out_edges(i, g); e != end; ++e) { int f_i = get(index, i); int f_j = get(index, target(*e, g)); using namespace std; // to call abs() unqualified @@ -49,7 +49,7 @@ namespace boost { BOOST_USING_STD_MAX(); typename graph_traits::vertices_size_type b = 0; typename graph_traits::vertex_iterator i, end; - for (tie(i, end) = vertices(g); i != end; ++i) + for (boost::tie(i, end) = vertices(g); i != end; ++i) b = max BOOST_PREVENT_MACRO_SUBSTITUTION (b, ith_bandwidth(*i, g, index)); return b; } @@ -69,7 +69,7 @@ namespace boost { typedef typename detail::numeric_traits::difference_type diff_t; size_type sum = 0; typename graph_traits::edge_iterator i, end; - for (tie(i, end) = edges(g); i != end; ++i) { + for (boost::tie(i, end) = edges(g); i != end; ++i) { diff_t f_u = get(index_map, source(*i, g)); diff_t f_v = get(index_map, target(*i, g)); using namespace std; // to call abs() unqualified diff --git a/include/boost/graph/bellman_ford_shortest_paths.hpp b/include/boost/graph/bellman_ford_shortest_paths.hpp index 4001c288..8fc02529 100644 --- a/include/boost/graph/bellman_ford_shortest_paths.hpp +++ b/include/boost/graph/bellman_ford_shortest_paths.hpp @@ -108,7 +108,7 @@ namespace boost { for (Size k = 0; k < N; ++k) { bool at_least_one_edge_relaxed = false; - for (tie(i, end) = edges(g); i != end; ++i) { + for (boost::tie(i, end) = edges(g); i != end; ++i) { v.examine_edge(*i, g); if (relax(*i, g, weight, pred, distance, combine, compare)) { at_least_one_edge_relaxed = true; @@ -120,7 +120,7 @@ namespace boost { break; } - for (tie(i, end) = edges(g); i != end; ++i) + for (boost::tie(i, end) = edges(g); i != end; ++i) if (compare(combine(get(distance, source(*i, g)), get(weight, *i)), get(distance, target(*i,g)))) { @@ -148,7 +148,7 @@ namespace boost { bellman_visitor<> null_vis; typedef typename property_traits::value_type weight_type; typename graph_traits::vertex_iterator v, v_end; - for (tie(v, v_end) = vertices(g); v != v_end; ++v) { + for (boost::tie(v, v_end) = vertices(g); v != v_end; ++v) { put(distance, *v, (std::numeric_limits::max)()); put(pred, *v, *v); } diff --git a/include/boost/graph/betweenness_centrality.hpp b/include/boost/graph/betweenness_centrality.hpp index 06b7be06..052f0633 100644 --- a/include/boost/graph/betweenness_centrality.hpp +++ b/include/boost/graph/betweenness_centrality.hpp @@ -305,10 +305,10 @@ namespace detail { namespace graph { std::stack ordered_vertices; vertex_iterator s, s_end; - for (tie(s, s_end) = vertices(g); s != s_end; ++s) { + for (boost::tie(s, s_end) = vertices(g); s != s_end; ++s) { // Initialize for this iteration vertex_iterator w, w_end; - for (tie(w, w_end) = vertices(g); w != w_end; ++w) { + for (boost::tie(w, w_end) = vertices(g); w != w_end; ++w) { incoming[*w].clear(); put(path_count, *w, 0); put(dependency, *w, 0); @@ -581,7 +581,7 @@ relative_betweenness_centrality(const Graph& g, CentralityMap centrality) typename graph_traits::vertices_size_type n = num_vertices(g); centrality_type factor = centrality_type(2)/centrality_type(n*n - 3*n + 2); vertex_iterator v, v_end; - for (tie(v, v_end) = vertices(g); v != v_end; ++v) { + for (boost::tie(v, v_end) = vertices(g); v != v_end; ++v) { put(centrality, *v, factor * get(centrality, *v)); } } @@ -602,13 +602,13 @@ central_point_dominance(const Graph& g, CentralityMap centrality // Find max centrality centrality_type max_centrality(0); vertex_iterator v, v_end; - for (tie(v, v_end) = vertices(g); v != v_end; ++v) { + for (boost::tie(v, v_end) = vertices(g); v != v_end; ++v) { max_centrality = (max)(max_centrality, get(centrality, *v)); } // Compute central point dominance centrality_type sum(0); - for (tie(v, v_end) = vertices(g); v != v_end; ++v) { + for (boost::tie(v, v_end) = vertices(g); v != v_end; ++v) { sum += (max_centrality - get(centrality, *v)); } return sum/(n-1); diff --git a/include/boost/graph/bipartite.hpp b/include/boost/graph/bipartite.hpp index 90cff6fe..f902fd3e 100644 --- a/include/boost/graph/bipartite.hpp +++ b/include/boost/graph/bipartite.hpp @@ -291,7 +291,7 @@ namespace boost { predecessor_recorder_t predecessor_recorder (predecessor_map); /// Initialize predecessor map - for (tie (vertex_iter, vertex_end) = vertices (graph); vertex_iter != vertex_end; ++vertex_iter) + for (boost::tie (vertex_iter, vertex_end) = vertices (graph); vertex_iter != vertex_end; ++vertex_iter) { put (predecessor_map, *vertex_iter, *vertex_iter); } diff --git a/include/boost/graph/boykov_kolmogorov_max_flow.hpp b/include/boost/graph/boykov_kolmogorov_max_flow.hpp new file mode 100644 index 00000000..8559bd77 --- /dev/null +++ b/include/boost/graph/boykov_kolmogorov_max_flow.hpp @@ -0,0 +1,866 @@ +// Copyright (c) 2006, Stephan Diederich +// +// This code may be used under either of the following two licences: +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. OF SUCH DAMAGE. +// +// Or: +// +// 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_BOYKOV_KOLMOGOROV_MAX_FLOW_HPP +#define BOOST_BOYKOV_KOLMOGOROV_MAX_FLOW_HPP + +#include +#include +#include +#include +#include +#include +#include // for std::min and std::max + +#include +#include +#include +#include +#include +#include +#include + +// The algorithm impelemented here is described in: +// +// Boykov, Y., Kolmogorov, V. "An Experimental Comparison of Min-Cut/Max-Flow +// Algorithms for Energy Minimization in Vision", In IEEE Transactions on +// Pattern Analysis and Machine Intelligence, vol. 26, no. 9, pp. 1124-1137, +// Sep 2004. +// +// For further reading, also see: +// +// Kolmogorov, V. "Graph Based Algorithms for Scene Reconstruction from Two or +// More Views". PhD thesis, Cornell University, Sep 2003. + +namespace boost { + +namespace detail { + +template +class bk_max_flow { + typedef typename property_traits::value_type tEdgeVal; + typedef graph_traits tGraphTraits; + typedef typename tGraphTraits::vertex_iterator vertex_iterator; + typedef typename tGraphTraits::vertex_descriptor vertex_descriptor; + typedef typename tGraphTraits::edge_descriptor edge_descriptor; + typedef typename tGraphTraits::edge_iterator edge_iterator; + typedef typename tGraphTraits::out_edge_iterator out_edge_iterator; + typedef boost::queue tQueue; //queue of vertices, used in adoption-stage + typedef typename property_traits::value_type tColorValue; + typedef color_traits tColorTraits; + typedef typename property_traits::value_type tDistanceVal; + + public: + bk_max_flow(Graph& g, + EdgeCapacityMap cap, + ResidualCapacityEdgeMap res, + ReverseEdgeMap rev, + PredecessorMap pre, + ColorMap color, + DistanceMap dist, + IndexMap idx, + vertex_descriptor src, + vertex_descriptor sink): + m_g(g), + m_index_map(idx), + m_cap_map(cap), + m_res_cap_map(res), + m_rev_edge_map(rev), + m_pre_map(pre), + m_tree_map(color), + m_dist_map(dist), + m_source(src), + m_sink(sink), + m_active_nodes(), + m_in_active_list_vec(num_vertices(g), false), + m_in_active_list_map(make_iterator_property_map(m_in_active_list_vec.begin(), m_index_map)), + m_has_parent_vec(num_vertices(g), false), + m_has_parent_map(make_iterator_property_map(m_has_parent_vec.begin(), m_index_map)), + m_time_vec(num_vertices(g), 0), + m_time_map(make_iterator_property_map(m_time_vec.begin(), m_index_map)), + m_flow(0), + m_time(1), + m_last_grow_vertex(graph_traits::null_vertex()){ + // initialize the color-map with gray-values + vertex_iterator vi, v_end; + for(boost::tie(vi, v_end) = vertices(m_g); vi != v_end; ++vi){ + set_tree(*vi, tColorTraits::gray()); + } + // Initialize flow to zero which means initializing + // the residual capacity equal to the capacity + edge_iterator ei, e_end; + for(boost::tie(ei, e_end) = edges(m_g); ei != e_end; ++ei) { + m_res_cap_map[*ei] = m_cap_map[*ei]; + assert(m_rev_edge_map[m_rev_edge_map[*ei]] == *ei); //check if the reverse edge map is build up properly + } + //init the search trees with the two terminals + set_tree(m_source, tColorTraits::black()); + set_tree(m_sink, tColorTraits::white()); + m_time_map[m_source] = 1; + m_time_map[m_sink] = 1; + } + + tEdgeVal max_flow(){ + //augment direct paths from SOURCE->SINK and SOURCE->VERTEX->SINK + augment_direct_paths(); + //start the main-loop + while(true){ + bool path_found; + edge_descriptor connecting_edge; + boost::tie(connecting_edge, path_found) = grow(); //find a path from source to sink + if(!path_found){ + //we're finished, no more paths were found + break; + } + ++m_time; + augment(connecting_edge); //augment that path + adopt(); //rebuild search tree structure + } + return m_flow; + } + + // the complete class is protected, as we want access to members in + // derived test-class (see test/boykov_kolmogorov_max_flow_test.cpp) + protected: + void augment_direct_paths(){ + // in a first step, we augment all direct paths from source->NODE->sink + // and additionally paths from source->sink. This improves especially + // graphcuts for segmentation, as most of the nodes have source/sink + // connects but shouldn't have an impact on other maxflow problems + // (this is done in grow() anyway) + out_edge_iterator ei, e_end; + for(boost::tie(ei, e_end) = out_edges(m_source, m_g); ei != e_end; ++ei){ + edge_descriptor from_source = *ei; + vertex_descriptor current_node = target(from_source, m_g); + if(current_node == m_sink){ + tEdgeVal cap = m_res_cap_map[from_source]; + m_res_cap_map[from_source] = 0; + m_flow += cap; + continue; + } + edge_descriptor to_sink; + bool is_there; + boost::tie(to_sink, is_there) = lookup_edge(current_node, m_sink, m_g); + if(is_there){ + tEdgeVal cap_from_source = m_res_cap_map[from_source]; + tEdgeVal cap_to_sink = m_res_cap_map[to_sink]; + if(cap_from_source > cap_to_sink){ + set_tree(current_node, tColorTraits::black()); + add_active_node(current_node); + set_edge_to_parent(current_node, from_source); + m_dist_map[current_node] = 1; + m_time_map[current_node] = 1; + // add stuff to flow and update residuals. we dont need to + // update reverse_edges, as incoming/outgoing edges to/from + // source/sink don't count for max-flow + m_res_cap_map[from_source] -= cap_to_sink; + m_res_cap_map[to_sink] = 0; + m_flow += cap_to_sink; + } else if(cap_to_sink > 0){ + set_tree(current_node, tColorTraits::white()); + add_active_node(current_node); + set_edge_to_parent(current_node, to_sink); + m_dist_map[current_node] = 1; + m_time_map[current_node] = 1; + // add stuff to flow and update residuals. we dont need to update + // reverse_edges, as incoming/outgoing edges to/from source/sink + // don't count for max-flow + m_res_cap_map[to_sink] -= cap_from_source; + m_res_cap_map[from_source] = 0; + m_flow += cap_from_source; + } + } else if(m_res_cap_map[from_source]){ + // there is no sink connect, so we can't augment this path, but to + // avoid adding m_source to the active nodes, we just activate this + // node and set the approciate things + set_tree(current_node, tColorTraits::black()); + set_edge_to_parent(current_node, from_source); + m_dist_map[current_node] = 1; + m_time_map[current_node] = 1; + add_active_node(current_node); + } + } + for(boost::tie(ei, e_end) = out_edges(m_sink, m_g); ei != e_end; ++ei){ + edge_descriptor to_sink = m_rev_edge_map[*ei]; + vertex_descriptor current_node = source(to_sink, m_g); + if(m_res_cap_map[to_sink]){ + set_tree(current_node, tColorTraits::white()); + set_edge_to_parent(current_node, to_sink); + m_dist_map[current_node] = 1; + m_time_map[current_node] = 1; + add_active_node(current_node); + } + } + } + + /** + * Returns a pair of an edge and a boolean. if the bool is true, the + * edge is a connection of a found path from s->t , read "the link" and + * source(returnVal, m_g) is the end of the path found in the source-tree + * target(returnVal, m_g) is the beginning of the path found in the sink-tree + */ + std::pair grow(){ + assert(m_orphans.empty()); + vertex_descriptor current_node; + while((current_node = get_next_active_node()) != graph_traits::null_vertex()){ //if there is one + assert(get_tree(current_node) != tColorTraits::gray() && + (has_parent(current_node) || + current_node == m_source || + current_node == m_sink)); + + if(get_tree(current_node) == tColorTraits::black()){ + //source tree growing + out_edge_iterator ei, e_end; + if(current_node != m_last_grow_vertex){ + m_last_grow_vertex = current_node; + boost::tie(m_last_grow_edge_it, m_last_grow_edge_end) = out_edges(current_node, m_g); + } + for(; m_last_grow_edge_it != m_last_grow_edge_end; ++m_last_grow_edge_it) { + edge_descriptor out_edge = *m_last_grow_edge_it; + if(m_res_cap_map[out_edge] > 0){ //check if we have capacity left on this edge + vertex_descriptor other_node = target(out_edge, m_g); + if(get_tree(other_node) == tColorTraits::gray()){ //it's a free node + set_tree(other_node, tColorTraits::black()); //aquire other node to our search tree + set_edge_to_parent(other_node, out_edge); //set us as parent + m_dist_map[other_node] = m_dist_map[current_node] + 1; //and update the distance-heuristic + m_time_map[other_node] = m_time_map[current_node]; + add_active_node(other_node); + } else if(get_tree(other_node) == tColorTraits::black()) { + // we do this to get shorter paths. check if we are nearer to + // the source as its parent is + if(is_closer_to_terminal(current_node, other_node)){ + set_edge_to_parent(other_node, out_edge); + m_dist_map[other_node] = m_dist_map[current_node] + 1; + m_time_map[other_node] = m_time_map[current_node]; + } + } else{ + assert(get_tree(other_node)==tColorTraits::white()); + //kewl, found a path from one to the other search tree, return + // the connecting edge in src->sink dir + return std::make_pair(out_edge, true); + } + } + } //for all out-edges + } //source-tree-growing + else{ + assert(get_tree(current_node) == tColorTraits::white()); + out_edge_iterator ei, e_end; + if(current_node != m_last_grow_vertex){ + m_last_grow_vertex = current_node; + boost::tie(m_last_grow_edge_it, m_last_grow_edge_end) = out_edges(current_node, m_g); + } + for(; m_last_grow_edge_it != m_last_grow_edge_end; ++m_last_grow_edge_it){ + edge_descriptor in_edge = m_rev_edge_map[*m_last_grow_edge_it]; + if(m_res_cap_map[in_edge] > 0){ //check if there is capacity left + vertex_descriptor other_node = source(in_edge, m_g); + if(get_tree(other_node) == tColorTraits::gray()){ //it's a free node + set_tree(other_node, tColorTraits::white()); //aquire that node to our search tree + set_edge_to_parent(other_node, in_edge); //set us as parent + add_active_node(other_node); //activate that node + m_dist_map[other_node] = m_dist_map[current_node] + 1; //set its distance + m_time_map[other_node] = m_time_map[current_node]; //and time + } else if(get_tree(other_node) == tColorTraits::white()){ + if(is_closer_to_terminal(current_node, other_node)){ + //we are closer to the sink than its parent is, so we "adopt" him + set_edge_to_parent(other_node, in_edge); + m_dist_map[other_node] = m_dist_map[current_node] + 1; + m_time_map[other_node] = m_time_map[current_node]; + } + } else{ + assert(get_tree(other_node)==tColorTraits::black()); + //kewl, found a path from one to the other search tree, + // return the connecting edge in src->sink dir + return std::make_pair(in_edge, true); + } + } + } //for all out-edges + } //sink-tree growing + + //all edges of that node are processed, and no more paths were found. + // remove if from the front of the active queue + finish_node(current_node); + } //while active_nodes not empty + + //no active nodes anymore and no path found, we're done + return std::make_pair(edge_descriptor(), false); + } + + /** + * augments path from s->t and updates residual graph + * source(e, m_g) is the end of the path found in the source-tree + * target(e, m_g) is the beginning of the path found in the sink-tree + * this phase generates orphans on satured edges, if the attached verts are + * from different search-trees orphans are ordered in distance to + * sink/source. first the farest from the source are front_inserted into + * the orphans list, and after that the sink-tree-orphans are + * front_inserted. when going to adoption stage the orphans are popped_front, + * and so we process the nearest verts to the terminals first + */ + void augment(edge_descriptor e) { + assert(get_tree(target(e, m_g)) == tColorTraits::white()); + assert(get_tree(source(e, m_g)) == tColorTraits::black()); + assert(m_orphans.empty()); + + const tEdgeVal bottleneck = find_bottleneck(e); + //now we push the found flow through the path + //for each edge we saturate we have to look for the verts that belong to that edge, one of them becomes an orphans + //now process the connecting edge + m_res_cap_map[e] -= bottleneck; + assert(m_res_cap_map[e] >= 0); + m_res_cap_map[m_rev_edge_map[e]] += bottleneck; + + //now we follow the path back to the source + vertex_descriptor current_node = source(e, m_g); + while(current_node != m_source){ + edge_descriptor pred = get_edge_to_parent(current_node); + m_res_cap_map[pred] -= bottleneck; + assert(m_res_cap_map[pred] >= 0); + m_res_cap_map[m_rev_edge_map[pred]] += bottleneck; + if(m_res_cap_map[pred] == 0){ + set_no_parent(current_node); + m_orphans.push_front(current_node); + } + current_node = source(pred, m_g); + } + //then go forward in the sink-tree + current_node = target(e, m_g); + while(current_node != m_sink){ + edge_descriptor pred = get_edge_to_parent(current_node); + m_res_cap_map[pred] -= bottleneck; + assert(m_res_cap_map[pred] >= 0); + m_res_cap_map[m_rev_edge_map[pred]] += bottleneck; + if(m_res_cap_map[pred] == 0){ + set_no_parent(current_node); + m_orphans.push_front(current_node); + } + current_node = target(pred, m_g); + } + //and add it to the max-flow + m_flow += bottleneck; + } + + /** + * returns the bottleneck of a s->t path (end_of_path is last vertex in + * source-tree, begin_of_path is first vertex in sink-tree) + */ + inline tEdgeVal find_bottleneck(edge_descriptor e){ + BOOST_USING_STD_MIN(); + tEdgeVal minimum_cap = m_res_cap_map[e]; + vertex_descriptor current_node = source(e, m_g); + //first go back in the source tree + while(current_node != m_source){ + edge_descriptor pred = get_edge_to_parent(current_node); + minimum_cap = min BOOST_PREVENT_MACRO_SUBSTITUTION(minimum_cap, m_res_cap_map[pred]); + current_node = source(pred, m_g); + } + //then go forward in the sink-tree + current_node = target(e, m_g); + while(current_node != m_sink){ + edge_descriptor pred = get_edge_to_parent(current_node); + minimum_cap = min BOOST_PREVENT_MACRO_SUBSTITUTION(minimum_cap, m_res_cap_map[pred]); + current_node = target(pred, m_g); + } + return minimum_cap; + } + + /** + * rebuild search trees + * empty the queue of orphans, and find new parents for them or just drop + * them from the search trees + */ + void adopt(){ + while(!m_orphans.empty() || !m_child_orphans.empty()){ + vertex_descriptor current_node; + if(m_child_orphans.empty()){ + //get the next orphan from the main-queue and remove it + current_node = m_orphans.front(); + m_orphans.pop_front(); + } else{ + current_node = m_child_orphans.front(); + m_child_orphans.pop(); + } + if(get_tree(current_node) == tColorTraits::black()){ + //we're in the source-tree + tDistanceVal min_distance = (std::numeric_limits::max)(); + edge_descriptor new_parent_edge; + out_edge_iterator ei, e_end; + for(boost::tie(ei, e_end) = out_edges(current_node, m_g); ei != e_end; ++ei){ + const edge_descriptor in_edge = m_rev_edge_map[*ei]; + assert(target(in_edge, m_g) == current_node); //we should be the target of this edge + if(m_res_cap_map[in_edge] > 0){ + vertex_descriptor other_node = source(in_edge, m_g); + if(get_tree(other_node) == tColorTraits::black() && has_source_connect(other_node)){ + if(m_dist_map[other_node] < min_distance){ + min_distance = m_dist_map[other_node]; + new_parent_edge = in_edge; + } + } + } + } + if(min_distance != (std::numeric_limits::max)()){ + set_edge_to_parent(current_node, new_parent_edge); + m_dist_map[current_node] = min_distance + 1; + m_time_map[current_node] = m_time; + } else{ + m_time_map[current_node] = 0; + for(boost::tie(ei, e_end) = out_edges(current_node, m_g); ei != e_end; ++ei){ + edge_descriptor in_edge = m_rev_edge_map[*ei]; + vertex_descriptor other_node = source(in_edge, m_g); + if(get_tree(other_node) == tColorTraits::black() && has_parent(other_node)){ + if(m_res_cap_map[in_edge] > 0){ + add_active_node(other_node); + } + if(source(get_edge_to_parent(other_node), m_g) == current_node){ + //we are the parent of that node + //it has to find a new parent, too + set_no_parent(other_node); + m_child_orphans.push(other_node); + } + } + } + set_tree(current_node, tColorTraits::gray()); + } //no parent found + } //source-tree-adoption + else{ + //now we should be in the sink-tree, check that... + assert(get_tree(current_node) == tColorTraits::white()); + out_edge_iterator ei, e_end; + edge_descriptor new_parent_edge; + tDistanceVal min_distance = (std::numeric_limits::max)(); + for(boost::tie(ei, e_end) = out_edges(current_node, m_g); ei != e_end; ++ei){ + const edge_descriptor out_edge = *ei; + if(m_res_cap_map[out_edge] > 0){ + const vertex_descriptor other_node = target(out_edge, m_g); + if(get_tree(other_node) == tColorTraits::white() && has_sink_connect(other_node)) + if(m_dist_map[other_node] < min_distance){ + min_distance = m_dist_map[other_node]; + new_parent_edge = out_edge; + } + } + } + if(min_distance != (std::numeric_limits::max)()){ + set_edge_to_parent(current_node, new_parent_edge); + m_dist_map[current_node] = min_distance + 1; + m_time_map[current_node] = m_time; + } else{ + m_time_map[current_node] = 0; + for(boost::tie(ei, e_end) = out_edges(current_node, m_g); ei != e_end; ++ei){ + const edge_descriptor out_edge = *ei; + const vertex_descriptor other_node = target(out_edge, m_g); + if(get_tree(other_node) == tColorTraits::white() && has_parent(other_node)){ + if(m_res_cap_map[out_edge] > 0){ + add_active_node(other_node); + } + if(target(get_edge_to_parent(other_node), m_g) == current_node){ + //we were it's parent, so it has to find a new one, too + set_no_parent(other_node); + m_child_orphans.push(other_node); + } + } + } + set_tree(current_node, tColorTraits::gray()); + } //no parent found + } //sink-tree adoption + } //while !orphans.empty() + } //adopt + + /** + * return next active vertex if there is one, otherwise a null_vertex + */ + inline vertex_descriptor get_next_active_node(){ + while(true){ + if(m_active_nodes.empty()) + return graph_traits::null_vertex(); + vertex_descriptor v = m_active_nodes.front(); + + //if it has no parent, this node can't be active (if its not source or sink) + if(!has_parent(v) && v != m_source && v != m_sink){ + m_active_nodes.pop(); + m_in_active_list_map[v] = false; + } else{ + assert(get_tree(v) == tColorTraits::black() || get_tree(v) == tColorTraits::white()); + return v; + } + } + } + + /** + * adds v as an active vertex, but only if its not in the list already + */ + inline void add_active_node(vertex_descriptor v){ + assert(get_tree(v) != tColorTraits::gray()); + if(m_in_active_list_map[v]){ + return; + } else{ + m_in_active_list_map[v] = true; + m_active_nodes.push(v); + } + } + + /** + * finish_node removes a node from the front of the active queue (its called in grow phase, if no more paths can be found using this node) + */ + inline void finish_node(vertex_descriptor v){ + assert(m_active_nodes.front() == v); + m_active_nodes.pop(); + m_in_active_list_map[v] = false; + m_last_grow_vertex = graph_traits::null_vertex(); + } + + /** + * removes a vertex from the queue of active nodes (actually this does nothing, + * but checks if this node has no parent edge, as this is the criteria for + * being no more active) + */ + inline void remove_active_node(vertex_descriptor v){ + assert(!has_parent(v)); + } + + /** + * returns the search tree of v; tColorValue::black() for source tree, + * white() for sink tree, gray() for no tree + */ + inline tColorValue get_tree(vertex_descriptor v) const { + return m_tree_map[v]; + } + + /** + * sets search tree of v; tColorValue::black() for source tree, white() + * for sink tree, gray() for no tree + */ + inline void set_tree(vertex_descriptor v, tColorValue t){ + m_tree_map[v] = t; + } + + /** + * returns edge to parent vertex of v; + */ + inline edge_descriptor get_edge_to_parent(vertex_descriptor v) const{ + return m_pre_map[v]; + } + + /** + * returns true if the edge stored in m_pre_map[v] is a valid entry + */ + inline bool has_parent(vertex_descriptor v) const{ + return m_has_parent_map[v]; + } + + /** + * sets edge to parent vertex of v; + */ + inline void set_edge_to_parent(vertex_descriptor v, edge_descriptor f_edge_to_parent){ + assert(m_res_cap_map[f_edge_to_parent] > 0); + m_pre_map[v] = f_edge_to_parent; + m_has_parent_map[v] = true; + } + + /** + * removes the edge to parent of v (this is done by invalidating the + * entry an additional map) + */ + inline void set_no_parent(vertex_descriptor v){ + m_has_parent_map[v] = false; + } + + /** + * checks if vertex v has a connect to the sink-vertex (@var m_sink) + * @param v the vertex which is checked + * @return true if a path to the sink was found, false if not + */ + inline bool has_sink_connect(vertex_descriptor v){ + tDistanceVal current_distance = 0; + vertex_descriptor current_vertex = v; + while(true){ + if(m_time_map[current_vertex] == m_time){ + //we found a node which was already checked this round. use it for distance calculations + current_distance += m_dist_map[current_vertex]; + break; + } + if(current_vertex == m_sink){ + m_time_map[m_sink] = m_time; + break; + } + if(has_parent(current_vertex)){ + //it has a parent, so get it + current_vertex = target(get_edge_to_parent(current_vertex), m_g); + ++current_distance; + } else{ + //no path found + return false; + } + } + current_vertex=v; + while(m_time_map[current_vertex] != m_time){ + m_dist_map[current_vertex] = current_distance--; + m_time_map[current_vertex] = m_time; + current_vertex = target(get_edge_to_parent(current_vertex), m_g); + } + return true; + } + + /** + * checks if vertex v has a connect to the source-vertex (@var m_source) + * @param v the vertex which is checked + * @return true if a path to the source was found, false if not + */ + inline bool has_source_connect(vertex_descriptor v){ + tDistanceVal current_distance = 0; + vertex_descriptor current_vertex = v; + while(true){ + if(m_time_map[current_vertex] == m_time){ + //we found a node which was already checked this round. use it for distance calculations + current_distance += m_dist_map[current_vertex]; + break; + } + if(current_vertex == m_source){ + m_time_map[m_source] = m_time; + break; + } + if(has_parent(current_vertex)){ + //it has a parent, so get it + current_vertex = source(get_edge_to_parent(current_vertex), m_g); + ++current_distance; + } else{ + //no path found + return false; + } + } + current_vertex=v; + while(m_time_map[current_vertex] != m_time){ + m_dist_map[current_vertex] = current_distance-- ; + m_time_map[current_vertex] = m_time; + current_vertex = source(get_edge_to_parent(current_vertex), m_g); + } + return true; + } + + /** + * returns true, if p is closer to a terminal than q + */ + inline bool is_closer_to_terminal(vertex_descriptor p, vertex_descriptor q){ + //checks the timestamps first, to build no cycles, and after that the real distance + return (m_time_map[q] <= m_time_map[p] && m_dist_map[q] > m_dist_map[p]+1); + } + + //////// + // member vars + //////// + Graph& m_g; + IndexMap m_index_map; + EdgeCapacityMap m_cap_map; + ResidualCapacityEdgeMap m_res_cap_map; + ReverseEdgeMap m_rev_edge_map; + PredecessorMap m_pre_map; //stores paths found in the growth stage + ColorMap m_tree_map; //maps each vertex into one of the two search tree or none (gray()) + DistanceMap m_dist_map; //stores distance to source/sink nodes + vertex_descriptor m_source; + vertex_descriptor m_sink; + + tQueue m_active_nodes; + std::vector m_in_active_list_vec; + iterator_property_map::iterator, IndexMap> m_in_active_list_map; + + std::list m_orphans; + tQueue m_child_orphans; // we use a second queuqe for child orphans, as they are FIFO processed + + std::vector m_has_parent_vec; + iterator_property_map::iterator, IndexMap> m_has_parent_map; + + std::vector m_time_vec; //timestamp of each node, used for sink/source-path calculations + iterator_property_map::iterator, IndexMap> m_time_map; + tEdgeVal m_flow; + long m_time; + vertex_descriptor m_last_grow_vertex; + out_edge_iterator m_last_grow_edge_it; + out_edge_iterator m_last_grow_edge_end; +}; + +} //namespace boost::detail + +/** + * non-named-parameter version, given everything + * this is the catch all version + */ +template +typename property_traits::value_type +boykov_kolmogorov_max_flow(Graph& g, + CapacityEdgeMap cap, + ResidualCapacityEdgeMap res_cap, + ReverseEdgeMap rev_map, + PredecessorMap pre_map, + ColorMap color, + DistanceMap dist, + IndexMap idx, + typename graph_traits::vertex_descriptor src, + typename graph_traits::vertex_descriptor sink) +{ + typedef typename graph_traits::vertex_descriptor vertex_descriptor; + typedef typename graph_traits::edge_descriptor edge_descriptor; + + //as this method is the last one before we instantiate the solver, we do the concept checks here + function_requires >(); //to have vertices(), num_vertices(), + function_requires >(); //to have edges() + function_requires >(); //to have source(), target() and out_edges() + function_requires >(); //read flow-values from edges + function_requires >(); //write flow-values to residuals + function_requires >(); //read out reverse edges + function_requires >(); //store predecessor there + function_requires >(); //write corresponding tree + function_requires >(); //write distance to source/sink + function_requires >(); //get index 0...|V|-1 + assert(num_vertices(g) >= 2 && src != sink); + + detail::bk_max_flow< + Graph, CapacityEdgeMap, ResidualCapacityEdgeMap, ReverseEdgeMap, + PredecessorMap, ColorMap, DistanceMap, IndexMap + > algo(g, cap, res_cap, rev_map, pre_map, color, dist, idx, src, sink); + + return algo.max_flow(); +} + +/** + * non-named-parameter version, given capacity, residucal_capacity, + * reverse_edges, and an index map. + */ +template +typename property_traits::value_type +boykov_kolmogorov_max_flow(Graph& g, + CapacityEdgeMap cap, + ResidualCapacityEdgeMap res_cap, + ReverseEdgeMap rev, + IndexMap idx, + typename graph_traits::vertex_descriptor src, + typename graph_traits::vertex_descriptor sink) +{ + typename graph_traits::vertices_size_type n_verts = num_vertices(g); + std::vector::edge_descriptor> predecessor_vec(n_verts); + std::vector color_vec(n_verts); + std::vector::vertices_size_type> distance_vec(n_verts); + return + boykov_kolmogorov_max_flow( + g, cap, res_cap, rev, + make_iterator_property_map(predecessor_vec.begin(), idx), + make_iterator_property_map(color_vec.begin(), idx), + make_iterator_property_map(distance_vec.begin(), idx), + idx, src, sink); +} + +/** + * non-named-parameter version, some given: capacity, residual_capacity, + * reverse_edges, color_map and an index map. Use this if you are interested in + * the minimum cut, as the color map provides that info. + */ +template +typename property_traits::value_type +boykov_kolmogorov_max_flow(Graph& g, + CapacityEdgeMap cap, + ResidualCapacityEdgeMap res_cap, + ReverseEdgeMap rev, + ColorMap color, + IndexMap idx, + typename graph_traits::vertex_descriptor src, + typename graph_traits::vertex_descriptor sink) +{ + typename graph_traits::vertices_size_type n_verts = num_vertices(g); + std::vector::edge_descriptor> predecessor_vec(n_verts); + std::vector::vertices_size_type> distance_vec(n_verts); + return + boykov_kolmogorov_max_flow( + g, cap, res_cap, rev, + make_iterator_property_map(predecessor_vec.begin(), idx), + color, + make_iterator_property_map(distance_vec.begin(), idx), + idx, src, sink); +} + +/** + * named-parameter version, some given + */ +template +typename property_traits::const_type>::value_type +boykov_kolmogorov_max_flow(Graph& g, + typename graph_traits::vertex_descriptor src, + typename graph_traits::vertex_descriptor sink, + const bgl_named_params& params) +{ + return + boykov_kolmogorov_max_flow( + g, + choose_const_pmap(get_param(params, edge_capacity), g, edge_capacity), + choose_pmap(get_param(params, edge_residual_capacity), g, edge_residual_capacity), + choose_const_pmap(get_param(params, edge_reverse), g, edge_reverse), + choose_pmap(get_param(params, vertex_predecessor), g, vertex_predecessor), + choose_pmap(get_param(params, vertex_color), g, vertex_color), + choose_pmap(get_param(params, vertex_distance), g, vertex_distance), + choose_const_pmap(get_param(params, vertex_index), g, vertex_index), + src, sink); +} + +/** + * named-parameter version, none given + */ +template +typename property_traits::const_type>::value_type +boykov_kolmogorov_max_flow(Graph& g, + typename graph_traits::vertex_descriptor src, + typename graph_traits::vertex_descriptor sink) +{ + bgl_named_params params(0); // bogus empty param + return boykov_kolmogorov_max_flow(g, src, sink, params); +} + +} // namespace boost + +#endif // BOOST_BOYKOV_KOLMOGOROV_MAX_FLOW_HPP + diff --git a/include/boost/graph/breadth_first_search.hpp b/include/boost/graph/breadth_first_search.hpp index 1cf06cf7..79fde8cd 100644 --- a/include/boost/graph/breadth_first_search.hpp +++ b/include/boost/graph/breadth_first_search.hpp @@ -73,7 +73,7 @@ namespace boost { Q.push(s); while (! Q.empty()) { Vertex u = Q.top(); Q.pop(); vis.examine_vertex(u, g); - for (tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) { + for (boost::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) { Vertex v = target(*ei, g); vis.examine_edge(*ei, g); ColorValue v_color = get(color, v); if (v_color == Color::white()) { vis.tree_edge(*ei, g); @@ -100,7 +100,7 @@ namespace boost { typedef typename property_traits::value_type ColorValue; typedef color_traits Color; typename boost::graph_traits::vertex_iterator i, i_end; - for (tie(i, i_end) = vertices(g); i != i_end; ++i) { + for (boost::tie(i, i_end) = vertices(g); i != i_end; ++i) { vis.initialize_vertex(*i, g); put(color, *i, Color::white()); } diff --git a/include/boost/graph/bron_kerbosch_all_cliques.hpp b/include/boost/graph/bron_kerbosch_all_cliques.hpp index f6d253b1..35479316 100644 --- a/include/boost/graph/bron_kerbosch_all_cliques.hpp +++ b/include/boost/graph/bron_kerbosch_all_cliques.hpp @@ -280,7 +280,7 @@ bron_kerbosch_all_cliques(const Graph& g, Visitor vis, std::size_t min) // constant inserts and removals at the end and also a constant size. VertexIterator i, end; - tie(i, end) = vertices(g); + boost::tie(i, end) = vertices(g); VertexSet cands(i, end); // start with all vertices as candidates VertexSet nots; // start with no vertices visited diff --git a/include/boost/graph/clustering_coefficient.hpp b/include/boost/graph/clustering_coefficient.hpp index e5f94d9f..15574f04 100644 --- a/include/boost/graph/clustering_coefficient.hpp +++ b/include/boost/graph/clustering_coefficient.hpp @@ -72,7 +72,7 @@ num_paths_through_vertex(const Graph& g, Vertex v) // for things like this (num_neighbors() would be great). AdjacencyIterator i, end; - tie(i, end) = adjacent_vertices(v, g); + boost::tie(i, end) = adjacent_vertices(v, g); std::size_t k = std::distance(i, end); return detail::possible_edges(g, k, Directed()); } @@ -92,7 +92,7 @@ num_triangles_on_vertex(const Graph& g, Vertex v) Degree count(0); AdjacencyIterator i, j, end; - for(tie(i, end) = adjacent_vertices(v, g); i != end; ++i) { + for(boost::tie(i, end) = adjacent_vertices(v, g); i != end; ++i) { for(j = boost::next(i); j != end; ++j) { count += detail::count_edges(g, *i, *j, Directed()); } @@ -127,7 +127,7 @@ all_clustering_coefficients(const Graph& g, ClusteringMap cm) Coefficient sum(0); VertexIterator i, end; - for(tie(i, end) = vertices(g); i != end; ++i) { + for(boost::tie(i, end) = vertices(g); i != end; ++i) { Coefficient cc = clustering_coefficient(g, *i); put(cm, *i, cc); sum += cc; @@ -147,7 +147,7 @@ mean_clustering_coefficient(const Graph& g, ClusteringMap cm) Coefficient cc(0); VertexIterator i, end; - for(tie(i, end) = vertices(g); i != end; ++i) { + for(boost::tie(i, end) = vertices(g); i != end; ++i) { cc += get(cm, *i); } return cc / Coefficient(num_vertices(g)); diff --git a/include/boost/graph/compressed_sparse_row_graph.hpp b/include/boost/graph/compressed_sparse_row_graph.hpp index 5488f42f..d236ddcd 100644 --- a/include/boost/graph/compressed_sparse_row_graph.hpp +++ b/include/boost/graph/compressed_sparse_row_graph.hpp @@ -185,11 +185,11 @@ template class compressed_sparse_row_graph : public detail::indexed_vertex_properties + VertexProperty, Vertex, typed_identity_property_map > { public: typedef detail::indexed_vertex_properties + VertexProperty, Vertex, typed_identity_property_map > inherited_vertex_properties; public: @@ -264,7 +264,7 @@ class compressed_sparse_row_graph(), keep_all()); } // From number of vertices and unsorted list of edges, plus edge properties @@ -277,7 +277,7 @@ class compressed_sparse_row_graph(), keep_all()); } // From number of vertices and unsorted list of edges, with filter and @@ -320,7 +320,7 @@ class compressed_sparse_row_graph(), keep_all(), numverts, numedges); inherited_vertex_properties::resize(numverts); } @@ -334,7 +334,7 @@ class compressed_sparse_row_graph(), keep_all(), numverts, numedges); inherited_vertex_properties::resize(numverts); } @@ -377,7 +377,7 @@ class compressed_sparse_row_graph()); } // From number of vertices and mutable vectors of sources and targets, @@ -408,7 +408,7 @@ class compressed_sparse_row_graph()); } // From number of vertices and mutable vectors of sources and targets and @@ -441,7 +441,7 @@ class compressed_sparse_row_graph sources, targets; boost::graph::detail::split_into_separate_coords (edge_begin, edge_end, sources, targets); - m_forward.assign_sources_and_targets_global(sources, targets, numverts, boost::identity_property_map()); + m_forward.assign_sources_and_targets_global(sources, targets, numverts, boost::typed_identity_property_map()); } // From number of vertices and single-pass range of unsorted edges and @@ -463,7 +463,7 @@ class compressed_sparse_row_graph()); } // From number of vertices and single-pass range of unsorted edges. Data is @@ -602,7 +602,7 @@ class compressed_sparse_row_graph()); } // Add edges from a sorted (smallest sources first) range of pairs @@ -653,7 +653,7 @@ class compressed_sparse_row_graph inline void add_edges_internal(InputIterator first, InputIterator last) { - this->add_edges_internal(first, last, identity_property_map()); + this->add_edges_internal(first, last, typed_identity_property_map()); } // Add edges from a range of (source, target) pairs and edge properties that @@ -699,7 +699,7 @@ class compressed_sparse_row_graphadd_edges_internal(first, last, ep_iter, ep_iter_end, identity_property_map()); + this->add_edges_internal(first, last, ep_iter, ep_iter_end, typed_identity_property_map()); } using inherited_vertex_properties::operator[]; @@ -728,11 +728,11 @@ template class compressed_sparse_row_graph : public detail::indexed_vertex_properties + VertexProperty, Vertex, typed_identity_property_map > { public: typedef detail::indexed_vertex_properties + VertexProperty, Vertex, typed_identity_property_map > inherited_vertex_properties; public: @@ -808,7 +808,7 @@ class compressed_sparse_row_graph(0), m_forward.m_rowstart.size() - 1, - identity_property_map(), + typed_identity_property_map(), keep_all()); } @@ -823,7 +823,7 @@ class compressed_sparse_row_graph(), keep_all()); set_up_backward_property_links(); } @@ -837,7 +837,7 @@ class compressed_sparse_row_graph(), keep_all()); set_up_backward_property_links(); } @@ -969,7 +969,7 @@ class compressed_sparse_row_graph()); } // Add edges from a sorted (smallest sources first) range of pairs @@ -1020,7 +1020,7 @@ class compressed_sparse_row_graph inline void add_edges_internal(InputIterator first, InputIterator last) { - this->add_edges_internal(first, last, identity_property_map()); + this->add_edges_internal(first, last, typed_identity_property_map()); } // Add edges from a range of (source, target) pairs and edge properties that @@ -1066,7 +1066,7 @@ class compressed_sparse_row_graphadd_edges_internal(first, last, ep_iter, ep_iter_end, identity_property_map()); + this->add_edges_internal(first, last, ep_iter, ep_iter_end, typed_identity_property_map()); } using inherited_vertex_properties::operator[]; @@ -1397,7 +1397,7 @@ get_property(const BOOST_CSR_GRAPH_TYPE& g, Tag) template struct property_map { - typedef identity_property_map type; + typedef typed_identity_property_map type; typedef type const_type; }; @@ -1423,10 +1423,10 @@ struct property_map }; template -inline identity_property_map +inline typed_identity_property_map get(vertex_index_t, const BOOST_CSR_GRAPH_TYPE&) { - return identity_property_map(); + return typed_identity_property_map(); } template diff --git a/include/boost/graph/copy.hpp b/include/boost/graph/copy.hpp index c566503a..402e75f2 100644 --- a/include/boost/graph/copy.hpp +++ b/include/boost/graph/copy.hpp @@ -113,19 +113,19 @@ namespace boost { Orig2CopyVertexIndexMap orig2copy, IndexMap) { typename graph_traits::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g_in); vi != vi_end; ++vi) { + for (boost::tie(vi, vi_end) = vertices(g_in); vi != vi_end; ++vi) { typename graph_traits::vertex_descriptor new_v = add_vertex(g_out); put(orig2copy, *vi, new_v); copy_vertex(*vi, new_v); } typename graph_traits::edge_iterator ei, ei_end; - for (tie(ei, ei_end) = edges(g_in); ei != ei_end; ++ei) { + for (boost::tie(ei, ei_end) = edges(g_in); ei != ei_end; ++ei) { typename graph_traits::edge_descriptor new_e; bool inserted; - tie(new_e, inserted) = add_edge(get(orig2copy, source(*ei, g_in)), - get(orig2copy, target(*ei, g_in)), - g_out); + boost::tie(new_e, inserted) = add_edge(get(orig2copy, source(*ei, g_in)), + get(orig2copy, target(*ei, g_in)), + g_out); copy_edge(*ei, new_e); } } @@ -142,20 +142,20 @@ namespace boost { Orig2CopyVertexIndexMap orig2copy, IndexMap) { typename graph_traits::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g_in); vi != vi_end; ++vi) { + for (boost::tie(vi, vi_end) = vertices(g_in); vi != vi_end; ++vi) { typename graph_traits::vertex_descriptor new_v = add_vertex(g_out); put(orig2copy, *vi, new_v); copy_vertex(*vi, new_v); } - for (tie(vi, vi_end) = vertices(g_in); vi != vi_end; ++vi) { + for (boost::tie(vi, vi_end) = vertices(g_in); vi != vi_end; ++vi) { typename graph_traits::out_edge_iterator ei, ei_end; - for (tie(ei, ei_end) = out_edges(*vi, g_in); ei != ei_end; ++ei) { + for (boost::tie(ei, ei_end) = out_edges(*vi, g_in); ei != ei_end; ++ei) { typename graph_traits::edge_descriptor new_e; bool inserted; - tie(new_e, inserted) = add_edge(get(orig2copy, source(*ei, g_in)), - get(orig2copy, target(*ei, g_in)), - g_out); + boost::tie(new_e, inserted) = add_edge(get(orig2copy, source(*ei, g_in)), + get(orig2copy, target(*ei, g_in)), + g_out); copy_edge(*ei, new_e); } } @@ -177,21 +177,21 @@ namespace boost { std::vector color(num_vertices(g_in), Color::white()); typename graph_traits::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g_in); vi != vi_end; ++vi) { + for (boost::tie(vi, vi_end) = vertices(g_in); vi != vi_end; ++vi) { typename graph_traits::vertex_descriptor new_v = add_vertex(g_out); put(orig2copy, *vi, new_v); copy_vertex(*vi, new_v); } - for (tie(vi, vi_end) = vertices(g_in); vi != vi_end; ++vi) { + for (boost::tie(vi, vi_end) = vertices(g_in); vi != vi_end; ++vi) { typename graph_traits::out_edge_iterator ei, ei_end; - for (tie(ei, ei_end) = out_edges(*vi, g_in); ei != ei_end; ++ei) { + for (boost::tie(ei, ei_end) = out_edges(*vi, g_in); ei != ei_end; ++ei) { typename graph_traits::edge_descriptor new_e; bool inserted; if (color[get(index_map, target(*ei, g_in))] == Color::white()) { - tie(new_e, inserted) = add_edge(get(orig2copy, source(*ei,g_in)), - get(orig2copy, target(*ei,g_in)), - g_out); + boost::tie(new_e, inserted) = add_edge(get(orig2copy, source(*ei,g_in)), + get(orig2copy, target(*ei,g_in)), + g_out); copy_edge(*ei, new_e); } } @@ -361,9 +361,9 @@ namespace boost { void examine_edge(Edge e, const Graph& g_in) const { typename graph_traits::edge_descriptor new_e; bool inserted; - tie(new_e, inserted) = add_edge(get(orig2copy, source(e, g_in)), - get(orig2copy, target(e, g_in)), - g_out); + boost::tie(new_e, inserted) = add_edge(get(orig2copy, source(e, g_in)), + get(orig2copy, target(e, g_in)), + g_out); copy_edge(e, new_e); } private: diff --git a/include/boost/graph/core_numbers.hpp b/include/boost/graph/core_numbers.hpp index da072bf1..7ef08261 100644 --- a/include/boost/graph/core_numbers.hpp +++ b/include/boost/graph/core_numbers.hpp @@ -122,11 +122,11 @@ namespace boost { { typename graph_traits::vertex_iterator vi,vi_end; typename graph_traits::out_edge_iterator ei,ei_end; - for (tie(vi,vi_end) = vertices(g); vi!=vi_end; ++vi) { + for (boost::tie(vi,vi_end) = vertices(g); vi!=vi_end; ++vi) { put(d,*vi,0); } - for (tie(vi,vi_end) = vertices(g); vi!=vi_end; ++vi) { - for (tie(ei,ei_end) = out_edges(*vi,g); ei!=ei_end; ++ei) { + for (boost::tie(vi,vi_end) = vertices(g); vi!=vi_end; ++vi) { + for (boost::tie(ei,ei_end) = out_edges(*vi,g); ei!=ei_end; ++ei) { put(d,target(*ei,g),get(d,target(*ei,g))+get(wm,*ei)); } } @@ -151,7 +151,7 @@ namespace boost { Q.pop(); v_cn = get(c,v); typename graph_traits::out_edge_iterator oi,oi_end; - for (tie(oi,oi_end) = out_edges(v,g); oi!=oi_end; ++oi) { + for (boost::tie(oi,oi_end) = out_edges(v,g); oi!=oi_end; ++oi) { vis.examine_edge(*oi,g); vertex u = target(*oi,g); // if c[u] > c[v], then u is still in the graph, @@ -182,7 +182,7 @@ namespace boost { IndexMap> MutableQueue; MutableQueue Q(num_vertices(g), icmp, im); typename graph_traits::vertex_iterator vi,vi_end; - for (tie(vi,vi_end) = vertices(g); vi!=vi_end; ++vi) { + for (boost::tie(vi,vi_end) = vertices(g); vi!=vi_end; ++vi) { Q.push(*vi); } return core_numbers_impl(g, c, wm, Q, vis); @@ -206,14 +206,14 @@ namespace boost { // compute the maximum degree (degrees are in the coremap) typename graph_traits::degree_size_type max_deg = 0; - for (tie(vi,vi_end) = vertices(g); vi!=vi_end; ++vi) { + for (boost::tie(vi,vi_end) = vertices(g); vi!=vi_end; ++vi) { max_deg = (std::max::degree_size_type>)(max_deg, get(c,*vi)); } // store the vertices in bins by their degree // allocate two extra locations to ease boundary cases std::vector bin(max_deg+2); - for (tie(vi,vi_end) = vertices(g); vi!=vi_end; ++vi) { + for (boost::tie(vi,vi_end) = vertices(g); vi!=vi_end; ++vi) { ++bin[get(c,*vi)]; } @@ -229,7 +229,7 @@ namespace boost { // perform the bucket sort with pos and vert so that // pos[0] is the vertex of smallest degree std::vector vert(num_vertices(g)); - for (tie(vi,vi_end) = vertices(g); vi!=vi_end; ++vi) { + for (boost::tie(vi,vi_end) = vertices(g); vi!=vi_end; ++vi) { vertex v=*vi; size_type p=bin[get(c,v)]; put(pos,v,p); @@ -247,7 +247,7 @@ namespace boost { vis.examine_vertex(v,g); v_cn = get(c,v); typename graph_traits::out_edge_iterator oi,oi_end; - for (tie(oi,oi_end) = out_edges(v,g); oi!=oi_end; ++oi) { + for (boost::tie(oi,oi_end) = out_edges(v,g); oi!=oi_end; ++oi) { vis.examine_edge(*oi,g); vertex u = target(*oi,g); // if c[u] > c[v], then u is still in the graph, diff --git a/include/boost/graph/create_condensation_graph.hpp b/include/boost/graph/create_condensation_graph.hpp index 4f3316f6..f874a086 100644 --- a/include/boost/graph/create_condensation_graph.hpp +++ b/include/boost/graph/create_condensation_graph.hpp @@ -38,7 +38,7 @@ namespace boost { for (size_type i = 0; i < components[si].size(); ++i) { vertex u = components[s][i]; typename graph_traits::adjacency_iterator v, v_end; - for (tie(v, v_end) = adjacent_vertices(u, g); v != v_end; ++v) { + for (boost::tie(v, v_end) = adjacent_vertices(u, g); v != v_end; ++v) { cg_vertex t = to_cg_vertex[component_number[*v]]; if (s != t) // Avoid loops in the condensation graph adj.push_back(t); @@ -50,7 +50,7 @@ namespace boost { cg_vertex t = adj[i]; typename graph_traits::edge_descriptor e; bool inserted; - tie(e, inserted) = add_edge(s, t, cg); + boost::tie(e, inserted) = add_edge(s, t, cg); put(edge_mult_map, e, 1); ++i; while (i < adj.size()) { @@ -58,7 +58,7 @@ namespace boost { put(edge_mult_map, e, get(edge_mult_map, e) + 1); else { t = adj[i]; - tie(e, inserted) = add_edge(s, t, cg); + boost::tie(e, inserted) = add_edge(s, t, cg); put(edge_mult_map, e, 1); } ++i; diff --git a/include/boost/graph/cuthill_mckee_ordering.hpp b/include/boost/graph/cuthill_mckee_ordering.hpp index c930bab3..52dc982a 100644 --- a/include/boost/graph/cuthill_mckee_ordering.hpp +++ b/include/boost/graph/cuthill_mckee_ordering.hpp @@ -92,7 +92,7 @@ namespace boost { // Copy degree to pseudo_degree // initialize the color map - for (tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui){ + for (boost::tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui){ put(color, *ui, Color::white()); } diff --git a/include/boost/graph/dag_shortest_paths.hpp b/include/boost/graph/dag_shortest_paths.hpp index d8b47ac6..a46de914 100644 --- a/include/boost/graph/dag_shortest_paths.hpp +++ b/include/boost/graph/dag_shortest_paths.hpp @@ -46,7 +46,7 @@ namespace boost { depth_first_visit(g, s, topo_visitor, color); typename graph_traits::vertex_iterator ui, ui_end; - for (tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui) { + for (boost::tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui) { put(distance, *ui, inf); put(pred, *ui, *ui); } @@ -58,7 +58,7 @@ namespace boost { Vertex u = *i; vis.examine_vertex(u, g); typename graph_traits::out_edge_iterator e, e_end; - for (tie(e, e_end) = out_edges(u, g); e != e_end; ++e) { + for (boost::tie(e, e_end) = out_edges(u, g); e != e_end; ++e) { vis.discover_vertex(target(*e, g), g); bool decreased = relax(*e, g, weight, pred, distance, combine, compare); diff --git a/include/boost/graph/depth_first_search.hpp b/include/boost/graph/depth_first_search.hpp index fcc61646..fde69f0f 100644 --- a/include/boost/graph/depth_first_search.hpp +++ b/include/boost/graph/depth_first_search.hpp @@ -100,7 +100,7 @@ namespace boost { put(color, u, Color::gray()); vis.discover_vertex(u, g); - tie(ei, ei_end) = out_edges(u, g); + boost::tie(ei, ei_end) = out_edges(u, g); // Variable is needed to workaround a borland bug. TF& fn = static_cast(func); if (fn(u, g)) { @@ -112,7 +112,7 @@ namespace boost { while (!stack.empty()) { VertexInfo& back = stack.back(); u = back.first; - tie(ei, ei_end) = back.second; + boost::tie(ei, ei_end) = back.second; stack.pop_back(); while (ei != ei_end) { Vertex v = target(*ei, g); @@ -124,7 +124,7 @@ namespace boost { u = v; put(color, u, Color::gray()); vis.discover_vertex(u, g); - tie(ei, ei_end) = out_edges(u, g); + boost::tie(ei, ei_end) = out_edges(u, g); if (fn(u, g)) { ei = ei_end; } @@ -166,7 +166,7 @@ namespace boost { // Variable is needed to workaround a borland bug. TF& fn = static_cast(func); if (!fn(u, g)) - for (tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) { + for (boost::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) { Vertex v = target(*ei, g); vis.examine_edge(*ei, g); ColorValue v_color = get(color, v); if (v_color == Color::white()) { vis.tree_edge(*ei, g); @@ -192,7 +192,7 @@ namespace boost { typedef color_traits Color; typename graph_traits::vertex_iterator ui, ui_end; - for (tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui) { + for (boost::tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui) { Vertex u = implicit_cast(*ui); put(color, u, Color::white()); vis.initialize_vertex(u, g); } @@ -202,7 +202,7 @@ namespace boost { detail::nontruth2()); } - for (tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui) { + for (boost::tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui) { Vertex u = implicit_cast(*ui); ColorValue u_color = get(color, u); if (u_color == Color::white()) { vis.start_vertex(u, g); diff --git a/include/boost/graph/detail/adjacency_list.hpp b/include/boost/graph/detail/adjacency_list.hpp index d94bc1eb..1bd98cd9 100644 --- a/include/boost/graph/detail/adjacency_list.hpp +++ b/include/boost/graph/detail/adjacency_list.hpp @@ -592,7 +592,7 @@ namespace boost { typedef typename Config::graph_type graph_type; graph_type& g = static_cast(g_); typename Config::out_edge_iterator first, last; - tie(first, last) = out_edges(u, g); + boost::tie(first, last) = out_edges(u, g); typedef typename Config::edge_parallel_category edge_parallel_category; detail::remove_directed_edge_if_dispatch (first, last, g.out_edge_list(u), pred, edge_parallel_category()); @@ -606,7 +606,7 @@ namespace boost { graph_type& g = static_cast(g_); typename Config::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) remove_out_edge_if(*vi, pred, g); } @@ -921,7 +921,7 @@ namespace boost { typedef typename Config::OutEdgeList::value_type::property_type PropT; graph_type& g = static_cast(g_); typename Config::out_edge_iterator first, last; - tie(first, last) = out_edges(u, g); + boost::tie(first, last) = out_edges(u, g); typedef typename Config::edge_parallel_category Cat; detail::undirected_remove_out_edge_if_dispatch (g, first, last, g.out_edge_list(u), pred, Cat()); @@ -948,7 +948,7 @@ namespace boost { typedef typename Config::graph_type graph_type; graph_type& g = static_cast(g_); typename Config::edge_iterator ei, ei_end, next; - tie(ei, ei_end) = edges(g); + boost::tie(ei, ei_end) = edges(g); for (next = ei; ei != ei_end; ei = next) { ++next; if (pred(*ei)) @@ -1118,7 +1118,7 @@ namespace boost { typedef typename Config::graph_type graph_type; graph_type& g = static_cast(g_); typename Config::edge_iterator ei, ei_end, next; - tie(ei, ei_end) = edges(g); + boost::tie(ei, ei_end) = edges(g); for (next = ei; ei != ei_end; ei = next) { ++next; if (pred(*ei)) @@ -1279,7 +1279,7 @@ namespace boost { // First remove the edges from the targets' in-edge lists and // from the graph's edge set list. typename Config::out_edge_iterator out_i, out_end; - for (tie(out_i, out_end) = out_edges(u, g); out_i != out_end; ++out_i) + for (boost::tie(out_i, out_end) = out_edges(u, g); out_i != out_end; ++out_i) if (pred(*out_i)) { detail::remove_directed_edge_dispatch (*out_i, in_edge_list(g, target(*out_i, g)), @@ -1291,7 +1291,7 @@ namespace boost { // Now remove the edges from this out-edge list. typename Config::out_edge_iterator first, last; - tie(first, last) = out_edges(u, g); + boost::tie(first, last) = out_edges(u, g); typedef typename Config::edge_parallel_category Cat; detail::remove_directed_edge_if_dispatch (first, last, g.out_edge_list(u), pred, Cat()); @@ -1320,7 +1320,7 @@ namespace boost { // First remove the edges from the sources' out-edge lists and // from the graph's edge set list. typename Config::in_edge_iterator in_i, in_end; - for (tie(in_i, in_end) = in_edges(v, g); in_i != in_end; ++in_i) + for (boost::tie(in_i, in_end) = in_edges(v, g); in_i != in_end; ++in_i) if (pred(*in_i)) { typename Config::vertex_descriptor u = source(*in_i, g); detail::remove_directed_edge_dispatch @@ -1331,7 +1331,7 @@ namespace boost { } // Now remove the edges from this in-edge list. typename Config::in_edge_iterator first, last; - tie(first, last) = in_edges(v, g); + boost::tie(first, last) = in_edges(v, g); typedef typename Config::edge_parallel_category Cat; detail::remove_directed_edge_if_dispatch (first, last, in_edge_list(g, v), pred, Cat()); @@ -1650,7 +1650,7 @@ namespace boost { typename Config::OutEdgeList& el = g.out_edge_list(u); typename Config::OutEdgeList::iterator first, last; typename Config::EdgeContainer fake_edge_container; - tie(first, last) = graph_detail:: + boost::tie(first, last) = graph_detail:: equal_range(el, StoredEdge(v, fake_edge_container.end(), &fake_edge_container)); return std::make_pair(out_edge_iterator(first, u), @@ -1873,7 +1873,7 @@ namespace boost { // Copy the stored vertex objects by adding each vertex // and copying its property object. vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(x); vi != vi_end; ++vi) { + for (boost::tie(vi, vi_end) = vertices(x); vi != vi_end; ++vi) { stored_vertex* v = (stored_vertex*)add_vertex(*this); v->m_property = ((stored_vertex*)*vi)->m_property; vertex_map[(stored_vertex*)*vi] = v; @@ -1881,12 +1881,12 @@ namespace boost { // Copy the edges by adding each edge and copying its // property object. edge_iterator ei, ei_end; - for (tie(ei, ei_end) = edges(x); ei != ei_end; ++ei) { + for (boost::tie(ei, ei_end) = edges(x); ei != ei_end; ++ei) { edge_descriptor e; bool inserted; vertex_descriptor s = source(*ei,x), t = target(*ei,x); - tie(e, inserted) = add_edge(vertex_map[(stored_vertex*)s], - vertex_map[(stored_vertex*)t], *this); + boost::tie(e, inserted) = add_edge(vertex_map[(stored_vertex*)s], + vertex_map[(stored_vertex*)t], *this); *((edge_property_type*)e.m_eproperty) = *((edge_property_type*)(*ei).m_eproperty); } @@ -2154,10 +2154,10 @@ namespace boost { // Copy the edges by adding each edge and copying its // property object. edge_iterator ei, ei_end; - for (tie(ei, ei_end) = edges(x); ei != ei_end; ++ei) { + for (boost::tie(ei, ei_end) = edges(x); ei != ei_end; ++ei) { edge_descriptor e; bool inserted; - tie(e, inserted) = add_edge(source(*ei,x), target(*ei,x) , *this); + boost::tie(e, inserted) = add_edge(source(*ei,x), target(*ei,x) , *this); *((edge_property_type*)e.m_eproperty) = *((edge_property_type*)(*ei).m_eproperty); } diff --git a/include/boost/graph/detail/compressed_sparse_row_struct.hpp b/include/boost/graph/detail/compressed_sparse_row_struct.hpp index 541b6dd0..881eb8df 100644 --- a/include/boost/graph/detail/compressed_sparse_row_struct.hpp +++ b/include/boost/graph/detail/compressed_sparse_row_struct.hpp @@ -326,7 +326,7 @@ namespace detail { m_rowstart[i] = current_edge; g_vertex v = ordered_verts_of_g[i]; g_out_edge_iter ei, ei_end; - for (tie(ei, ei_end) = out_edges(v, g); ei != ei_end; ++ei) { + for (boost::tie(ei, ei_end) = out_edges(v, g); ei != ei_end; ++ei) { m_column[current_edge++] = get(vi, target(*ei, g)); } } diff --git a/include/boost/graph/detail/incremental_components.hpp b/include/boost/graph/detail/incremental_components.hpp index b13b93da..f66a3660 100644 --- a/include/boost/graph/detail/incremental_components.hpp +++ b/include/boost/graph/detail/incremental_components.hpp @@ -60,7 +60,7 @@ namespace boost { return (*this); } - bool operator==(self& other_iterator) { + bool operator==(const self& other_iterator) const { return (m_current_index == *other_iterator); } diff --git a/include/boost/graph/detail/sparse_ordering.hpp b/include/boost/graph/detail/sparse_ordering.hpp index 593d8c85..7a7350e6 100644 --- a/include/boost/graph/detail/sparse_ordering.hpp +++ b/include/boost/graph/detail/sparse_ordering.hpp @@ -137,7 +137,7 @@ namespace boost { sparse::rcm_queue Q(degree); typename boost::graph_traits::vertex_iterator ui, ui_end; - for (tie(ui, ui_end) = vertices(G); ui != ui_end; ++ui) + for (boost::tie(ui, ui_end) = vertices(G); ui != ui_end; ++ui) if (get(color, *ui) != Color::red()) put(color, *ui, Color::white()); breadth_first_visit(G, u, buffer(Q).color_map(color)); diff --git a/include/boost/graph/dijkstra_shortest_paths.hpp b/include/boost/graph/dijkstra_shortest_paths.hpp index d7456734..5b39cb38 100644 --- a/include/boost/graph/dijkstra_shortest_paths.hpp +++ b/include/boost/graph/dijkstra_shortest_paths.hpp @@ -372,7 +372,7 @@ namespace boost { typedef typename property_traits::value_type ColorValue; typedef color_traits Color; typename graph_traits::vertex_iterator ui, ui_end; - for (tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui) { + for (boost::tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui) { vis.initialize_vertex(*ui, g); put(distance, *ui, inf); put(predecessor, *ui, *ui); diff --git a/include/boost/graph/directed_graph.hpp b/include/boost/graph/directed_graph.hpp index 28b085dd..ceb3d6e3 100644 --- a/include/boost/graph/directed_graph.hpp +++ b/include/boost/graph/directed_graph.hpp @@ -194,7 +194,7 @@ public: // find all edges, (u, v) std::vector edges; out_edge_iterator i, i_end; - for(tie(i, i_end) = boost::out_edges(u, m_graph); i != i_end; ++i) { + for(boost::tie(i, i_end) = boost::out_edges(u, m_graph); i != i_end; ++i) { if(boost::target(*i, m_graph) == v) { edges.push_back(*i); } @@ -225,7 +225,7 @@ public: renumber_vertex_indices() { vertex_iterator i, end; - tie(i, end) = vertices(m_graph); + boost::tie(i, end) = vertices(m_graph); m_max_vertex_index = renumber_vertex_indices(i, end, 0); } @@ -248,7 +248,7 @@ public: renumber_edge_indices() { edge_iterator i, end; - tie(i, end) = edges(m_graph); + boost::tie(i, end) = edges(m_graph); m_max_edge_index = renumber_edge_indices(i, end, 0); } diff --git a/include/boost/graph/dominator_tree.hpp b/include/boost/graph/dominator_tree.hpp index 0c19a407..db40cb73 100644 --- a/include/boost/graph/dominator_tree.hpp +++ b/include/boost/graph/dominator_tree.hpp @@ -118,7 +118,7 @@ namespace boost { // For each predecessor of n typename graph_traits::in_edge_iterator inItr, inEnd; - for (tie(inItr, inEnd) = in_edges(n, g); inItr != inEnd; ++inItr) + for (boost::tie(inItr, inEnd) = in_edges(n, g); inItr != inEnd; ++inItr) { const Vertex v = source(*inItr, g); // To deal with unreachable nodes @@ -396,7 +396,7 @@ namespace boost { if (numOfVertices == 0) return; vertexItr vi, viend; - tie(vi, viend) = vertices(g); + boost::tie(vi, viend) = vertices(g); const std::set N(vi, viend); bool change = true; @@ -409,14 +409,14 @@ namespace boost { while (change) { change = false; - for (tie(vi, viend) = vertices(g); vi != viend; ++vi) + for (boost::tie(vi, viend) = vertices(g); vi != viend; ++vi) { if (*vi == entry) continue; std::set T(N); typename graph_traits::in_edge_iterator inItr, inEnd; - for (tie(inItr, inEnd) = in_edges(*vi, g); inItr != inEnd; ++inItr) + for (boost::tie(inItr, inEnd) = in_edges(*vi, g); inItr != inEnd; ++inItr) { const Vertex p = source(*inItr, g); @@ -434,16 +434,16 @@ namespace boost { change = true; get(domMap, *vi).swap(T); } - } // end of for (tie(vi, viend) = vertices(g) + } // end of for (boost::tie(vi, viend) = vertices(g) } // end of while(change) // 2. Build dominator tree - for (tie(vi, viend) = vertices(g); vi != viend; ++vi) + for (boost::tie(vi, viend) = vertices(g); vi != viend; ++vi) get(domMap, *vi).erase(*vi); Graph domTree(numOfVertices); - for (tie(vi, viend) = vertices(g); vi != viend; ++vi) + for (boost::tie(vi, viend) = vertices(g); vi != viend; ++vi) { if (*vi == entry) continue; @@ -464,7 +464,7 @@ namespace boost { } } - for (tie(vi, viend) = vertices(g); vi != viend; ++vi) + for (boost::tie(vi, viend) = vertices(g); vi != viend; ++vi) { if (*vi != entry && get(domMap, *vi).size() == 1) { diff --git a/include/boost/graph/eccentricity.hpp b/include/boost/graph/eccentricity.hpp index 6043477e..99f80a45 100644 --- a/include/boost/graph/eccentricity.hpp +++ b/include/boost/graph/eccentricity.hpp @@ -58,8 +58,8 @@ all_eccentricities(const Graph& g, const DistanceMatrix& dist, EccentricityMap e r = numeric_values::infinity(), d = numeric_values::zero(); VertexIterator i, end; - tie(i, end) = vertices(g); - for(tie(i, end) = vertices(g); i != end; ++i) { + boost::tie(i, end) = vertices(g); + for(boost::tie(i, end) = vertices(g); i != end; ++i) { DistanceMap dm = get(dist, *i); Eccentricity e = eccentricity(g, dm); put(ecc, *i, e); @@ -85,7 +85,7 @@ radius_and_diameter(const Graph& g, EccentricityMap ecc) BOOST_USING_STD_MAX(); VertexIterator i, end; - tie(i, end) = vertices(g); + boost::tie(i, end) = vertices(g); Eccentricity radius = get(ecc, *i); Eccentricity diameter = get(ecc, *i); for(i = boost::next(i); i != end; ++i) { diff --git a/include/boost/graph/edge_connectivity.hpp b/include/boost/graph/edge_connectivity.hpp index 383ad635..e255d84b 100644 --- a/include/boost/graph/edge_connectivity.hpp +++ b/include/boost/graph/edge_connectivity.hpp @@ -34,7 +34,7 @@ namespace boost { size_type delta = (std::numeric_limits::max)(); typename Traits::vertex_iterator i, iend; - for (tie(i, iend) = vertices(g); i != iend; ++i) + for (boost::tie(i, iend) = vertices(g); i != iend; ++i) if (degree(*i, g) < delta) { delta = degree(*i, g); p = *i; @@ -48,7 +48,7 @@ namespace boost { OutputIterator result) { typename graph_traits::adjacency_iterator ai, aend; - for (tie(ai, aend) = adjacent_vertices(u, g); ai != aend; ++ai) + for (boost::tie(ai, aend) = adjacent_vertices(u, g); ai != aend; ++ai) *result++ = *ai; } @@ -111,11 +111,11 @@ namespace boost { typename property_map::type rev_edge = get(edge_reverse, flow_g); - for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { + for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { u = source(*ei, g), v = target(*ei, g); - tie(e1, inserted) = add_edge(u, v, flow_g); + boost::tie(e1, inserted) = add_edge(u, v, flow_g); cap[e1] = 1; - tie(e2, inserted) = add_edge(v, u, flow_g); + boost::tie(e2, inserted) = add_edge(v, u, flow_g); cap[e2] = 1; // not sure about this rev_edge[e1] = e2; rev_edge[e2] = e1; @@ -124,7 +124,7 @@ namespace boost { //------------------------------------------------------------------------- // The Algorithm - tie(p, delta) = detail::min_degree_vertex(g); + boost::tie(p, delta) = detail::min_degree_vertex(g); S_star.push_back(p); alpha_star = delta; S.insert(p); @@ -132,7 +132,7 @@ namespace boost { detail::neighbors(g, S.begin(), S.end(), std::inserter(neighbor_S, neighbor_S.begin())); - tie(vi, vi_end) = vertices(g); + boost::tie(vi, vi_end) = vertices(g); std::set_difference(vi, vi_end, neighbor_S.begin(), neighbor_S.end(), std::back_inserter(non_neighbor_S)); @@ -146,7 +146,7 @@ namespace boost { if (alpha_S_k < alpha_star) { alpha_star = alpha_S_k; S_star.clear(); - for (tie(vi, vi_end) = vertices(flow_g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = vertices(flow_g); vi != vi_end; ++vi) if (color[*vi] != Color::white()) S_star.push_back(*vi); } @@ -154,7 +154,7 @@ namespace boost { neighbor_S.insert(k); detail::neighbors(g, k, std::inserter(neighbor_S, neighbor_S.begin())); non_neighbor_S.clear(); - tie(vi, vi_end) = vertices(g); + boost::tie(vi, vi_end) = vertices(g); std::set_difference(vi, vi_end, neighbor_S.begin(), neighbor_S.end(), std::back_inserter(non_neighbor_S)); @@ -169,7 +169,7 @@ namespace boost { degree_size_type c = 0; for (si = S_star.begin(); si != S_star.end(); ++si) { out_edge_iterator ei, ei_end; - for (tie(ei, ei_end) = out_edges(*si, g); ei != ei_end; ++ei) + for (boost::tie(ei, ei_end) = out_edges(*si, g); ei != ei_end; ++ei) if (!in_S_star[target(*ei, g)]) { *disconnecting_set++ = *ei; ++c; diff --git a/include/boost/graph/edmonds_karp_max_flow.hpp b/include/boost/graph/edmonds_karp_max_flow.hpp index fed4d69f..43cc592d 100644 --- a/include/boost/graph/edmonds_karp_max_flow.hpp +++ b/include/boost/graph/edmonds_karp_max_flow.hpp @@ -92,8 +92,8 @@ namespace boost { typename graph_traits::vertex_iterator u_iter, u_end; typename graph_traits::out_edge_iterator ei, e_end; - for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) - for (tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) + for (boost::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) + for (boost::tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) res[*ei] = cap[*ei]; color[sink] = Color::gray(); @@ -108,7 +108,7 @@ namespace boost { } // while typename property_traits::value_type flow = 0; - for (tie(ei, e_end) = out_edges(src, g); ei != e_end; ++ei) + for (boost::tie(ei, e_end) = out_edges(src, g); ei != e_end; ++ei) flow += (cap[*ei] - res[*ei]); return flow; } // edmonds_karp_max_flow() diff --git a/include/boost/graph/filtered_graph.hpp b/include/boost/graph/filtered_graph.hpp index 30b34335..43461410 100644 --- a/include/boost/graph/filtered_graph.hpp +++ b/include/boost/graph/filtered_graph.hpp @@ -279,7 +279,7 @@ namespace boost { { typedef filtered_graph Graph; typename graph_traits::vertex_iterator f, l; - tie(f, l) = vertices(g.m_g); + boost::tie(f, l) = vertices(g.m_g); typedef typename Graph::vertex_iterator iter; return std::make_pair(iter(g.m_vertex_pred, f, l), iter(g.m_vertex_pred, l, l)); @@ -293,7 +293,7 @@ namespace boost { typedef filtered_graph Graph; typename Graph::EdgePred pred(g.m_edge_pred, g.m_vertex_pred, g); typename graph_traits::edge_iterator f, l; - tie(f, l) = edges(g.m_g); + boost::tie(f, l) = edges(g.m_g); typedef typename Graph::edge_iterator iter; return std::make_pair(iter(pred, f, l), iter(pred, l, l)); } @@ -308,7 +308,7 @@ namespace boost { // // However, the current solution is still unsatisfactory because // the following semantic constraints no longer hold: - // tie(vi, viend) = vertices(g); + // boost::tie(vi, viend) = vertices(g); // assert(std::distance(vi, viend) == num_vertices(g)); template @@ -349,7 +349,7 @@ namespace boost { typename Graph::OutEdgePred pred(g.m_edge_pred, g.m_vertex_pred, g); typedef typename Graph::out_edge_iterator iter; typename graph_traits::out_edge_iterator f, l; - tie(f, l) = out_edges(u, g.m_g); + boost::tie(f, l) = out_edges(u, g.m_g); return std::make_pair(iter(pred, f, l), iter(pred, l, l)); } @@ -360,7 +360,7 @@ namespace boost { { typename filtered_graph::degree_size_type n = 0; typename filtered_graph::out_edge_iterator f, l; - for (tie(f, l) = out_edges(u, g); f != l; ++f) + for (boost::tie(f, l) = out_edges(u, g); f != l; ++f) ++n; return n; } @@ -374,7 +374,7 @@ namespace boost { typedef filtered_graph Graph; typedef typename Graph::adjacency_iterator adjacency_iterator; typename Graph::out_edge_iterator f, l; - tie(f, l) = out_edges(u, g); + boost::tie(f, l) = out_edges(u, g); return std::make_pair(adjacency_iterator(f, const_cast(&g)), adjacency_iterator(l, const_cast(&g))); } @@ -389,7 +389,7 @@ namespace boost { typename Graph::InEdgePred pred(g.m_edge_pred, g.m_vertex_pred, g); typedef typename Graph::in_edge_iterator iter; typename graph_traits::in_edge_iterator f, l; - tie(f, l) = in_edges(u, g.m_g); + boost::tie(f, l) = in_edges(u, g.m_g); return std::make_pair(iter(pred, f, l), iter(pred, l, l)); } @@ -400,7 +400,7 @@ namespace boost { { typename filtered_graph::degree_size_type n = 0; typename filtered_graph::in_edge_iterator f, l; - for (tie(f, l) = in_edges(u, g); f != l; ++f) + for (boost::tie(f, l) = in_edges(u, g); f != l; ++f) ++n; return n; } @@ -413,7 +413,7 @@ namespace boost { { typename graph_traits::edge_descriptor e; bool exists; - tie(e, exists) = edge(u, v, g.m_g); + boost::tie(e, exists) = edge(u, v, g.m_g); return std::make_pair(e, exists && g.m_edge_pred(e)); } @@ -428,7 +428,7 @@ namespace boost { typename Graph::OutEdgePred pred(g.m_edge_pred, g.m_vertex_pred, g); typedef typename Graph::out_edge_iterator iter; typename graph_traits::out_edge_iterator f, l; - tie(f, l) = edge_range(u, v, g.m_g); + boost::tie(f, l) = edge_range(u, v, g.m_g); return std::make_pair(iter(pred, f, l), iter(pred, l, l)); } diff --git a/include/boost/graph/floyd_warshall_shortest.hpp b/include/boost/graph/floyd_warshall_shortest.hpp index 87c3453b..48dba712 100644 --- a/include/boost/graph/floyd_warshall_shortest.hpp +++ b/include/boost/graph/floyd_warshall_shortest.hpp @@ -57,10 +57,10 @@ namespace boost i, lasti, j, lastj, k, lastk; - for (tie(k, lastk) = vertices(g); k != lastk; k++) - for (tie(i, lasti) = vertices(g); i != lasti; i++) + for (boost::tie(k, lastk) = vertices(g); k != lastk; k++) + for (boost::tie(i, lasti) = vertices(g); i != lasti; i++) if(d[*i][*k] != inf) - for (tie(j, lastj) = vertices(g); j != lastj; j++) + for (boost::tie(j, lastj) = vertices(g); j != lastj; j++) if(d[*k][*j] != inf) d[*i][*j] = detail::min_with_compare(d[*i][*j], @@ -68,7 +68,7 @@ namespace boost compare); - for (tie(i, lasti) = vertices(g); i != lasti; i++) + for (boost::tie(i, lasti) = vertices(g); i != lasti; i++) if (compare(d[*i][*i], zero)) return false; return true; @@ -110,16 +110,16 @@ namespace boost typename graph_traits::edge_iterator first, last; - for(tie(firstv, lastv) = vertices(g); firstv != lastv; firstv++) - for(tie(firstv2, lastv2) = vertices(g); firstv2 != lastv2; firstv2++) + for(boost::tie(firstv, lastv) = vertices(g); firstv != lastv; firstv++) + for(boost::tie(firstv2, lastv2) = vertices(g); firstv2 != lastv2; firstv2++) d[*firstv][*firstv2] = inf; - for(tie(firstv, lastv) = vertices(g); firstv != lastv; firstv++) + for(boost::tie(firstv, lastv) = vertices(g); firstv != lastv; firstv++) d[*firstv][*firstv] = zero; - for(tie(first, last) = edges(g); first != last; first++) + for(boost::tie(first, last) = edges(g); first != last; first++) { if (d[source(*first, g)][target(*first, g)] != inf) { d[source(*first, g)][target(*first, g)] = @@ -136,7 +136,7 @@ namespace boost undirected_tag>::value; if (is_undirected) { - for(tie(first, last) = edges(g); first != last; first++) + for(boost::tie(first, last) = edges(g); first != last; first++) { if (d[target(*first, g)][source(*first, g)] != inf) d[target(*first, g)][source(*first, g)] = diff --git a/include/boost/graph/fruchterman_reingold.hpp b/include/boost/graph/fruchterman_reingold.hpp index 0da35167..4ce502e8 100644 --- a/include/boost/graph/fruchterman_reingold.hpp +++ b/include/boost/graph/fruchterman_reingold.hpp @@ -78,7 +78,7 @@ struct all_force_pairs { typedef typename graph_traits::vertex_iterator vertex_iterator; vertex_iterator v, end; - for (tie(v, end) = vertices(g); v != end; ++v) { + for (boost::tie(v, end) = vertices(g); v != end; ++v) { vertex_iterator u = v; for (++u; u != end; ++u) { apply_force(*u, *v); @@ -116,7 +116,7 @@ struct grid_force_pairs std::size_t rows = std::size_t(topology.extent()[1] / two_k + 1.); buckets_t buckets(rows * columns); vertex_iterator v, v_end; - for (tie(v, v_end) = vertices(g); v != v_end; ++v) { + for (boost::tie(v, v_end) = vertices(g); v != v_end; ++v) { std::size_t column = std::size_t((get(position, *v)[0] + topology.extent()[0] / 2) / two_k); std::size_t row = @@ -299,13 +299,13 @@ fruchterman_reingold_force_directed_layout do { // Calculate repulsive forces vertex_iterator v, v_end; - for (tie(v, v_end) = vertices(g); v != v_end; ++v) + for (boost::tie(v, v_end) = vertices(g); v != v_end; ++v) put(displacement, *v, typename Topology::point_difference_type()); force_pairs(g, apply_force); // Calculate attractive forces edge_iterator e, e_end; - for (tie(e, e_end) = edges(g); e != e_end; ++e) { + for (boost::tie(e, e_end) = edges(g); e != e_end; ++e) { vertex_descriptor v = source(*e, g); vertex_descriptor u = target(*e, g); diff --git a/include/boost/graph/graph_stats.hpp b/include/boost/graph/graph_stats.hpp index 47c05025..636c4913 100644 --- a/include/boost/graph/graph_stats.hpp +++ b/include/boost/graph/graph_stats.hpp @@ -77,7 +77,7 @@ std::map dup_edge_dist( Graph& g ) { BGL_FORALL_VERTICES_T( v, g, Graph ) { std::list front_neighbors; a_iterator_type a_iter, a_end; - for( tie( a_iter, a_end ) = adjacent_vertices( v, g ); + for( boost::tie( a_iter, a_end ) = adjacent_vertices( v, g ); a_iter != a_end; ++a_iter ) { front_neighbors.push_back( *a_iter ); } diff --git a/include/boost/graph/graph_utility.hpp b/include/boost/graph/graph_utility.hpp index 9976074c..ba1fe3d8 100644 --- a/include/boost/graph/graph_utility.hpp +++ b/include/boost/graph/graph_utility.hpp @@ -157,11 +157,11 @@ namespace boost { void print_in_edges(const IncidenceGraph& G, Name name) { typename graph_traits::vertex_iterator ui,ui_end; - for (tie(ui,ui_end) = vertices(G); ui != ui_end; ++ui) { + for (boost::tie(ui,ui_end) = vertices(G); ui != ui_end; ++ui) { std::cout << get(name,*ui) << " <-- "; typename graph_traits ::in_edge_iterator ei, ei_end; - for(tie(ei,ei_end) = in_edges(*ui,G); ei != ei_end; ++ei) + for(boost::tie(ei,ei_end) = in_edges(*ui,G); ei != ei_end; ++ei) std::cout << get(name,source(*ei,G)) << " "; std::cout << std::endl; } @@ -171,11 +171,11 @@ namespace boost { void print_graph_dispatch(const IncidenceGraph& G, Name name, directed_tag) { typename graph_traits::vertex_iterator ui,ui_end; - for (tie(ui,ui_end) = vertices(G); ui != ui_end; ++ui) { + for (boost::tie(ui,ui_end) = vertices(G); ui != ui_end; ++ui) { std::cout << get(name,*ui) << " --> "; typename graph_traits ::out_edge_iterator ei, ei_end; - for(tie(ei,ei_end) = out_edges(*ui,G); ei != ei_end; ++ei) + for(boost::tie(ei,ei_end) = out_edges(*ui,G); ei != ei_end; ++ei) std::cout << get(name,target(*ei,G)) << " "; std::cout << std::endl; } @@ -184,11 +184,11 @@ namespace boost { void print_graph_dispatch(const IncidenceGraph& G, Name name, undirected_tag) { typename graph_traits::vertex_iterator ui,ui_end; - for (tie(ui,ui_end) = vertices(G); ui != ui_end; ++ui) { + for (boost::tie(ui,ui_end) = vertices(G); ui != ui_end; ++ui) { std::cout << get(name,*ui) << " <--> "; typename graph_traits ::out_edge_iterator ei, ei_end; - for(tie(ei,ei_end) = out_edges(*ui,G); ei != ei_end; ++ei) + for(boost::tie(ei,ei_end) = out_edges(*ui,G); ei != ei_end; ++ei) std::cout << get(name,target(*ei,G)) << " "; std::cout << std::endl; } @@ -209,7 +209,7 @@ namespace boost { void print_edges(const EdgeListGraph& G, Name name) { typename graph_traits::edge_iterator ei, ei_end; - for (tie(ei, ei_end) = edges(G); ei != ei_end; ++ei) + for (boost::tie(ei, ei_end) = edges(G); ei != ei_end; ++ei) std::cout << "(" << get(name, source(*ei, G)) << "," << get(name, target(*ei, G)) << ") "; std::cout << std::endl; @@ -219,7 +219,7 @@ namespace boost { void print_edges2(const EdgeListGraph& G, VertexName vname, EdgeName ename) { typename graph_traits::edge_iterator ei, ei_end; - for (tie(ei, ei_end) = edges(G); ei != ei_end; ++ei) + for (boost::tie(ei, ei_end) = edges(G); ei != ei_end; ++ei) std::cout << get(ename, *ei) << "(" << get(vname, source(*ei, G)) << "," << get(vname, target(*ei, G)) << ") "; std::cout << std::endl; @@ -229,7 +229,7 @@ namespace boost { void print_vertices(const VertexListGraph& G, Name name) { typename graph_traits::vertex_iterator vi,vi_end; - for (tie(vi,vi_end) = vertices(G); vi != vi_end; ++vi) + for (boost::tie(vi,vi_end) = vertices(G); vi != vi_end; ++vi) std::cout << get(name,*vi) << " "; std::cout << std::endl; } @@ -241,21 +241,21 @@ namespace boost { edge_descriptor; typename graph_traits::adjacency_iterator vi, viend, adj_found; - tie(vi, viend) = adjacent_vertices(a, g); + boost::tie(vi, viend) = adjacent_vertices(a, g); adj_found = std::find(vi, viend, b); if (adj_found == viend) return false; typename graph_traits::out_edge_iterator oi, oiend, out_found; - tie(oi, oiend) = out_edges(a, g); + boost::tie(oi, oiend) = out_edges(a, g); out_found = std::find_if(oi, oiend, incident_to(b, g)); if (out_found == oiend) return false; typename graph_traits::in_edge_iterator ii, iiend, in_found; - tie(ii, iiend) = in_edges(b, g); + boost::tie(ii, iiend) = in_edges(b, g); in_found = std::find_if(ii, iiend, incident_from(a, g)); if (in_found == iiend) return false; @@ -268,7 +268,7 @@ namespace boost { typedef typename graph_traits::edge_descriptor edge_descriptor; typename graph_traits::adjacency_iterator vi, viend, found; - tie(vi, viend) = adjacent_vertices(a, g); + boost::tie(vi, viend) = adjacent_vertices(a, g); #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 && defined(__SGI_STL_PORT) // Getting internal compiler error with std::find() found = viend; @@ -285,7 +285,7 @@ namespace boost { typename graph_traits::out_edge_iterator oi, oiend, out_found; - tie(oi, oiend) = out_edges(a, g); + boost::tie(oi, oiend) = out_edges(a, g); #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 && defined(__SGI_STL_PORT) // Getting internal compiler error with std::find() @@ -318,7 +318,7 @@ namespace boost { bool in_edge_set(Graph& g, Edge e) { typename Graph::edge_iterator ei, ei_end, found; - tie(ei, ei_end) = edges(g); + boost::tie(ei, ei_end) = edges(g); found = std::find(ei, ei_end, e); return found != ei_end; } @@ -327,7 +327,7 @@ namespace boost { bool in_vertex_set(Graph& g, Vertex v) { typename Graph::vertex_iterator vi, vi_end, found; - tie(vi, vi_end) = vertices(g); + boost::tie(vi, vi_end) = vertices(g); found = std::find(vi, vi_end, v); return found != vi_end; } @@ -336,7 +336,7 @@ namespace boost { bool in_edge_set(Graph& g, Vertex u, Vertex v) { typename Graph::edge_iterator ei, ei_end; - for (tie(ei,ei_end) = edges(g); ei != ei_end; ++ei) + for (boost::tie(ei,ei_end) = edges(g); ei != ei_end; ++ei) if (source(*ei,g) == u && target(*ei,g) == v) return true; return false; @@ -380,10 +380,10 @@ namespace boost { typedef color_traits Color; typename graph_traits::vertex_iterator ui, ui_end, vi, vi_end, ci, ci_end; - for (tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui) - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (boost::tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui) + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) if (*ui != *vi) { - for (tie(ci, ci_end) = vertices(g); ci != ci_end; ++ci) + for (boost::tie(ci, ci_end) = vertices(g); ci != ci_end; ++ci) put(color, *ci, Color::white()); if (! is_reachable(*ui, *vi, g, color)) return false; diff --git a/include/boost/graph/graphml.hpp b/include/boost/graph/graphml.hpp index b4955b88..6afa12c9 100644 --- a/include/boost/graph/graphml.hpp +++ b/include/boost/graph/graphml.hpp @@ -296,7 +296,7 @@ write_graphml(std::ostream& out, const Graph& g, VertexIndexMap vertex_index, typedef typename graph_traits::vertex_iterator vertex_iterator; vertex_iterator v, v_end; - for (tie(v, v_end) = vertices(g); v != v_end; ++v) + for (boost::tie(v, v_end) = vertices(g); v != v_end; ++v) { out << " \n"; // Output data @@ -314,7 +314,7 @@ write_graphml(std::ostream& out, const Graph& g, VertexIndexMap vertex_index, typedef typename graph_traits::edge_iterator edge_iterator; edge_iterator e, e_end; typename graph_traits::edges_size_type edge_count = 0; - for (tie(e, e_end) = edges(g); e != e_end; ++e) + for (boost::tie(e, e_end) = edges(g); e != e_end; ++e) { out << " #include #include +#include +#include +#include namespace boost { @@ -56,13 +59,25 @@ namespace boost { } }; + template + inline std::string escape_dot_string(const T& obj) { + using namespace boost::xpressive; + static sregex valid_unquoted_id = (((alpha | '_') >> *_w) | (!as_xpr('-') >> (('.' >> *_d) | (+_d >> !('.' >> *_d))))); + std::string s(boost::lexical_cast(obj)); + if (regex_match(s, valid_unquoted_id)) { + return s; + } else { + return "\"" + regex_replace(s, sregex(as_xpr('"')), "\\\"") + "\""; + } + } + template class label_writer { public: label_writer(Name _name) : name(_name) {} template void operator()(std::ostream& out, const VertexOrEdge& v) const { - out << "[label=\"" << get(name, v) << "\"]"; + out << "[label=" << escape_dot_string(get(name, v)) << "]"; } private: Name name; @@ -93,7 +108,7 @@ namespace boost { iend = attr.end(); while ( i != iend ) { - out << i->first << "=\"" << i->second << "\""; + out << i->first << "=" << escape_dot_string(i->second); ++i; if ( i != iend ) out << ", "; @@ -239,20 +254,20 @@ namespace boost { typedef typename graph_traits::directed_category cat_type; typedef graphviz_io_traits Traits; std::string name = "G"; - out << Traits::name() << " " << name << " {" << std::endl; + out << Traits::name() << " " << escape_dot_string(name) << " {" << std::endl; gpw(out); //print graph properties typename graph_traits::vertex_iterator i, end; - for(tie(i,end) = vertices(g); i != end; ++i) { - out << get(vertex_id, *i); + for(boost::tie(i,end) = vertices(g); i != end; ++i) { + out << escape_dot_string(get(vertex_id, *i)); vpw(out, *i); //print vertex attributes out << ";" << std::endl; } typename graph_traits::edge_iterator ei, edge_end; - for(tie(ei, edge_end) = edges(g); ei != edge_end; ++ei) { - out << get(vertex_id, source(*ei, g)) << Traits::delimiter() << get(vertex_id, target(*ei, g)) << " "; + for(boost::tie(ei, edge_end) = edges(g); ei != edge_end; ++ei) { + out << escape_dot_string(get(vertex_id, source(*ei, g))) << Traits::delimiter() << escape_dot_string(get(vertex_id, target(*ei, g))) << " "; epw(out, *ei); //print edge attributes out << ";" << std::endl; } @@ -324,7 +339,7 @@ namespace boost { else out << "subgraph"; - out << " " << g_name << " {" << std::endl; + out << " " << escape_dot_string(g_name) << " {" << std::endl; typename Graph::const_children_iterator i_child, j_child; @@ -346,7 +361,7 @@ namespace boost { #endif //print subgraph - for ( tie(i_child,j_child) = g.children(); + for ( boost::tie(i_child,j_child) = g.children(); i_child != j_child; ++i_child ) write_graphviz_subgraph(out, *i_child, vertex_marker, edge_marker, vertex_id); @@ -356,12 +371,12 @@ namespace boost { typename graph_traits::vertex_iterator i, end; typename graph_traits::edge_iterator ei, edge_end; - for(tie(i,end) = vertices(g); i != end; ++i) { + for(boost::tie(i,end) = vertices(g); i != end; ++i) { Vertex v = g.local_to_global(*i); int pos = get(vertex_id, v); if ( vertex_marker[pos] ) { vertex_marker[pos] = false; - out << pos; + out << escape_dot_string(pos); #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 typedef typename property_map::const_type VertexAttributeMap; @@ -375,14 +390,14 @@ namespace boost { } } - for (tie(ei, edge_end) = edges(g); ei != edge_end; ++ei) { + for (boost::tie(ei, edge_end) = edges(g); ei != edge_end; ++ei) { Vertex u = g.local_to_global(source(*ei,g)), v = g.local_to_global(target(*ei, g)); int pos = get(get(edge_index, g.root()), g.local_to_global(*ei)); if ( edge_marker[pos] ) { edge_marker[pos] = false; - out << get(vertex_id, u) << " " << Traits::delimiter() - << " " << get(vertex_id, v); + out << escape_dot_string(get(vertex_id, u)) << " " << Traits::delimiter() + << " " << escape_dot_string(get(vertex_id, v)); #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 typedef typename property_map::const_type EdgeAttributeMap; @@ -449,6 +464,8 @@ namespace boost { vertex_id); } +#if 0 + // This interface has not worked for a long time typedef std::map GraphvizAttrList; typedef property @@ -478,15 +495,15 @@ namespace boost { GraphvizGraphProperty> > GraphvizGraph; - // These four require linking the BGL-Graphviz library: libbgl-viz.a // from the /src directory. // Library has not existed for a while - // extern void read_graphviz(const std::string& file, GraphvizDigraph& g); - // extern void read_graphviz(FILE* file, GraphvizDigraph& g); - // - // extern void read_graphviz(const std::string& file, GraphvizGraph& g); - // extern void read_graphviz(FILE* file, GraphvizGraph& g); + extern void read_graphviz(const std::string& file, GraphvizDigraph& g); + extern void read_graphviz(FILE* file, GraphvizDigraph& g); + + extern void read_graphviz(const std::string& file, GraphvizGraph& g); + extern void read_graphviz(FILE* file, GraphvizGraph& g); +#endif class dynamic_properties_writer { @@ -504,7 +521,7 @@ namespace boost { else out << ", "; first = false; - out << i->first << "=\"" << i->second->get_string(key) << "\""; + out << i->first << "=" << escape_dot_string(i->second->get_string(key)); } } @@ -534,7 +551,7 @@ namespace boost { else out << ", "; first = false; - out << i->first << "=\"" << i->second->get_string(key) << "\""; + out << i->first << "=" << escape_dot_string(i->second->get_string(key)); } } @@ -576,22 +593,22 @@ namespace boost { template inline void - write_graphviz(std::ostream& out, const Graph& g, - const dynamic_properties& dp, - const std::string& node_id = "node_id" - BOOST_GRAPH_ENABLE_IF_MODELS_PARM(Graph,vertex_list_graph_tag)) + write_graphviz_dp(std::ostream& out, const Graph& g, + const dynamic_properties& dp, + const std::string& node_id = "node_id" + BOOST_GRAPH_ENABLE_IF_MODELS_PARM(Graph,vertex_list_graph_tag)) { typedef typename graph_traits::vertex_descriptor Vertex; - write_graphviz(out, g, dp, node_id, - graph::detail::node_id_property_map(dp, node_id)); + write_graphviz_dp(out, g, dp, node_id, + graph::detail::node_id_property_map(dp, node_id)); } template void - write_graphviz(std::ostream& out, const Graph& g, - const dynamic_properties& dp, const std::string& node_id, - VertexID id - BOOST_GRAPH_ENABLE_IF_MODELS_PARM(Graph,vertex_list_graph_tag)) + write_graphviz_dp(std::ostream& out, const Graph& g, + const dynamic_properties& dp, const std::string& node_id, + VertexID id + BOOST_GRAPH_ENABLE_IF_MODELS_PARM(Graph,vertex_list_graph_tag)) { write_graphviz (out, g, diff --git a/include/boost/graph/grid_graph.hpp b/include/boost/graph/grid_graph.hpp index bda68d51..9eff5259 100644 --- a/include/boost/graph/grid_graph.hpp +++ b/include/boost/graph/grid_graph.hpp @@ -101,6 +101,8 @@ namespace boost { typedef typename graph_traits::vertex_descriptor result_type; + grid_graph_vertex_at() : m_graph(0) {} + grid_graph_vertex_at(const Graph* graph) : m_graph(graph) { } @@ -124,6 +126,8 @@ namespace boost { public: typedef typename graph_traits::edge_descriptor result_type; + grid_graph_out_edge_at() : m_vertex(), m_graph(0) {} + grid_graph_out_edge_at(vertex_descriptor source_vertex, const Graph* graph) : m_vertex(source_vertex), @@ -150,6 +154,8 @@ namespace boost { public: typedef typename graph_traits::edge_descriptor result_type; + grid_graph_in_edge_at() : m_vertex(), m_graph(0) {} + grid_graph_in_edge_at(vertex_descriptor target_vertex, const Graph* graph) : m_vertex(target_vertex), @@ -172,6 +178,8 @@ namespace boost { typedef typename graph_traits::edge_descriptor result_type; + grid_graph_edge_at() : m_graph(0) {} + grid_graph_edge_at(const Graph* graph) : m_graph(graph) { } diff --git a/include/boost/graph/howard_cycle_ratio.hpp b/include/boost/graph/howard_cycle_ratio.hpp index 119499a3..09c6522b 100644 --- a/include/boost/graph/howard_cycle_ratio.hpp +++ b/include/boost/graph/howard_cycle_ratio.hpp @@ -187,9 +187,9 @@ namespace boost { float_t cz = (std::numeric_limits::max)(); //Closest to zero value float_t s = 0; const float_t eps_ = std::numeric_limits::epsilon(); - for (tie(vi, vie) = vertices(m_g); vi != vie; ++vi) + for (boost::tie(vi, vie) = vertices(m_g); vi != vie; ++vi) { - for (tie(oei, oeie) = out_edges(*vi, m_g); oei != oeie; ++oei) + 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]); @@ -211,9 +211,9 @@ namespace boost { m_sink = graph_traits().null_vertex(); typename graph_traits::vertex_iterator vi, vie; typename graph_traits::out_edge_iterator oei, oeie; - for ( tie(vi, vie) = vertices(m_g); vi != vie; ++vi ) + for ( boost::tie(vi, vie) = vertices(m_g); vi != vie; ++vi ) { - tie(oei, oeie) = out_edges(*vi, m_g); + boost::tie(oei, oeie) = out_edges(*vi, m_g); typename graph_traits::out_edge_iterator mei = std::max_element(oei, oeie, boost::bind(m_cmp, @@ -331,7 +331,7 @@ namespace boost { 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::vertex_iterator uv_itr, vie; - tie(uv_itr, vie) = vertices(m_g); + 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(), @@ -373,11 +373,11 @@ namespace boost { typename graph_traits::vertex_iterator vi, vie; typename graph_traits::out_edge_iterator oei, oeie; const float_t eps_ = FloatTraits::epsilon(); - for (tie(vi, vie) = vertices(m_g); vi != vie; ++vi) + for (boost::tie(vi, vie) = vertices(m_g); vi != vie; ++vi) { if (!m_badv[*vi]) { - for (tie(oei, oeie) = out_edges(*vi, m_g); oei != oeie; ++oei) + 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 diff --git a/include/boost/graph/incremental_components.hpp b/include/boost/graph/incremental_components.hpp index 43cc2a86..fff3a324 100644 --- a/include/boost/graph/incremental_components.hpp +++ b/include/boost/graph/incremental_components.hpp @@ -18,6 +18,7 @@ #include #include #include +#include namespace boost { @@ -54,7 +55,7 @@ namespace boost { void incremental_components(EdgeListGraph& g, DisjointSets& ds) { typename graph_traits::edge_iterator e, end; - for (tie(e,end) = edges(g); e != end; ++e) + for (boost::tie(e,end) = edges(g); e != end; ++e) ds.union_set(source(*e,g),target(*e,g)); } @@ -90,7 +91,7 @@ namespace boost { { typename graph_traits ::vertex_iterator v, vend; - for (tie(v, vend) = vertices(G); v != vend; ++v) + for (boost::tie(v, vend) = vertices(G); v != vend; ++v) ds.make_set(*v); } @@ -175,7 +176,7 @@ namespace boost { void build_index_lists(ParentIterator parent_start, const ElementIndexMap& index_map) { - typedef typename ParentIterator::value_type Element; + typedef typename std::iterator_traits::value_type Element; typename IndexContainer::iterator index_list = m_index_list->begin(); diff --git a/include/boost/graph/johnson_all_pairs_shortest.hpp b/include/boost/graph/johnson_all_pairs_shortest.hpp index 0720411c..8aec5005 100644 --- a/include/boost/graph/johnson_all_pairs_shortest.hpp +++ b/include/boost/graph/johnson_all_pairs_shortest.hpp @@ -74,21 +74,21 @@ namespace boost { { typename Traits1::vertex_iterator v, v_end; int i = 1; - for (tie(v, v_end) = vertices(g1); v != v_end; ++v, ++i) { + for (boost::tie(v, v_end) = vertices(g1); v != v_end; ++v, ++i) { typename Traits2::edge_descriptor e; bool z; - tie(e, z) = add_edge(s, get(id1, *v) + 1, g2); + boost::tie(e, z) = add_edge(s, get(id1, *v) + 1, g2); put(w, e, zero); verts1[i] = *v; } typename Traits1::edge_iterator e, e_end; - for (tie(e, e_end) = edges(g1); e != e_end; ++e) { + for (boost::tie(e, e_end) = edges(g1); e != e_end; ++e) { typename Traits2::edge_descriptor e2; bool z; - tie(e2, z) = add_edge(get(id1, source(*e, g1)) + 1, - get(id1, target(*e, g1)) + 1, g2); + boost::tie(e2, z) = add_edge(get(id1, source(*e, g1)) + 1, + get(id1, target(*e, g1)) + 1, g2); put(w, e2, get(w1, *e)); if (is_undirected) { - tie(e2, z) = add_edge(get(id1, target(*e, g1)) + 1, - get(id1, source(*e, g1)) + 1, g2); + boost::tie(e2, z) = add_edge(get(id1, target(*e, g1)) + 1, + get(id1, source(*e, g1)) + 1, g2); put(w, e2, get(w1, *e)); } } @@ -97,7 +97,7 @@ namespace boost { typename Traits2::edge_iterator e, e_end; shared_array_property_map h(num_vertices(g2), id2); - for (tie(v, v_end) = vertices(g2); v != v_end; ++v) + for (boost::tie(v, v_end) = vertices(g2); v != v_end; ++v) put(d, *v, inf); put(d, s, zero); @@ -106,19 +106,19 @@ namespace boost { dummy_property_map pred; bellman_visitor<> bvis; if (bellman_ford_shortest_paths (g2, num_vertices(g2), w, pred, d, combine, compare, bvis)) { - for (tie(v, v_end) = vertices(g2); v != v_end; ++v) + for (boost::tie(v, v_end) = vertices(g2); v != v_end; ++v) put(h, *v, get(d, *v)); // Reweight the edges to remove negatives - for (tie(e, e_end) = edges(g2); e != e_end; ++e) { + for (boost::tie(e, e_end) = edges(g2); e != e_end; ++e) { typename Traits2::vertex_descriptor a = source(*e, g2), b = target(*e, g2); put(w_hat, *e, combine(get(w, *e), (get(h, a) - get(h, b)))); } - for (tie(u, u_end) = vertices(g2); u != u_end; ++u) { + for (boost::tie(u, u_end) = vertices(g2); u != u_end; ++u) { dijkstra_visitor<> dvis; dijkstra_shortest_paths (g2, *u, pred, d, w_hat, id2, compare, combine, inf, zero,dvis); - for (tie(v, v_end) = vertices(g2); v != v_end; ++v) { + for (boost::tie(v, v_end) = vertices(g2); v != v_end; ++v) { if (*u != s && *v != s) { typename Traits1::vertex_descriptor u1, v1; u1 = verts1[get(id2, *u)]; v1 = verts1[get(id2, *v)]; diff --git a/include/boost/graph/king_ordering.hpp b/include/boost/graph/king_ordering.hpp index 77497273..9d9a438f 100644 --- a/include/boost/graph/king_ordering.hpp +++ b/include/boost/graph/king_ordering.hpp @@ -59,7 +59,7 @@ namespace boost { for( ; rbegin != rend; rend--){ percolate_down(i); w = (*Qptr)[index_begin+i]; - for (tie(ei, ei_end) = out_edges(w, g); ei != ei_end; ++ei) { + for (boost::tie(ei, ei_end) = out_edges(w, g); ei != ei_end; ++ei) { v = target(*ei, g); put(degree, v, get(degree, v) - 1); @@ -212,7 +212,7 @@ namespace boost { queue Q; // Copy degree to pseudo_degree // initialize the color map - for (tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui){ + for (boost::tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui){ put(pseudo_degree, *ui, get(degree, *ui)); put(color, *ui, Color::white()); } diff --git a/include/boost/graph/kolmogorov_max_flow.hpp b/include/boost/graph/kolmogorov_max_flow.hpp index f98a5721..ae476f32 100644 --- a/include/boost/graph/kolmogorov_max_flow.hpp +++ b/include/boost/graph/kolmogorov_max_flow.hpp @@ -32,6 +32,10 @@ #ifndef BOOST_KOLMOGOROV_MAX_FLOW_HPP #define BOOST_KOLMOGOROV_MAX_FLOW_HPP +#warning \ + The kolmogorov_max_flow.hpp header is deprecated and will be removed \ + in Boost 1.46. Use boykov_kolmogorov_max_flow.hpp instead. + #include #include #include @@ -105,13 +109,13 @@ namespace boost { m_last_grow_vertex(graph_traits::null_vertex()){ // initialize the color-map with gray-values vertex_iterator vi, v_end; - for(tie(vi, v_end) = vertices(m_g); vi != v_end; ++vi){ + for(boost::tie(vi, v_end) = vertices(m_g); vi != v_end; ++vi){ set_tree(*vi, tColorTraits::gray()); } // Initialize flow to zero which means initializing // the residual capacity equal to the capacity edge_iterator ei, e_end; - for(tie(ei, e_end) = edges(m_g); ei != e_end; ++ei) { + for(boost::tie(ei, e_end) = edges(m_g); ei != e_end; ++ei) { m_res_cap_map[*ei] = m_cap_map[*ei]; assert(m_rev_edge_map[m_rev_edge_map[*ei]] == *ei); //check if the reverse edge map is build up properly } @@ -121,7 +125,7 @@ namespace boost { m_time_map[m_source] = 1; m_time_map[m_sink] = 1; } - + ~kolmogorov(){} tEdgeVal max_flow(){ @@ -131,10 +135,10 @@ namespace boost { while(true){ bool path_found; edge_descriptor connecting_edge; - tie(connecting_edge, path_found) = grow(); //find a path from source to sink + boost::tie(connecting_edge, path_found) = grow(); //find a path from source to sink if(!path_found){ //we're finished, no more paths were found - break; + break; } ++m_time; augment(connecting_edge); //augment that path @@ -151,7 +155,7 @@ namespace boost { //this improves especially graphcuts for segmentation, as most of the nodes have source/sink connects //but shouldn't have an impact on other maxflow problems (this is done in grow() anyway) out_edge_iterator ei, e_end; - for(tie(ei, e_end) = out_edges(m_source, m_g); ei != e_end; ++ei){ + for(boost::tie(ei, e_end) = out_edges(m_source, m_g); ei != e_end; ++ei){ edge_descriptor from_source = *ei; vertex_descriptor current_node = target(from_source, m_g); if(current_node == m_sink){ @@ -162,7 +166,7 @@ namespace boost { } edge_descriptor to_sink; bool is_there; - tie(to_sink, is_there) = lookup_edge(current_node, m_sink, m_g); + boost::tie(to_sink, is_there) = lookup_edge(current_node, m_sink, m_g); if(is_there){ tEdgeVal cap_from_source = m_res_cap_map[from_source]; tEdgeVal cap_to_sink = m_res_cap_map[to_sink]; @@ -199,7 +203,7 @@ namespace boost { add_active_node(current_node); } } - for(tie(ei, e_end) = out_edges(m_sink, m_g); ei != e_end; ++ei){ + for(boost::tie(ei, e_end) = out_edges(m_sink, m_g); ei != e_end; ++ei){ edge_descriptor to_sink = m_rev_edge_map[*ei]; vertex_descriptor current_node = source(to_sink, m_g); if(m_res_cap_map[to_sink]){ @@ -213,7 +217,7 @@ namespace boost { } /** - * returns a pair of an edge and a boolean. if the bool is true, the edge is a connection of a found path from s->t , read "the link" and + * returns a pair of an edge and a boolean. if the bool is true, the edge is a connection of a found path from s->t , read "the link" and * source(returnVal, m_g) is the end of the path found in the source-tree * target(returnVal, m_g) is the beginning of the path found in the sink-tree */ @@ -221,14 +225,14 @@ namespace boost { assert(m_orphans.empty()); vertex_descriptor current_node; while((current_node = get_next_active_node()) != graph_traits::null_vertex()){ //if there is one - assert(get_tree(current_node) != tColorTraits::gray() && (has_parent(current_node) || current_node==m_source || current_node==m_sink)); - if(get_tree(current_node) == tColorTraits::black()){ + assert(get_tree(current_node) != tColorTraits::gray() && (has_parent(current_node) || current_node==m_source || current_node==m_sink)); + if(get_tree(current_node) == tColorTraits::black()){ //source tree growing out_edge_iterator ei, e_end; if(current_node != m_last_grow_vertex){ m_last_grow_vertex = current_node; - tie(m_last_grow_edge_it, m_last_grow_edge_end) = out_edges(current_node, m_g); - } + boost::tie(m_last_grow_edge_it, m_last_grow_edge_end) = out_edges(current_node, m_g); + } for(; m_last_grow_edge_it != m_last_grow_edge_end; ++m_last_grow_edge_it){ edge_descriptor out_edge = *m_last_grow_edge_it; if(m_res_cap_map[out_edge] > 0){ //check if we have capacity left on this edge @@ -245,7 +249,7 @@ namespace boost { m_dist_map[other_node] = m_dist_map[current_node] + 1; m_time_map[other_node] = m_time_map[current_node]; } - } else{ + } else{ assert(get_tree(other_node)==tColorTraits::white()); //kewl, found a path from one to the other search tree, return the connecting edge in src->sink dir return std::make_pair(out_edge, true); @@ -258,7 +262,7 @@ namespace boost { out_edge_iterator ei, e_end; if(current_node != m_last_grow_vertex){ m_last_grow_vertex = current_node; - tie(m_last_grow_edge_it, m_last_grow_edge_end) = out_edges(current_node, m_g); + boost::tie(m_last_grow_edge_it, m_last_grow_edge_end) = out_edges(current_node, m_g); } for(; m_last_grow_edge_it != m_last_grow_edge_end; ++m_last_grow_edge_it){ edge_descriptor in_edge = m_rev_edge_map[*m_last_grow_edge_it]; @@ -297,7 +301,7 @@ namespace boost { * target(e, m_g) is the beginning of the path found in the sink-tree * this phase generates orphans on satured edges, if the attached verts are from different search-trees * orphans are ordered in distance to sink/source. first the farest from the source are front_inserted into the orphans list, - * and after that the sink-tree-orphans are front_inserted. when going to adoption stage the orphans are popped_front, and so we process the nearest + * and after that the sink-tree-orphans are front_inserted. when going to adoption stage the orphans are popped_front, and so we process the nearest * verts to the terminals first */ void augment(edge_descriptor e){ @@ -381,12 +385,12 @@ namespace boost { current_node = m_child_orphans.front(); m_child_orphans.pop(); } - if(get_tree(current_node) == tColorTraits::black()){ + if(get_tree(current_node) == tColorTraits::black()){ //we're in the source-tree tDistanceVal min_distance = (std::numeric_limits::max)(); edge_descriptor new_parent_edge; out_edge_iterator ei, e_end; - for(tie(ei, e_end) = out_edges(current_node, m_g); ei != e_end; ++ei){ + for(boost::tie(ei, e_end) = out_edges(current_node, m_g); ei != e_end; ++ei){ const edge_descriptor in_edge = m_rev_edge_map[*ei]; assert(target(in_edge, m_g) == current_node); //we should be the target of this edge if(m_res_cap_map[in_edge] > 0){ @@ -405,7 +409,7 @@ namespace boost { m_time_map[current_node] = m_time; } else{ m_time_map[current_node] = 0; - for(tie(ei, e_end) = out_edges(current_node, m_g); ei != e_end; ++ei){ + for(boost::tie(ei, e_end) = out_edges(current_node, m_g); ei != e_end; ++ei){ edge_descriptor in_edge = m_rev_edge_map[*ei]; vertex_descriptor other_node = source(in_edge, m_g); if(get_tree(other_node) == tColorTraits::black() && has_parent(other_node)){ @@ -429,7 +433,7 @@ namespace boost { out_edge_iterator ei, e_end; edge_descriptor new_parent_edge; tDistanceVal min_distance = (std::numeric_limits::max)(); - for(tie(ei, e_end) = out_edges(current_node, m_g); ei != e_end; ++ei){ + for(boost::tie(ei, e_end) = out_edges(current_node, m_g); ei != e_end; ++ei){ const edge_descriptor out_edge = *ei; if(m_res_cap_map[out_edge] > 0){ const vertex_descriptor other_node = target(out_edge, m_g); @@ -446,10 +450,10 @@ namespace boost { m_time_map[current_node] = m_time; } else{ m_time_map[current_node] = 0; - for(tie(ei, e_end) = out_edges(current_node, m_g); ei != e_end; ++ei){ + for(boost::tie(ei, e_end) = out_edges(current_node, m_g); ei != e_end; ++ei){ const edge_descriptor out_edge = *ei; const vertex_descriptor other_node = target(out_edge, m_g); - if(get_tree(other_node) == tColorTraits::white() && has_parent(other_node)){ + if(get_tree(other_node) == tColorTraits::white() && has_parent(other_node)){ if(m_res_cap_map[out_edge] > 0){ add_active_node(other_node); } @@ -468,7 +472,7 @@ namespace boost { /** * return next active vertex if there is one, otherwise a null_vertex - */ + */ inline vertex_descriptor get_next_active_node(){ while(true){ if(m_active_nodes.empty()) @@ -487,7 +491,7 @@ namespace boost { /** * adds v as an active vertex, but only if its not in the list already - */ + */ inline void add_active_node(vertex_descriptor v){ assert(get_tree(v) != tColorTraits::gray()); if(m_in_active_list_map[v]){ @@ -509,8 +513,8 @@ namespace boost { } /** - * removes a vertex from the queue of active nodes (actually this does nothing, - * but checks if this node has no parent edge, as this is the criteria for beeing no more active) + * removes a vertex from the queue of active nodes (actually this does nothing, + * but checks if this node has no parent edge, as this is the criteria for beeing no more active) */ inline void remove_active_node(vertex_descriptor v){ assert(!has_parent(v)); @@ -541,12 +545,12 @@ namespace boost { * returns true if the edge stored in m_pre_map[v] is a valid entry */ inline bool has_parent(vertex_descriptor v) const{ - return m_has_parent_map[v]; + return m_has_parent_map[v]; } /** - * sets edge to parent vertex of v; - */ + * sets edge to parent vertex of v; + */ inline void set_edge_to_parent(vertex_descriptor v, edge_descriptor f_edge_to_parent){ assert(m_res_cap_map[f_edge_to_parent] > 0); m_pre_map[v] = f_edge_to_parent; @@ -576,7 +580,7 @@ namespace boost { } if(current_vertex == m_sink){ m_time_map[m_sink] = m_time; - break; + break; } if(has_parent(current_vertex)){ //it has a parent, so get it @@ -673,12 +677,12 @@ namespace boost { out_edge_iterator m_last_grow_edge_end; }; } //namespace detail - + /** * non-named-parameter version, given everything * this is the catch all version - */ - template typename property_traits::value_type kolmogorov_max_flow @@ -738,7 +742,7 @@ namespace boost { make_iterator_property_map(distance_vec.begin(), idx), idx, src, sink); } - + /** * non-named-parameter version, some given: capacity, residual_capacity, reverse_edges, color_map and an index map. * Use this if you are interested in the minimum cut, as the color map provides that info @@ -766,7 +770,7 @@ namespace boost { make_iterator_property_map(distance_vec.begin(), idx), idx, src, sink); } - + /** * named-parameter version, some given */ @@ -788,7 +792,7 @@ namespace boost { choose_const_pmap(get_param(params, vertex_index), g, vertex_index), src, sink); } - + /** * named-parameter version, none given */ diff --git a/include/boost/graph/labeled_graph.hpp b/include/boost/graph/labeled_graph.hpp index d91c5983..51743a4a 100644 --- a/include/boost/graph/labeled_graph.hpp +++ b/include/boost/graph/labeled_graph.hpp @@ -694,19 +694,19 @@ get(Prop p, LABELED_GRAPH& g) template inline typename property_map::const_type get(Prop p, LABELED_GRAPH const& g) -{ return get(p, g.impl()); } +{ return get(p, g.graph()); } template inline typename property_traits< typename property_map::const_type >::value_type get(Prop p, LABELED_GRAPH const& g, const Key& k) -{ return get(p, g.impl(), k); } +{ return get(p, g.graph(), k); } template inline void put(Prop p, LABELED_GRAPH& g, Key const& k, Value const& v) -{ put(p, g.impl(), k, v); } +{ put(p, g.graph(), k, v); } //@} /** @name Mutable Graph */ diff --git a/include/boost/graph/leda_graph.hpp b/include/boost/graph/leda_graph.hpp index 770874c5..687a10dd 100644 --- a/include/boost/graph/leda_graph.hpp +++ b/include/boost/graph/leda_graph.hpp @@ -481,11 +481,11 @@ namespace boost { leda::GRAPH& g) { typename graph_traits< leda::GRAPH >::out_edge_iterator ei, ei_end; - for (tie(ei, ei_end)=out_edges(u,g); ei!=ei_end; ei++) + for (boost::tie(ei, ei_end)=out_edges(u,g); ei!=ei_end; ei++) remove_edge(*ei); typename graph_traits< leda::GRAPH >::in_edge_iterator iei, iei_end; - for (tie(iei, iei_end)=in_edges(u,g); iei!=iei_end; iei++) + for (boost::tie(iei, iei_end)=in_edges(u,g); iei!=iei_end; iei++) remove_edge(*iei); } @@ -684,11 +684,11 @@ namespace boost { leda::graph& g) { graph_traits::out_edge_iterator ei, ei_end; - for (tie(ei, ei_end)=out_edges(u,g); ei!=ei_end; ei++) + for (boost::tie(ei, ei_end)=out_edges(u,g); ei!=ei_end; ei++) remove_edge(*ei, g); graph_traits::in_edge_iterator iei, iei_end; - for (tie(iei, iei_end)=in_edges(u,g); iei!=iei_end; iei++) + for (boost::tie(iei, iei_end)=in_edges(u,g); iei!=iei_end; iei++) remove_edge(*iei, g); } diff --git a/include/boost/graph/loop_erased_random_walk.hpp b/include/boost/graph/loop_erased_random_walk.hpp new file mode 100644 index 00000000..421808da --- /dev/null +++ b/include/boost/graph/loop_erased_random_walk.hpp @@ -0,0 +1,110 @@ +// Copyright 2010 The Trustees of Indiana University. + +// 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) + +// Authors: Jeremiah Willcock +// Andrew Lumsdaine + +#ifndef BOOST_GRAPH_LOOP_ERASED_RANDOM_WALK_HPP +#define BOOST_GRAPH_LOOP_ERASED_RANDOM_WALK_HPP + +#include +#include +#include +#include +#include +#include + +namespace boost { + + // Do a loop-erased random walk from vertex s to any vertex colored black (or + // actually any color other than white or gray) in the color map. The color + // white is for vertices that are not part of the path, while gray is for + // those that are on the path (for cycle detection). The vector path is used + // for temporary storage and as the result of the algorithm; while all + // elements of the path except the last have their colors set to gray upon + // return. Vertex s must start off colored white. + // + // Useful references: + // http://everything2.com/title/loop-erased+random+walk + // Wikipedia page on "Loop-Erased Random Walk" + + template + void loop_erased_random_walk( + const Graph& g, + typename boost::graph_traits::vertex_descriptor s, + NextEdge next_edge, + ColorMap color, + std::vector::vertex_descriptor>& path + ) { + typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + typedef typename boost::graph_traits::edge_descriptor edge_descriptor; + typedef typename boost::property_traits::value_type color_t; + typedef boost::color_traits color_gen; + + assert (get(color, s) == color_gen::white()); + path.clear(); + path.push_back(s); + put(color, s, color_gen::gray()); + while (true) { + edge_descriptor e = next_edge(s, g); + vertex_descriptor t = target(e, g); + color_t t_color = get(color, t); + if (t_color == color_gen::white()) { + path.push_back(t); + put(color, t, color_gen::gray()); + s = t; + } else if (t_color == color_gen::gray()) { + // Found a loop; delete from path from the first occurrence of t to the + // end, coloring vertices white. + typename std::vector::iterator it = std::find(path.begin(), path.end(), t); + assert (it != path.end()); + ++it; + for (typename std::vector::iterator j = it; j != path.end(); ++j) { + put(color, *j, color_gen::white()); + } + path.erase(it, path.end()); + s = t; + } else { + // Done + path.push_back(t); + break; + } + } + } + + template + class unweighted_random_out_edge_gen { + Gen& gen; + + typedef boost::graph_traits gt; + + public: + unweighted_random_out_edge_gen(Gen& gen): gen(gen) {} + + typename gt::edge_descriptor + operator()(typename gt::vertex_descriptor src, const Graph& g) const { + return boost::random_out_edge(g, src, gen); + } + }; + + template + class weighted_random_out_edge_gen { + WeightMap weight; + Gen& gen; + + typedef boost::graph_traits gt; + + public: + weighted_random_out_edge_gen(const WeightMap& weight, Gen& gen): weight(weight), gen(gen) {} + + typename gt::edge_descriptor + operator()(typename gt::vertex_descriptor src, const Graph& g) const { + return boost::weighted_random_out_edge(g, src, weight, gen); + } + }; +} + +#endif // BOOST_GRAPH_LOOP_ERASED_RANDOM_WALK_HPP diff --git a/include/boost/graph/make_connected.hpp b/include/boost/graph/make_connected.hpp index e5e2f52c..de6c861d 100644 --- a/include/boost/graph/make_connected.hpp +++ b/include/boost/graph/make_connected.hpp @@ -46,7 +46,7 @@ namespace boost return; vertex_iterator_t vi, vi_end; - tie(vi,vi_end) = vertices(g); + boost::tie(vi,vi_end) = vertices(g); std::copy(vi, vi_end, vertices_by_component.begin()); bucket_sort(vertices_by_component.begin(), diff --git a/include/boost/graph/max_cardinality_matching.hpp b/include/boost/graph/max_cardinality_matching.hpp index 1f0f6de2..043f7014 100644 --- a/include/boost/graph/max_cardinality_matching.hpp +++ b/include/boost/graph/max_cardinality_matching.hpp @@ -43,7 +43,7 @@ namespace boost v_size_t size_of_matching = 0; vertex_iterator_t vi, vi_end; - for(tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) + for(boost::tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) { vertex_descriptor_t v = *vi; if (get(mate,v) != graph_traits::null_vertex() @@ -74,7 +74,7 @@ namespace boost typedef typename graph_traits::vertex_iterator vertex_iterator_t; vertex_iterator_t vi, vi_end; - for( tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) + for( boost::tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) { vertex_descriptor_t v = *vi; if (get(mate,v) != graph_traits::null_vertex() @@ -187,7 +187,7 @@ namespace boost ds(ds_rank_map, ds_parent_map) { vertex_iterator_t vi, vi_end; - for(tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) + for(boost::tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) mate[*vi] = get(arg_mate, *vi); } @@ -205,7 +205,7 @@ namespace boost even_edges.clear(); vertex_iterator_t vi, vi_end; - for(tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) + for(boost::tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) { vertex_descriptor_t u = *vi; @@ -219,7 +219,7 @@ namespace boost { vertex_state[u] = graph::detail::V_EVEN; out_edge_iterator_t ei, ei_end; - for(tie(ei,ei_end) = out_edges(u,g); ei != ei_end; ++ei) + for(boost::tie(ei,ei_end) = out_edges(u,g); ei != ei_end; ++ei) even_edges.push_back( *ei ); } else @@ -261,7 +261,7 @@ namespace boost vertex_state[w_prime] = graph::detail::V_ODD; vertex_state[mate[w_prime]] = graph::detail::V_EVEN; out_edge_iterator_t ei, ei_end; - for( tie(ei,ei_end) = out_edges(mate[w_prime], g); ei != ei_end; ++ei) + for( boost::tie(ei,ei_end) = out_edges(mate[w_prime], g); ei != ei_end; ++ei) even_edges.push_back(*ei); pred[w_prime] = v; } @@ -356,7 +356,7 @@ namespace boost void get_current_matching(PropertyMap pm) { vertex_iterator_t vi,vi_end; - for(tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) + for(boost::tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) put(pm, *vi, mate[*vi]); } @@ -367,7 +367,7 @@ namespace boost void get_vertex_state_map(PropertyMap pm) { vertex_iterator_t vi,vi_end; - for(tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) + for(boost::tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) put(pm, *vi, vertex_state[origin[ds.find_set(*vi)]]); } @@ -403,7 +403,7 @@ namespace boost { bridge[v] = the_bridge; out_edge_iterator_t oei, oei_end; - for(tie(oei, oei_end) = out_edges(v,g); oei != oei_end; ++oei) + for(boost::tie(oei, oei_end) = out_edges(v,g); oei != oei_end; ++oei) even_edges.push_back(*oei); } } @@ -520,11 +520,11 @@ namespace boost static void find_matching(const Graph& g, MateMap mate) { vertex_iterator_t vi, vi_end; - for(tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) + for(boost::tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) put(mate, *vi, graph_traits::null_vertex()); edge_iterator_t ei, ei_end; - for( tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for( boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { edge_descriptor_t e = *ei; vertex_descriptor_t u = source(e,g); @@ -598,11 +598,11 @@ namespace boost directed_edges_vector_t edge_list; vertex_iterator_t vi, vi_end; - for(tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for(boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) put(mate, *vi, graph_traits::null_vertex()); edge_iterator_t ei, ei_end; - for(tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for(boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { edge_descriptor_t e = *ei; vertex_descriptor_t u = source(e,g); @@ -642,7 +642,7 @@ namespace boost static void find_matching(const Graph& g, MateMap mate) { vertex_iterator_t vi, vi_end; - for(tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) + for(boost::tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) put(mate, *vi, graph_traits::null_vertex()); } }; @@ -791,7 +791,7 @@ namespace boost //count the number of graph::detail::V_ODD vertices v_size_t num_odd_vertices = 0; vertex_iterator_t vi, vi_end; - for(tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) + for(boost::tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) if (vertex_state[*vi] == graph::detail::V_ODD) ++num_odd_vertices; diff --git a/include/boost/graph/mcgregor_common_subgraphs.hpp b/include/boost/graph/mcgregor_common_subgraphs.hpp index 51eea889..c46f7215 100644 --- a/include/boost/graph/mcgregor_common_subgraphs.hpp +++ b/include/boost/graph/mcgregor_common_subgraphs.hpp @@ -288,8 +288,8 @@ namespace boost { typename graph_traits::vertex_iterator vertex2_begin, vertex2_end, vertex2_iter; - tie(vertex1_iter, vertex1_end) = vertices(graph1); - tie(vertex2_begin, vertex2_end) = vertices(graph2); + boost::tie(vertex1_iter, vertex1_end) = vertices(graph1); + boost::tie(vertex2_begin, vertex2_end) = vertices(graph2); vertex2_iter = vertex2_begin; // Iterate until all vertices have been visited diff --git a/include/boost/graph/metric_tsp_approx.hpp b/include/boost/graph/metric_tsp_approx.hpp index 02709539..ff81b9f0 100644 --- a/include/boost/graph/metric_tsp_approx.hpp +++ b/include/boost/graph/metric_tsp_approx.hpp @@ -285,7 +285,7 @@ namespace boost // would require revisiting the core algorithm. Edge e; bool found; - tie(e, found) = lookup_edge(previous_, v, g); + boost::tie(e, found) = lookup_edge(previous_, v, g); if(!found) { BOOST_THROW_EXCEPTION(not_complete()); } diff --git a/include/boost/graph/minimum_degree_ordering.hpp b/include/boost/graph/minimum_degree_ordering.hpp index 39c3dcfb..85e6e7be 100644 --- a/include/boost/graph/minimum_degree_ordering.hpp +++ b/include/boost/graph/minimum_degree_ordering.hpp @@ -310,13 +310,13 @@ namespace boost { { typename graph_traits::vertex_iterator v, vend; size_type vid = 0; - for (tie(v, vend) = vertices(G); v != vend; ++v, ++vid) + for (boost::tie(v, vend) = vertices(G); v != vend; ++v, ++vid) index_vertex_vec[vid] = *v; index_vertex_map = IndexVertexMap(&index_vertex_vec[0]); // Initialize degreelists. Degreelists organizes the nodes // according to their degree. - for (tie(v, vend) = vertices(G); v != vend; ++v) { + for (boost::tie(v, vend) = vertices(G); v != vend; ++v) { put(degree, *v, out_degree(*v, G)); degreelists.push(*v); } @@ -409,7 +409,7 @@ namespace boost { size_type e_id = element_neighbor.top(); vertex_t element = get(index_vertex_map, e_id); adj_iter i, i_end; - for (tie(i, i_end) = adjacent_vertices(element, G); i != i_end; ++i){ + for (boost::tie(i, i_end) = adjacent_vertices(element, G); i != i_end; ++i){ vertex_t i_node = *i; if (!marker.is_tagged(i_node) && !numbering.is_numbered(i_node)) { marker.mark_tagged(i_node); @@ -419,7 +419,7 @@ namespace boost { element_neighbor.pop(); } adj_iter v, ve; - for (tie(v, ve) = adjacent_vertices(node, G); v != ve; ++v) { + for (boost::tie(v, ve) = adjacent_vertices(node, G); v != ve; ++v) { vertex_t v_node = *v; if (!degree_lists_marker.need_update(v_node) && !degree_lists_marker.outmatched_or_done(v_node)) { @@ -456,7 +456,7 @@ namespace boost { vertex_t current = get(index_vertex_map, llist.top()); adj_iter i, ie; - for (tie(i,ie) = adjacent_vertices(current, G); i != ie; ++i) { + for (boost::tie(i,ie) = adjacent_vertices(current, G); i != ie; ++i) { vertex_t i_node = *i; const size_type i_id = get(vertex_index_map, i_node); if (supernode_size[i_node] != 0) { @@ -490,7 +490,7 @@ namespace boost { } if (numbering.is_numbered(neighbor)) { adj_iter i, ie; - for (tie(i,ie) = adjacent_vertices(neighbor, G); + for (boost::tie(i,ie) = adjacent_vertices(neighbor, G); i != ie; ++i) { const vertex_t i_node = *i; if (i_node == u_node || supernode_size[i_node] == 0) @@ -536,7 +536,7 @@ namespace boost { marker.increment_tag(); deg = deg0; adj_iter i, ie; - for (tie(i, ie) = adjacent_vertices(u_node, G); i != ie; ++i) { + for (boost::tie(i, ie) = adjacent_vertices(u_node, G); i != ie; ++i) { vertex_t i_node = *i; if (marker.is_tagged(i_node)) continue; @@ -544,7 +544,7 @@ namespace boost { if (numbering.is_numbered(i_node)) { adj_iter j, je; - for (tie(j, je) = adjacent_vertices(i_node, G); j != je; ++j) { + for (boost::tie(j, je) = adjacent_vertices(i_node, G); j != je; ++j) { const vertex_t j_node = *j; if (marker.is_not_tagged(j_node)) { marker.mark_tagged(j_node); diff --git a/include/boost/graph/neighbor_bfs.hpp b/include/boost/graph/neighbor_bfs.hpp index 01cfe49b..3ed94fc5 100644 --- a/include/boost/graph/neighbor_bfs.hpp +++ b/include/boost/graph/neighbor_bfs.hpp @@ -152,7 +152,7 @@ namespace boost { vis.examine_vertex(u, g); typename GTraits::out_edge_iterator ei, ei_end; - for (tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) { + for (boost::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) { Edge e = *ei; vis.examine_out_edge(e, g); Vertex v = target(e, g); @@ -172,7 +172,7 @@ namespace boost { } // for out-edges typename GTraits::in_edge_iterator in_ei, in_ei_end; - for (tie(in_ei, in_ei_end) = in_edges(u, g); + for (boost::tie(in_ei, in_ei_end) = in_edges(u, g); in_ei != in_ei_end; ++in_ei) { Edge e = *in_ei; vis.examine_in_edge(e, g); @@ -216,7 +216,7 @@ namespace boost { typedef typename property_traits::value_type ColorValue; typedef color_traits Color; typename boost::graph_traits::vertex_iterator i, i_end; - for (tie(i, i_end) = vertices(g); i != i_end; ++i) { + for (boost::tie(i, i_end) = vertices(g); i != i_end; ++i) { put(color, *i, Color::white()); vis.initialize_vertex(*i, g); } diff --git a/include/boost/graph/page_rank.hpp b/include/boost/graph/page_rank.hpp index 9532260f..a8987046 100644 --- a/include/boost/graph/page_rank.hpp +++ b/include/boost/graph/page_rank.hpp @@ -142,7 +142,7 @@ remove_dangling_links(MutableGraph& g old_n = num_vertices(g); typename graph_traits::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; /* in loop */) { + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; /* in loop */) { typename graph_traits::vertex_descriptor v = *vi++; if (out_degree(v, g) == 0) { clear_vertex(v, g); diff --git a/include/boost/graph/planar_detail/boyer_myrvold_impl.hpp b/include/boost/graph/planar_detail/boyer_myrvold_impl.hpp index ee31c85e..71607fcb 100644 --- a/include/boost/graph/planar_detail/boyer_myrvold_impl.hpp +++ b/include/boost/graph/planar_detail/boyer_myrvold_impl.hpp @@ -346,7 +346,7 @@ namespace boost // the walkup and consumed by the walkdown. vertex_iterator_t vi, vi_end; - for(tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) + for(boost::tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) { vertex_t v(*vi); vertex_t parent = dfs_parent[v]; @@ -471,7 +471,7 @@ namespace boost typedef typename face_vertex_iterator::type walkup_iterator_t; out_edge_iterator_t oi, oi_end; - for(tie(oi,oi_end) = out_edges(v,g); oi != oi_end; ++oi) + for(boost::tie(oi,oi_end) = out_edges(v,g); oi != oi_end; ++oi) { edge_t e(*oi); vertex_t e_source(source(e,g)); @@ -689,7 +689,7 @@ namespace boost = face_handles[first_tail].first_vertex(); vertex_t second = face_handles[first_tail].second_vertex(); - tie(first_side_vertex, first_tail) + boost::tie(first_side_vertex, first_tail) = make_tuple(first_tail, first == first_side_vertex ? second : first @@ -701,7 +701,7 @@ namespace boost = face_handles[second_tail].first_vertex(); vertex_t second = face_handles[second_tail].second_vertex(); - tie(second_side_vertex, second_tail) + boost::tie(second_side_vertex, second_tail) = make_tuple(second_tail, first == second_side_vertex ? second : first); @@ -790,10 +790,10 @@ namespace boost { bottom_path_follows_first = next_bottom_follows_first; - tie(merge_point, - next_bottom_follows_first, - top_path_follows_first - ) = merge_stack.back(); + boost::tie(merge_point, + next_bottom_follows_first, + top_path_follows_first + ) = merge_stack.back(); merge_stack.pop_back(); face_handle_t top_handle(face_handles[merge_point]); @@ -918,7 +918,7 @@ namespace boost // planar embedding no matter what order we embed them in. vertex_iterator_t xi, xi_end; - for(tie(xi,xi_end) = vertices(g); xi != xi_end; ++xi) + for(boost::tie(xi,xi_end) = vertices(g); xi != xi_end; ++xi) { if (!separated_dfs_child_list[*xi]->empty()) { @@ -1058,10 +1058,10 @@ namespace boost bool seen_goal_edge = false; out_edge_iterator_t oi, oi_end; - for(tie(oi,oi_end) = out_edges(v,g); oi != oi_end; ++oi) + for(boost::tie(oi,oi_end) = out_edges(v,g); oi != oi_end; ++oi) forbidden_edge[*oi] = true; - for(tie(oi,oi_end) = out_edges(v,g); oi != oi_end; ++oi) + for(boost::tie(oi,oi_end) = out_edges(v,g); oi != oi_end; ++oi) { path_edges.clear(); @@ -1195,7 +1195,7 @@ namespace boost // Clear the short-circuit edges - these are needed for the planar // testing/embedding algorithm to run in linear time, but they'll // complicate the kuratowski subgraph isolation - for(tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) + for(boost::tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) { face_handles[*vi].reset_vertex_cache(); dfs_child_handles[*vi].reset_vertex_cache(); @@ -1352,7 +1352,7 @@ namespace boost //Find external path to x and to y - for(tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for(boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { edge_t e(*ei); goal_edge[e] @@ -1376,7 +1376,7 @@ namespace boost } - for(tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for(boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { edge_t e(*ei); goal_edge[e] @@ -1407,13 +1407,13 @@ namespace boost { chosen_case = detail::BM_CASE_A; - for(tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) + for(boost::tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) if (lower_face_vertex[*vi]) - for(tie(oei,oei_end) = out_edges(*vi,g); oei != oei_end; ++oei) + for(boost::tie(oei,oei_end) = out_edges(*vi,g); oei != oei_end; ++oei) if(!outer_face_edge[*oei]) goal_edge[*oei] = true; - for(tie(ei,ei_end) = edges(g); ei != ei_end; ++ei) + for(boost::tie(ei,ei_end) = edges(g); ei != ei_end; ++ei) forbidden_edge[*ei] = outer_face_edge[*ei]; z = kuratowski_walkup @@ -1424,7 +1424,7 @@ namespace boost { chosen_case = detail::BM_CASE_B; - for(tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for(boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { edge_t e(*ei); goal_edge[e] = false; @@ -1442,7 +1442,7 @@ namespace boost ); - for(tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for(boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { forbidden_edge[*ei] = outer_face_edge[*ei]; } @@ -1646,7 +1646,7 @@ namespace boost //First, get a list of all of v's embedded child edges out_edge_iterator_t v_edge_itr, v_edge_end; - for(tie(v_edge_itr,v_edge_end) = out_edges(v,g); + for(boost::tie(v_edge_itr,v_edge_end) = out_edges(v,g); v_edge_itr != v_edge_end; ++v_edge_itr ) { @@ -1711,7 +1711,7 @@ namespace boost //Finding z and w. - for(tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for(boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { edge_t e(*ei); goal_edge[e] = !outer_face_edge[e] && @@ -1729,14 +1729,14 @@ namespace boost if (chosen_case == detail::BM_CASE_E) { - for(tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for(boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { forbidden_edge[*ei] = outer_face_edge[*ei]; goal_edge[*ei] = !outer_face_edge[*ei] && (source(*ei,g) == w || target(*ei,g) == w); } - for(tie(oei, oei_end) = out_edges(w,g); oei != oei_end; ++oei) + for(boost::tie(oei, oei_end) = out_edges(w,g); oei != oei_end; ++oei) { if (!outer_face_edge[*oei]) goal_edge[*oei] = true; @@ -1800,7 +1800,7 @@ namespace boost while(child != parent) { is_in_subgraph[dfs_parent_edge[child]] = true; - tie(parent, child) = std::make_pair( dfs_parent[parent], parent ); + boost::tie(parent, child) = std::make_pair( dfs_parent[parent], parent ); } @@ -1928,7 +1928,7 @@ namespace boost } - for(tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for(boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) if (is_in_subgraph[*ei]) *o_itr = *ei; @@ -1940,7 +1940,7 @@ namespace boost void make_edge_permutation(EdgePermutation perm) { vertex_iterator_t vi, vi_end; - for(tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) + for(boost::tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) { vertex_t v(*vi); perm[v].clear(); diff --git a/include/boost/graph/profile.hpp b/include/boost/graph/profile.hpp old mode 100755 new mode 100644 index 1ba2d249..1ff99de5 --- a/include/boost/graph/profile.hpp +++ b/include/boost/graph/profile.hpp @@ -23,7 +23,7 @@ namespace boost { { typename graph_traits::vertices_size_type b = 0; typename graph_traits::vertex_iterator i, end; - for (tie(i, end) = vertices(g); i != end; ++i){ + for (boost::tie(i, end) = vertices(g); i != end; ++i){ b += ith_bandwidth(*i, g, index) + 1; } diff --git a/include/boost/graph/push_relabel_max_flow.hpp b/include/boost/graph/push_relabel_max_flow.hpp index 2b654709..34a8212a 100644 --- a/include/boost/graph/push_relabel_max_flow.hpp +++ b/include/boost/graph/push_relabel_max_flow.hpp @@ -141,12 +141,12 @@ namespace boost { // Initialize flow to zero which means initializing // the residual capacity to equal the capacity. out_edge_iterator ei, e_end; - for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) - for (tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) { + for (boost::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) + for (boost::tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) { residual_capacity[*ei] = capacity[*ei]; } - for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) { + for (boost::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) { vertex_descriptor u = *u_iter; excess_flow[u] = 0; current[u] = out_edges(u, g); @@ -156,7 +156,7 @@ namespace boost { FlowValue test_excess = 0; out_edge_iterator a_iter, a_end; - for (tie(a_iter, a_end) = out_edges(src, g); a_iter != a_end; ++a_iter) + for (boost::tie(a_iter, a_end) = out_edges(src, g); a_iter != a_end; ++a_iter) if (target(*a_iter, g) != src) test_excess += residual_capacity[*a_iter]; if (test_excess > (std::numeric_limits::max)()) @@ -166,7 +166,7 @@ namespace boost { excess_flow[src] = (std::numeric_limits::max)(); else { excess_flow[src] = 0; - for (tie(a_iter, a_end) = out_edges(src, g); + for (boost::tie(a_iter, a_end) = out_edges(src, g); a_iter != a_end; ++a_iter) { edge_descriptor a = *a_iter; if (target(a, g) != src) { @@ -182,7 +182,7 @@ namespace boost { max_active = 0; min_active = n; - for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) { + for (boost::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) { vertex_descriptor u = *u_iter; if (u == sink) { distance[u] = 0; @@ -211,7 +211,7 @@ namespace boost { BOOST_USING_STD_MAX(); ++update_count; vertex_iterator u_iter, u_end; - for (tie(u_iter,u_end) = vertices(g); u_iter != u_end; ++u_iter) { + for (boost::tie(u_iter,u_end) = vertices(g); u_iter != u_end; ++u_iter) { color[*u_iter] = ColorTraits::white(); distance[*u_iter] = n; } @@ -233,7 +233,7 @@ namespace boost { distance_size_type d_v = distance[u] + 1; out_edge_iterator ai, a_end; - for (tie(ai, a_end) = out_edges(u, g); ai != a_end; ++ai) { + for (boost::tie(ai, a_end) = out_edges(u, g); ai != a_end; ++ai) { edge_descriptor a = *ai; vertex_descriptor v = target(a, g); if (color[v] == ColorTraits::white() @@ -262,7 +262,7 @@ namespace boost { assert(excess_flow[u] > 0); while (1) { out_edge_iterator ai, ai_end; - for (tie(ai, ai_end) = current[u]; ai != ai_end; ++ai) { + for (boost::tie(ai, ai_end) = current[u]; ai != ai_end; ++ai) { edge_descriptor a = *ai; if (is_residual_edge(a)) { vertex_descriptor v = target(a, g); @@ -337,7 +337,7 @@ namespace boost { // Examine the residual out-edges of vertex i, choosing the // edge whose target vertex has the minimal distance. out_edge_iterator ai, a_end, min_edge_iter; - for (tie(ai, a_end) = out_edges(u, g); ai != a_end; ++ai) { + for (boost::tie(ai, a_end) = out_edges(u, g); ai != a_end; ++ai) { ++work_since_last_update; edge_descriptor a = *ai; vertex_descriptor v = target(a, g); @@ -433,20 +433,20 @@ namespace boost { bool bos_null = true; // handle self-loops - for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) - for (tie(ai, a_end) = out_edges(*u_iter, g); ai != a_end; ++ai) + for (boost::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) + for (boost::tie(ai, a_end) = out_edges(*u_iter, g); ai != a_end; ++ai) if (target(*ai, g) == *u_iter) residual_capacity[*ai] = capacity[*ai]; // initialize - for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) { + for (boost::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) { u = *u_iter; color[u] = ColorTraits::white(); parent[u] = u; current[u] = out_edges(u, g); } // eliminate flow cycles and topologically order the vertices - for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) { + for (boost::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) { u = *u_iter; if (color[u] == ColorTraits::white() && excess_flow[u] > 0 @@ -532,7 +532,7 @@ namespace boost { // note that the sink is not on the stack if (! bos_null) { for (u = tos; u != bos; u = topo_next[u]) { - tie(ai, a_end) = out_edges(u, g); + boost::tie(ai, a_end) = out_edges(u, g); while (excess_flow[u] > 0 && ai != a_end) { if (capacity[*ai] == 0 && is_residual_edge(*ai)) push_flow(*ai); @@ -558,8 +558,8 @@ namespace boost { out_edge_iterator ai, a_end; // check edge flow values - for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) { - for (tie(ai, a_end) = out_edges(*u_iter, g); ai != a_end; ++ai) { + for (boost::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) { + for (boost::tie(ai, a_end) = out_edges(*u_iter, g); ai != a_end; ++ai) { edge_descriptor a = *ai; if (capacity[a] > 0) if ((residual_capacity[a] + residual_capacity[reverse_edge[a]] @@ -572,13 +572,13 @@ namespace boost { // check conservation FlowValue sum; - for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) { + for (boost::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) { vertex_descriptor u = *u_iter; if (u != src && u != sink) { if (excess_flow[u] != 0) return false; sum = 0; - for (tie(ai, a_end) = out_edges(u, g); ai != a_end; ++ai) + for (boost::tie(ai, a_end) = out_edges(u, g); ai != a_end; ++ai) if (capacity[*ai] > 0) sum -= capacity[*ai] - residual_capacity[*ai]; else @@ -611,8 +611,8 @@ namespace boost { os << "flow values" << std::endl; vertex_iterator u_iter, u_end; out_edge_iterator ei, e_end; - for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) - for (tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) + for (boost::tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) + for (boost::tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) if (capacity[*ei] > 0) os << *u_iter << " " << target(*ei, g) << " " << (capacity[*ei] - residual_capacity[*ei]) << std::endl; diff --git a/include/boost/graph/r_c_shortest_paths.hpp b/include/boost/graph/r_c_shortest_paths.hpp index b1bd7574..37bf3f34 100644 --- a/include/boost/graph/r_c_shortest_paths.hpp +++ b/include/boost/graph/r_c_shortest_paths.hpp @@ -359,7 +359,7 @@ void r_c_shortest_paths_dispatch typename graph_traits::vertex_descriptor cur_vertex = cur_label->resident_vertex; typename graph_traits::out_edge_iterator oei, oei_end; - for( tie( oei, oei_end ) = out_edges( cur_vertex, g ); + for( boost::tie( oei, oei_end ) = out_edges( cur_vertex, g ); oei != oei_end; ++oei ) { diff --git a/include/boost/graph/random.hpp b/include/boost/graph/random.hpp index bc53b8f3..c79c9c68 100644 --- a/include/boost/graph/random.hpp +++ b/include/boost/graph/random.hpp @@ -12,10 +12,12 @@ #include #include +#include #include #include #include +#include #include #include @@ -24,6 +26,7 @@ #include #include +#include namespace boost { @@ -67,6 +70,43 @@ namespace boost { return *edges(g).first; } + template + typename graph_traits::edge_descriptor + random_out_edge(Graph& g, typename graph_traits::vertex_descriptor src, RandomNumGen& gen) { + typedef typename graph_traits::degree_size_type degree_size_type; + typedef boost::uniform_int ui_type; + ui_type ui(0, out_degree(src, g) - 1); + boost::variate_generator + variate(gen, ui); + typename graph_traits::out_edge_iterator it = out_edges(src, g).first; + std::advance(it, variate()); + return *it; + } + + template + typename graph_traits::edge_descriptor + weighted_random_out_edge(Graph& g, typename graph_traits::vertex_descriptor src, WeightMap weight, RandomNumGen& gen) { + typedef graph_traits gt; + typedef typename gt::vertex_descriptor vertex_descriptor; + typedef typename property_traits::value_type weight_type; + weight_type weight_sum(0); + BGL_FORALL_OUTEDGES_T(src, e, g, Graph) {weight_sum += get(weight, e);} + typedef boost::uniform_real<> ur_type; + ur_type ur(0, weight_sum); + boost::variate_generator + variate(gen, ur); + weight_type chosen_weight = variate(); + BGL_FORALL_OUTEDGES_T(src, e, g, Graph) { + weight_type w = get(weight, e); + if (chosen_weight < w) { + return e; + } else { + chosen_weight -= w; + } + } + assert (false); // Should not get here + } + namespace detail { class dummy_property_copier { public: @@ -157,7 +197,7 @@ namespace boost { b = random_vertex(g, gen); } while (self_edges == false && a == b); edge_t e; bool inserted; - tie(e, inserted) = add_edge(a, b, g); + boost::tie(e, inserted) = add_edge(a, b, g); if (inserted) *edge_out++ = std::make_pair(source(e, g), target(e, g)); } @@ -171,7 +211,7 @@ namespace boost { { typename property_map::type pm = get(Property(), g); typename graph_traits::vertex_iterator vi, ve; - for (tie(vi, ve) = vertices(g); vi != ve; ++vi) { + for (boost::tie(vi, ve) = vertices(g); vi != ve; ++vi) { pm[*vi] = rg(); } } @@ -182,7 +222,7 @@ namespace boost { { typename property_map::type pm = get(Property(), g); typename graph_traits::edge_iterator ei, ee; - for (tie(ei, ee) = edges(g); ei != ee; ++ei) { + for (boost::tie(ei, ee) = edges(g); ei != ee; ++ei) { pm[*ei] = rg(); } } @@ -200,5 +240,6 @@ namespace boost { } +#include #endif diff --git a/include/boost/graph/random_spanning_tree.hpp b/include/boost/graph/random_spanning_tree.hpp new file mode 100644 index 00000000..e9f95fe5 --- /dev/null +++ b/include/boost/graph/random_spanning_tree.hpp @@ -0,0 +1,103 @@ +// Copyright 2010 The Trustees of Indiana University. + +// 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) + +// Authors: Jeremiah Willcock +// Andrew Lumsdaine + +#ifndef BOOST_GRAPH_RANDOM_SPANNING_TREE_HPP +#define BOOST_GRAPH_RANDOM_SPANNING_TREE_HPP + +#include +#include +#include +#include +#include + +namespace boost { + + namespace detail { + // Use Wilson's algorithm (based on loop-free random walks) to generate a + // random spanning tree. The distribution of edges used is controlled by + // the next_edge() function, so this version allows either weighted or + // unweighted selection of trees. + // Algorithm is from http://en.wikipedia.org/wiki/Uniform_spanning_tree + template + void random_spanning_tree_internal(const Graph& g, PredMap pred, ColorMap color, NextEdge next_edge) { + typedef typename graph_traits::vertex_descriptor vertex_descriptor; + typedef typename graph_traits::edge_descriptor edge_descriptor; + + assert (num_vertices(g) >= 2); // g must also be undirected (or symmetric) and connected + + typedef color_traits::value_type> color_gen; + BGL_FORALL_VERTICES_T(v, g, Graph) put(color, v, color_gen::white()); + + std::vector path; + + vertex_descriptor s = *vertices(g).first; + put(color, s, color_gen::black()); + put(pred, s, graph_traits::null_vertex()); + + BGL_FORALL_VERTICES_T(v, g, Graph) { + if (get(color, v) != color_gen::white()) continue; + loop_erased_random_walk(g, v, next_edge, color, path); + for (typename std::vector::const_reverse_iterator i = path.rbegin(); + boost::next(i) != path.rend(); ++i) { + typename std::vector::const_reverse_iterator j = i; + ++j; + assert (get(color, *j) == color_gen::gray()); + put(color, *j, color_gen::black()); + put(pred, *j, *i); + } + } + } + } + + // Compute a uniformly-distributed spanning tree on a graph. + template + void random_spanning_tree(const Graph& g, PredMap pred, Gen& gen, ColorMap color) { + unweighted_random_out_edge_gen random_oe(gen); + detail::random_spanning_tree_internal(g, pred, color, random_oe); + } + + // Compute a uniformly-distributed spanning tree on a graph. + template + void random_spanning_tree(const Graph& g, PredMap pred, Gen& gen) { + std::vector color_data(num_vertices(g)); + random_spanning_tree(g, pred, gen, make_iterator_property_map(color_data.begin(), get(vertex_index, g))); + } + + // Compute a weight-distributed spanning tree on a graph. + // Weighting works according to: + // @article{Mosbah1999263, + // title = "Non-uniform random spanning trees on weighted graphs", + // journal = "Theoretical Computer Science", + // volume = "218", + // number = "2", + // pages = "263--271", + // year = "1999", + // note = "", + // issn = "0304-3975", + // doi = "DOI: 10.1016/S0304-3975(98)00325-9", + // url = "http://www.sciencedirect.com/science/article/B6V1G-3WSV1D9-P/2/06bea092e23163c4884844cde4a5e92c", + // author = "M. Mosbah and N. Saheb" + // } + template + void weighted_random_spanning_tree(const Graph& g, PredMap pred, WeightMap weight, Gen& gen, ColorMap color) { + weighted_random_out_edge_gen random_oe(weight, gen); + detail::random_spanning_tree_internal(g, pred, color, random_oe); + } + + // Compute a weight-distributed spanning tree on a graph. + template + void weighted_random_spanning_tree(const Graph& g, PredMap pred, WeightMap weight, Gen& gen) { + std::vector color_data(num_vertices(g)); + weighted_random_spanning_tree(g, pred, weight, gen, make_iterator_property_map(color_data.begin(), get(vertex_index, g))); + } +} + +#include + +#endif // BOOST_GRAPH_RANDOM_SPANNING_TREE_HPP diff --git a/include/boost/graph/read_dimacs.hpp b/include/boost/graph/read_dimacs.hpp index f31482a4..aad8dbab 100644 --- a/include/boost/graph/read_dimacs.hpp +++ b/include/boost/graph/read_dimacs.hpp @@ -228,8 +228,8 @@ int read_dimacs_max_flow(Graph& g, { edge_descriptor e1, e2; bool in1, in2; - tie(e1, in1) = add_edge(verts[tail], verts[head], g); - tie(e2, in2) = add_edge(verts[head], verts[tail], g); + boost::tie(e1, in1) = add_edge(verts[tail], verts[head], g); + boost::tie(e2, in2) = add_edge(verts[head], verts[tail], g); if (!in1 || !in2) { std::cerr << "unable to add edge (" << head << "," << tail << ")" << std::endl; diff --git a/include/boost/graph/reverse_graph.hpp b/include/boost/graph/reverse_graph.hpp index 3a81c294..5669bb9b 100644 --- a/include/boost/graph/reverse_graph.hpp +++ b/include/boost/graph/reverse_graph.hpp @@ -220,7 +220,7 @@ adjacent_vertices(typename graph_traits::vertex_descriptor u { typedef reverse_graph Graph; typename graph_traits::out_edge_iterator first, last; - tie(first, last) = out_edges(u, g); + boost::tie(first, last) = out_edges(u, g); typedef typename graph_traits::adjacency_iterator adjacency_iterator; return std::make_pair(adjacency_iterator(first, const_cast(&g)), adjacency_iterator(last, const_cast(&g))); diff --git a/include/boost/graph/rmat_graph_generator.hpp b/include/boost/graph/rmat_graph_generator.hpp index 8761b0c8..9e8cfd54 100644 --- a/include/boost/graph/rmat_graph_generator.hpp +++ b/include/boost/graph/rmat_graph_generator.hpp @@ -164,7 +164,7 @@ namespace boost { // Generate the first edge vertices_size_type u, v; - tie(u, v) = generate_edge(this->gen, n, SCALE, a, b, c, d); + boost::tie(u, v) = generate_edge(this->gen, n, SCALE, a, b, c, d); if (permute_vertices) current = std::make_pair(vertexPermutation[u], @@ -181,7 +181,7 @@ namespace boost { rmat_iterator& operator++() { vertices_size_type u, v; - tie(u, v) = generate_edge(this->gen, n, SCALE, a, b, c, d); + boost::tie(u, v) = generate_edge(this->gen, n, SCALE, a, b, c, d); if (permute_vertices) current = std::make_pair(vertexPermutation[u], @@ -279,7 +279,7 @@ namespace boost { for (edges_size_type i = 0; i < m; ++i) { vertices_size_type u, v; - tie(u, v) = generate_edge(this->gen, n, SCALE, a, b, c, d); + boost::tie(u, v) = generate_edge(this->gen, n, SCALE, a, b, c, d); if (permute_vertices) { if (ep(vertexPermutation[u], vertexPermutation[v])) @@ -381,7 +381,7 @@ namespace boost { edges_size_type edges = 0; do { vertices_size_type u, v; - tie(u, v) = generate_edge(this->gen, n, SCALE, a, b, c, d); + boost::tie(u, v) = generate_edge(this->gen, n, SCALE, a, b, c, d); // Lowest vertex number always comes first // (this means we don't have to worry about i->j and j->i being in the edge list) @@ -495,7 +495,7 @@ namespace boost { do { vertices_size_type u, v; - tie(u, v) = generate_edge(this->gen, n, SCALE, a, b, c, d); + boost::tie(u, v) = generate_edge(this->gen, n, SCALE, a, b, c, d); if (bidirectional) { if (edge_map.find(std::make_pair(u, v)) == edge_map.end()) { diff --git a/include/boost/graph/sequential_vertex_coloring.hpp b/include/boost/graph/sequential_vertex_coloring.hpp index f5362b3c..6bca0843 100644 --- a/include/boost/graph/sequential_vertex_coloring.hpp +++ b/include/boost/graph/sequential_vertex_coloring.hpp @@ -61,7 +61,7 @@ namespace boost { //Initialize colors typename GraphTraits::vertex_iterator v, vend; - for (tie(v, vend) = vertices(G); v != vend; ++v) + for (boost::tie(v, vend) = vertices(G); v != vend; ++v) put(color, *v, V-1); //Determine the color for every vertex one by one @@ -71,7 +71,7 @@ namespace boost { //Mark the colors of vertices adjacent to current. //i can be the value for marking since i increases successively - for (tie(v,vend) = adjacent_vertices(current, G); v != vend; ++v) + for (boost::tie(v,vend) = adjacent_vertices(current, G); v != vend; ++v) mark[get(color,*v)] = i; //Next step is to assign the smallest un-marked color diff --git a/include/boost/graph/sloan_ordering.hpp b/include/boost/graph/sloan_ordering.hpp index ff5748dd..781e9c9f 100644 --- a/include/boost/graph/sloan_ordering.hpp +++ b/include/boost/graph/sloan_ordering.hpp @@ -139,7 +139,7 @@ namespace boost { //step 1 //Scan for the vertex with the smallest degree and the maximum degree typename graph_traits::vertex_iterator ui, ui_end; - for (tie(ui, ui_end) = vertices(G); ui != ui_end; ++ui) + for (boost::tie(ui, ui_end) = vertices(G); ui != ui_end; ++ui) { dummy = get(degree, *ui); @@ -180,7 +180,7 @@ namespace boost { //step 4 //pushing one node of each degree in an ascending manner into degree_queue std::vector shrink_trace(maximum_degree, false); - for (tie(ui, ui_end) = vertices(G); ui != ui_end; ++ui) + for (boost::tie(ui, ui_end) = vertices(G); ui != ui_end; ++ui) { dummy = get(degree, *ui); @@ -292,7 +292,7 @@ namespace boost { //Sets the color and priority to their initial status unsigned cdeg; typename graph_traits::vertex_iterator ui, ui_end; - for (tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui) + for (boost::tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui) { put(color, *ui, Color::white()); cdeg=get(degree, *ui)+1; @@ -321,7 +321,7 @@ namespace boost { if(get(color, u) == Color::green() ) { //for-loop over all out-edges of vertex u - for (tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) + for (boost::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) { v = target(*ei, g); @@ -340,7 +340,7 @@ namespace boost { put(color, u, Color::black() ); //Gives u an inactive status //for loop over all the adjacent vertices of u - for (tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) { + for (boost::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) { v = target(*ei, g); @@ -350,7 +350,7 @@ namespace boost { put(priority, v, get(priority, v)+W2); //updates the priority //for loop over alll adjacent vertices of v - for (tie(ei2, ei2_end) = out_edges(v, g); ei2 != ei2_end; ++ei2) { + for (boost::tie(ei2, ei2_end) = out_edges(v, g); ei2 != ei2_end; ++ei2) { w = target(*ei2, g); if(get(color, w) != Color::black() ) { //tests if vertex is postactive diff --git a/include/boost/graph/strong_components.hpp b/include/boost/graph/strong_components.hpp index 9469010a..6494283e 100644 --- a/include/boost/graph/strong_components.hpp +++ b/include/boost/graph/strong_components.hpp @@ -54,7 +54,7 @@ namespace boost { const Graph& g) { typename graph_traits::vertex_descriptor w; typename graph_traits::out_edge_iterator ei, ei_end; - for (tie(ei, ei_end) = out_edges(v, g); ei != ei_end; ++ei) { + for (boost::tie(ei, ei_end) = out_edges(v, g); ei != ei_end; ++ei) { w = target(*ei, g); if (get(comp, w) == (std::numeric_limits::max)()) put(root, v, this->min_discover_time(get(root,v), get(root,w))); @@ -249,7 +249,7 @@ namespace boost { { components.resize(num_scc); typename graph_traits::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) components[component_number[*vi]].push_back(*vi); } @@ -304,7 +304,7 @@ namespace boost { // initialize G_T typename graph_traits::vertex_iterator ui, ui_end; - for (tie(ui, ui_end) = vertices(G_T); ui != ui_end; ++ui) + for (boost::tie(ui, ui_end) = vertices(G_T); ui != ui_end; ++ui) put(color, *ui, Color::white()); typedef typename property_traits::value_type D; @@ -314,8 +314,8 @@ namespace boost { std::priority_queue, Compare > Q(fl); typename graph_traits::vertex_iterator i, j, iend, jend; - tie(i, iend) = vertices(G_T); - tie(j, jend) = vertices(G); + boost::tie(i, iend) = vertices(G_T); + boost::tie(j, jend) = vertices(G); for ( ; i != iend; ++i, ++j) { put(finish_time, *i, get(finish_time, *j)); Q.push(*i); diff --git a/include/boost/graph/subgraph.hpp b/include/boost/graph/subgraph.hpp index 15cdace5..093da7b0 100644 --- a/include/boost/graph/subgraph.hpp +++ b/include/boost/graph/subgraph.hpp @@ -124,7 +124,7 @@ typedef typename Traits::traversal_category traversal_category; { typename Graph::vertex_iterator v, v_end; vertices_size_type i = 0; - for(tie(v, v_end) = vertices(m_graph); v != v_end; ++v) + for(boost::tie(v, v_end) = vertices(m_graph); v != v_end; ++v) m_global_vertex[i++] = *v; } @@ -180,7 +180,7 @@ typedef typename Traits::traversal_category traversal_category; vertex_descriptor global_to_local(vertex_descriptor u_global) const { vertex_descriptor u_local; bool in_subgraph; if (is_root()) return u_global; - tie(u_local, in_subgraph) = this->find_vertex(u_global); + boost::tie(u_local, in_subgraph) = this->find_vertex(u_global); assert(in_subgraph == true); return u_local; } @@ -315,7 +315,7 @@ public: // Probably shouldn't be public.... { edge_descriptor e_local; bool inserted; - tie(e_local, inserted) = add_edge(u_local, v_local, m_graph); + boost::tie(e_local, inserted) = add_edge(u_local, v_local, m_graph); put(edge_index, m_graph, e_local, m_edge_counter++); m_global_edge.push_back(e_global); m_local_edge[get(get(edge_index, this->root()), e_global)] = e_local; @@ -358,7 +358,7 @@ add_vertex(typename subgraph::vertex_descriptor u_global, // remember edge global and local maps { typename subgraph::out_edge_iterator ei, ei_end; - for (tie(ei, ei_end) = out_edges(u_global, r); + for (boost::tie(ei, ei_end) = out_edges(u_global, r); ei != ei_end; ++ei) { e_global = *ei; v_global = target(e_global, r); @@ -369,10 +369,10 @@ add_vertex(typename subgraph::vertex_descriptor u_global, if (is_directed(g)) { // not necessary for undirected graph typename subgraph::vertex_iterator vi, vi_end; typename subgraph::out_edge_iterator ei, ei_end; - for(tie(vi, vi_end) = vertices(r); vi != vi_end; ++vi) { + for(boost::tie(vi, vi_end) = vertices(r); vi != vi_end; ++vi) { v_global = *vi; if(g.find_vertex(v_global).second) - for(tie(ei, ei_end) = out_edges(*vi, r); ei != ei_end; ++ei) { + for(boost::tie(ei, ei_end) = out_edges(*vi, r); ei != ei_end; ++ei) { e_global = *ei; uu_global = target(e_global, r); if(uu_global == u_global && g.find_vertex(v_global).second) { @@ -507,8 +507,8 @@ namespace detail { // add local edge only if u_global and v_global are in subgraph g Vertex u_local, v_local; bool u_in_subgraph, v_in_subgraph; - tie(u_local, u_in_subgraph) = g.find_vertex(u_global); - tie(v_local, v_in_subgraph) = g.find_vertex(v_global); + boost::tie(u_local, u_in_subgraph) = g.find_vertex(u_global); + boost::tie(v_local, v_in_subgraph) = g.find_vertex(v_global); if(u_in_subgraph && v_in_subgraph) { g.local_add_edge(u_local, v_local, e_global); } @@ -525,7 +525,7 @@ namespace detail { if(g.is_root()) { typename subgraph::edge_descriptor e_global; bool inserted; - tie(e_global, inserted) = add_edge(u_global, v_global, ep, g.m_graph); + boost::tie(e_global, inserted) = add_edge(u_global, v_global, ep, g.m_graph); put(edge_index, g.m_graph, e_global, g.m_edge_counter++); g.m_global_edge.push_back(e_global); children_add_edge(u_global, v_global, e_global, g.m_children, orig); @@ -554,7 +554,7 @@ add_edge(typename subgraph::vertex_descriptor u, } else { typename subgraph::edge_descriptor e_local, e_global; bool inserted; - tie(e_global, inserted) = + boost::tie(e_global, inserted) = detail::add_edge_recur_up(g.local_to_global(u), g.local_to_global(v), ep, g, &g); diff --git a/include/boost/graph/transitive_closure.hpp b/include/boost/graph/transitive_closure.hpp index 378dacf5..01bfb3d3 100644 --- a/include/boost/graph/transitive_closure.hpp +++ b/include/boost/graph/transitive_closure.hpp @@ -101,7 +101,7 @@ namespace boost for (size_type i = 0; i < components[s].size(); ++i) { vertex u = components[s][i]; adjacency_iterator v, v_end; - for (tie(v, v_end) = adjacent_vertices(u, g); v != v_end; ++v) { + for (boost::tie(v, v_end) = adjacent_vertices(u, g); v != v_end; ++v) { cg_vertex t = component_number[*v]; if (s != t) // Avoid loops in the condensation graph adj.push_back(t); @@ -144,7 +144,7 @@ namespace boost chain.push_back(v); in_a_chain[v] = true; typename graph_traits::adjacency_iterator adj_first, adj_last; - tie(adj_first, adj_last) = adjacent_vertices(v, CG); + boost::tie(adj_first, adj_last) = adjacent_vertices(v, CG); typename graph_traits::adjacency_iterator next = std::find_if(adj_first, adj_last, std::not1(detail::subscript(in_a_chain))); @@ -174,7 +174,7 @@ namespace boost i = topo_order.rbegin(); i != topo_order.rend(); ++i) { cg_vertex u = *i; typename graph_traits::adjacency_iterator adj, adj_last; - for (tie(adj, adj_last) = adjacent_vertices(u, CG); + for (boost::tie(adj, adj_last) = adjacent_vertices(u, CG); adj != adj_last; ++adj) { cg_vertex v = *adj; if (topo_number[v] < successors[u][chain_number[v]]) { @@ -204,15 +204,15 @@ namespace boost typedef typename graph_traits < GraphTC >::vertex_descriptor tc_vertex; { vertex_iterator i, i_end; - for (tie(i, i_end) = vertices(g); i != i_end; ++i) + for (boost::tie(i, i_end) = vertices(g); i != i_end; ++i) g_to_tc_map[*i] = add_vertex(tc); } // Add edges between all the vertices in two adjacent SCCs typename graph_traits::vertex_iterator si, si_end; - for (tie(si, si_end) = vertices(CG); si != si_end; ++si) { + for (boost::tie(si, si_end) = vertices(CG); si != si_end; ++si) { cg_vertex s = *si; typename graph_traits::adjacency_iterator i, i_end; - for (tie(i, i_end) = adjacent_vertices(s, CG); i != i_end; ++i) { + for (boost::tie(i, i_end) = adjacent_vertices(s, CG); i != i_end; ++i) { cg_vertex t = *i; for (size_type k = 0; k < components[s].size(); ++k) for (size_type l = 0; l < components[t].size(); ++l) @@ -233,7 +233,7 @@ namespace boost // Need to add it to transitive closure. { vertex_iterator i, i_end; - for (tie(i, i_end) = vertices(g); i != i_end; ++i) + for (boost::tie(i, i_end) = vertices(g); i != i_end; ++i) { adjacency_iterator ab, ae; for (boost::tie(ab, ae) = adjacent_vertices(*i, g); ab != ae; ++ab) @@ -312,10 +312,10 @@ namespace boost // for j // A[i,j] = A[i,j] | A[k,j] vertex_iterator ki, ke, ii, ie, ji, je; - for (tie(ki, ke) = vertices(g); ki != ke; ++ki) - for (tie(ii, ie) = vertices(g); ii != ie; ++ii) + for (boost::tie(ki, ke) = vertices(g); ki != ke; ++ki) + for (boost::tie(ii, ie) = vertices(g); ii != ie; ++ii) if (edge(*ii, *ki, g).second) - for (tie(ji, je) = vertices(g); ji != je; ++ji) + for (boost::tie(ji, je) = vertices(g); ji != je; ++ji) if (!edge(*ii, *ji, g).second && edge(*ki, *ji, g).second) { add_edge(*ii, *ji, g); } @@ -342,10 +342,10 @@ namespace boost // A[i,j] = A[i,j] | A[k,j] vertex_iterator ic, ie, jc, je, kc, ke; - for (tie(ic, ie) = vertices(g), ++ic; ic != ie; ++ic) - for (tie(kc, ke) = vertices(g); *kc != *ic; ++kc) + for (boost::tie(ic, ie) = vertices(g), ++ic; ic != ie; ++ic) + for (boost::tie(kc, ke) = vertices(g); *kc != *ic; ++kc) if (edge(*ic, *kc, g).second) - for (tie(jc, je) = vertices(g); jc != je; ++jc) + for (boost::tie(jc, je) = vertices(g); jc != je; ++jc) if (!edge(*ic, *jc, g).second && edge(*kc, *jc, g).second) { add_edge(*ic, *jc, g); } @@ -355,10 +355,10 @@ namespace boost // for j = 1 to n // A[i,j] = A[i,j] | A[k,j] - for (tie(ic, ie) = vertices(g), --ie; ic != ie; ++ic) + for (boost::tie(ic, ie) = vertices(g), --ie; ic != ie; ++ic) for (kc = ic, ke = ie, ++kc; kc != ke; ++kc) if (edge(*ic, *kc, g).second) - for (tie(jc, je) = vertices(g); jc != je; ++jc) + for (boost::tie(jc, je) = vertices(g); jc != je; ++jc) if (!edge(*ic, *jc, g).second && edge(*kc, *jc, g).second) { add_edge(*ic, *jc, g); } diff --git a/include/boost/graph/transitive_reduction.hpp b/include/boost/graph/transitive_reduction.hpp index 5cfa9627..44dfee98 100644 --- a/include/boost/graph/transitive_reduction.hpp +++ b/include/boost/graph/transitive_reduction.hpp @@ -91,7 +91,7 @@ transitive_reduction(const Graph& g, GraphTR& tr, //do that. So what I'm doint is, collection the successors of *it here { typename Graph::out_edge_iterator oi,oi_end; - for( tie(oi, oi_end) = out_edges( *it, g ); oi != oi_end; ++oi ) { + for( boost::tie(oi, oi_end) = out_edges( *it, g ); oi != oi_end; ++oi ) { neighbors.push_back( target( *oi, g ) ); } } diff --git a/include/boost/graph/tree_traits.hpp b/include/boost/graph/tree_traits.hpp index a9f7e8ce..0843628c 100644 --- a/include/boost/graph/tree_traits.hpp +++ b/include/boost/graph/tree_traits.hpp @@ -21,7 +21,7 @@ namespace boost { { visitor.preorder(v, t); typename tree_traits::children_iterator i, end; - tie(i, end) = children(v, t); + boost::tie(i, end) = children(v, t); if (i != end) { traverse_tree(*i++, t, visitor); visitor.inorder(v, t); diff --git a/include/boost/graph/undirected_dfs.hpp b/include/boost/graph/undirected_dfs.hpp index 2486cd4b..9cad25ad 100644 --- a/include/boost/graph/undirected_dfs.hpp +++ b/include/boost/graph/undirected_dfs.hpp @@ -56,7 +56,7 @@ namespace boost { VertexInfo& back = stack.back(); u = back.first; Iter ei, ei_end; - tie(ei, ei_end) = back.second; + boost::tie(ei, ei_end) = back.second; stack.pop_back(); while (ei != ei_end) { Vertex v = target(*ei, g); @@ -70,7 +70,7 @@ namespace boost { u = v; put(vertex_color, u, Color::gray()); vis.discover_vertex(u, g); - tie(ei, ei_end) = out_edges(u, g); + boost::tie(ei, ei_end) = out_edges(u, g); } else if (v_color == Color::gray()) { if (uv_color == EColor::white()) vis.back_edge(*ei, g); ++ei; @@ -109,7 +109,7 @@ namespace boost { typename graph_traits::out_edge_iterator ei, ei_end; put(vertex_color, u, Color::gray()); vis.discover_vertex(u, g); - for (tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) { + for (boost::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) { Vertex v = target(*ei, g); vis.examine_edge(*ei, g); ColorValue v_color = get(vertex_color, v); EColorValue uv_color = get(edge_color, *ei); @@ -141,18 +141,18 @@ namespace boost { typedef color_traits Color; typename graph_traits::vertex_iterator ui, ui_end; - for (tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui) { + for (boost::tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui) { put(vertex_color, *ui, Color::white()); vis.initialize_vertex(*ui, g); } typename graph_traits::edge_iterator ei, ei_end; - for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) put(edge_color, *ei, Color::white()); if (start_vertex != *vertices(g).first){ vis.start_vertex(start_vertex, g); detail::undir_dfv_impl(g, start_vertex, vis, vertex_color, edge_color); } - for (tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui) { + for (boost::tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui) { ColorValue u_color = get(vertex_color, *ui); if (u_color == Color::white()) { vis.start_vertex(*ui, g); detail::undir_dfv_impl(g, *ui, vis, vertex_color, edge_color); diff --git a/include/boost/graph/undirected_graph.hpp b/include/boost/graph/undirected_graph.hpp index abfa4adb..0c16e263 100644 --- a/include/boost/graph/undirected_graph.hpp +++ b/include/boost/graph/undirected_graph.hpp @@ -199,7 +199,7 @@ public: // find all edges, (u, v) std::vector edges; out_edge_iterator i, i_end; - for(tie(i, i_end) = boost::out_edges(u, m_graph); i != i_end; ++i) { + for(boost::tie(i, i_end) = boost::out_edges(u, m_graph); i != i_end; ++i) { if(boost::target(*i, m_graph) == v) { edges.push_back(*i); } @@ -226,7 +226,7 @@ public: void renumber_vertex_indices() { vertex_iterator i, i_end; - tie(i, i_end) = vertices(m_graph); + boost::tie(i, i_end) = vertices(m_graph); m_max_vertex_index = renumber_vertex_indices(i, i_end, 0); } @@ -245,7 +245,7 @@ public: void renumber_edge_indices() { edge_iterator i, end; - tie(i, end) = edges(m_graph); + boost::tie(i, end) = edges(m_graph); m_max_edge_index = renumber_edge_indices(i, end, 0); } diff --git a/include/boost/graph/wavefront.hpp b/include/boost/graph/wavefront.hpp index 00cf3524..4d9c909c 100644 --- a/include/boost/graph/wavefront.hpp +++ b/include/boost/graph/wavefront.hpp @@ -37,12 +37,12 @@ namespace boost { rows_active[index_i] = true; typename graph_traits::vertex_iterator ui, ui_end; - for (tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui) + for (boost::tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui) { v = *ui; if(index[v] <= index_i) { - for (tie(edge_it2, edge_it2_end) = out_edges(v, g); edge_it2 != edge_it2_end; ++edge_it2) + for (boost::tie(edge_it2, edge_it2_end) = out_edges(v, g); edge_it2 != edge_it2_end; ++edge_it2) { w = target(*edge_it2, g); if( (index[w] >= index_i) && (!rows_active[index[w]]) ) @@ -74,7 +74,7 @@ namespace boost { BOOST_USING_STD_MAX(); typename graph_traits::vertices_size_type b = 0; typename graph_traits::vertex_iterator i, end; - for (tie(i, end) = vertices(g); i != end; ++i) + for (boost::tie(i, end) = vertices(g); i != end; ++i) b = max BOOST_PREVENT_MACRO_SUBSTITUTION(b, ith_wavefront(*i, g, index)); return b; } @@ -93,7 +93,7 @@ namespace boost { { double b = 0; typename graph_traits::vertex_iterator i, end; - for (tie(i, end) = vertices(g); i != end; ++i) + for (boost::tie(i, end) = vertices(g); i != end; ++i) b += ith_wavefront(*i, g, index); b /= num_vertices(g); @@ -114,7 +114,7 @@ namespace boost { { double b = 0; typename graph_traits::vertex_iterator i, end; - for (tie(i, end) = vertices(g); i != end; ++i) + for (boost::tie(i, end) = vertices(g); i != end; ++i) b += std::pow(double ( ith_wavefront(*i, g, index) ), 2.0); b /= num_vertices(g); diff --git a/src/graphml.cpp b/src/graphml.cpp index 4f9677df..87cab74c 100644 --- a/src/graphml.cpp +++ b/src/graphml.cpp @@ -168,7 +168,7 @@ private: any edge; bool added; - tie(edge, added) = m_g.do_add_edge(source, target); + boost::tie(edge, added) = m_g.do_add_edge(source, target); if (!added) { BOOST_THROW_EXCEPTION(bad_parallel_edge(u, v)); } diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index b3262fcc..e3dd2850 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -84,7 +84,7 @@ test-suite graph_test : [ run king_ordering.cpp ] [ run matching_test.cpp ] [ run max_flow_test.cpp ] - [ run kolmogorov_max_flow_test.cpp ] + [ run boykov_kolmogorov_max_flow_test.cpp ] [ run cycle_ratio_tests.cpp ../build//boost_graph ../../regex/build//boost_regex : $(CYCLE_RATIO_INPUT_FILE) ] [ run basic_planarity_test.cpp ] [ run make_connected_test.cpp ] @@ -112,10 +112,11 @@ test-suite graph_test : [ run clustering_coefficient.cpp ] [ run core_numbers_test.cpp ] [ run read_propmap.cpp ] - [ run mcgregor_subgraphs_test.cpp ] + [ run mcgregor_subgraphs_test.cpp ../build//boost_graph ] [ compile grid_graph_cc.cpp ] [ run grid_graph_test.cpp ] [ run incremental_components_test.cpp ] + [ run random_spanning_tree_test.cpp ../build//boost_graph ] [ run graphml_test.cpp ../build//boost_graph : : "graphml_test.xml" ] ; diff --git a/test/astar_search_test.cpp b/test/astar_search_test.cpp index 42143812..a2b3a622 100644 --- a/test/astar_search_test.cpp +++ b/test/astar_search_test.cpp @@ -162,8 +162,8 @@ int main(int, char **) WeightMap weightmap = get(edge_weight, g); for(std::size_t j = 0; j < num_edges; ++j) { edge_descriptor e; bool inserted; - tie(e, inserted) = add_edge(edge_array[j].first, - edge_array[j].second, g); + boost::tie(e, inserted) = add_edge(edge_array[j].first, + edge_array[j].second, g); weightmap[e] = weights[j]; } diff --git a/test/betweenness_centrality_test.cpp b/test/betweenness_centrality_test.cpp index f35c16ba..585e97de 100644 --- a/test/betweenness_centrality_test.cpp +++ b/test/betweenness_centrality_test.cpp @@ -45,7 +45,7 @@ run_weighted_test(Graph*, int V, weighted_edge edge_init[], int E, { vertex_iterator v, v_end; int index = 0; - for (tie(v, v_end) = boost::vertices(g); v != v_end; ++v, ++index) { + for (boost::tie(v, v_end) = boost::vertices(g); v != v_end; ++v, ++index) { put(vertex_index, g, *v, index); vertices[index] = *v; } @@ -93,7 +93,7 @@ run_unweighted_test(Graph*, int V, unweighted_edge edge_init[], int E, { vertex_iterator v, v_end; int index = 0; - for (tie(v, v_end) = boost::vertices(g); v != v_end; ++v, ++index) { + for (boost::tie(v, v_end) = boost::vertices(g); v != v_end; ++v, ++index) { put(vertex_index, g, *v, index); vertices[index] = *v; } @@ -186,7 +186,7 @@ run_wheel_test(Graph*, int V) { vertex_iterator v, v_end; int index = 0; - for (tie(v, v_end) = boost::vertices(g); v != v_end; ++v, ++index) { + for (boost::tie(v, v_end) = boost::vertices(g); v != v_end; ++v, ++index) { put(vertex_index, g, *v, index); vertices[index] = *v; if (*v != center) { @@ -247,7 +247,7 @@ void randomly_add_edges(MutableGraph& g, double edge_probability) typedef typename graph_traits::vertex_descriptor vertex; typename graph_traits::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { vertex v = *vi; typename graph_traits::vertex_iterator wi = is_undirected? vi : vertices(g).first; @@ -273,11 +273,11 @@ simple_unweighted_betweenness_centrality(const Graph& g, VertexIndexMap index, typedef typename boost::property_traits::value_type centrality_type; vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) put(centrality, *vi, 0); vertex_iterator si, si_end; - for (tie(si, si_end) = vertices(g); si != si_end; ++si) { + for (boost::tie(si, si_end) = vertices(g); si != si_end; ++si) { vertex s = *si; // S <-- empty stack @@ -313,7 +313,7 @@ simple_unweighted_betweenness_centrality(const Graph& g, VertexIndexMap index, S.push(v); adjacency_iterator wi, wi_end; - for (tie(wi, wi_end) = adjacent_vertices(v, g); wi != wi_end; ++wi) { + for (boost::tie(wi, wi_end) = adjacent_vertices(v, g); wi != wi_end; ++wi) { vertex w = *wi; // w found for the first time? @@ -366,7 +366,7 @@ simple_unweighted_betweenness_centrality(const Graph& g, VertexIndexMap index, is_same::value; if (is_undirected) { vertex_iterator v, v_end; - for(tie(v, v_end) = vertices(g); v != v_end; ++v) { + for(boost::tie(v, v_end) = vertices(g); v != v_end; ++v) { put(centrality, *v, get(centrality, *v) / centrality_type(2)); } } @@ -380,7 +380,7 @@ void random_unweighted_test(Graph*, int n) { typename graph_traits::vertex_iterator v, v_end; int index = 0; - for (tie(v, v_end) = boost::vertices(g); v != v_end; ++v, ++index) { + for (boost::tie(v, v_end) = boost::vertices(g); v != v_end; ++v, ++index) { put(vertex_index, g, *v, index); } } diff --git a/test/biconnected_components_test.cpp b/test/biconnected_components_test.cpp index d2a801e3..ee37375f 100644 --- a/test/biconnected_components_test.cpp +++ b/test/biconnected_components_test.cpp @@ -42,7 +42,7 @@ check_articulation_points(const Graph& g, std::vector art_points) std::vector art_points_check; typename graph_traits::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { Graph g_copy(g); Vertex victim = vertex(get(vertex_index, g, *vi), g_copy); clear_vertex(victim, g_copy); @@ -121,7 +121,7 @@ int test_main(int argc, char* argv[]) } graph_traits::edge_iterator ei, ei_end; - for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) out << source(*ei, g) << " -- " << target(*ei, g) << "[label=\"" << g[*ei].component << "\"]\n"; out << "}\n"; diff --git a/test/bidir_remove_edge.cpp b/test/bidir_remove_edge.cpp index f1896e1a..ebd48b75 100644 --- a/test/bidir_remove_edge.cpp +++ b/test/bidir_remove_edge.cpp @@ -24,7 +24,7 @@ main(int, char*[]) edge_prop p = { 42 }; edge e; bool b; - tie(e, b) = add_edge(0, 1, p, g); + boost::tie(e, b) = add_edge(0, 1, p, g); BOOST_TEST( num_edges(g) == 1 ); BOOST_TEST( g[e].weight == 42 ); remove_edge(e, g); @@ -37,7 +37,7 @@ main(int, char*[]) graph g(2); edge e; bool b; - tie(e, b) = add_edge(0, 1, g); + boost::tie(e, b) = add_edge(0, 1, g); BOOST_TEST( num_edges(g) == 1 ); remove_edge(e, g); BOOST_TEST( num_edges(g) == 0 ); diff --git a/test/bidir_vec_remove_edge.cpp b/test/bidir_vec_remove_edge.cpp index 4f988153..732eae70 100644 --- a/test/bidir_vec_remove_edge.cpp +++ b/test/bidir_vec_remove_edge.cpp @@ -40,7 +40,7 @@ test_main(int, char*[]) // e2 has been invalidated, so grab it again bool b2; - tie(e2, b2) = boost::edge(1, 0, g); + boost::tie(e2, b2) = boost::edge(1, 0, g); BOOST_CHECK( b2 ); BOOST_CHECK( g[e2].weight == 17 ); diff --git a/test/kolmogorov_max_flow_test.cpp b/test/boykov_kolmogorov_max_flow_test.cpp similarity index 74% rename from test/kolmogorov_max_flow_test.cpp rename to test/boykov_kolmogorov_max_flow_test.cpp index 4d087e40..17607fce 100644 --- a/test/kolmogorov_max_flow_test.cpp +++ b/test/boykov_kolmogorov_max_flow_test.cpp @@ -36,8 +36,8 @@ #include #include -#include -//boost utilities we use +#include + #include #include #include @@ -49,26 +49,26 @@ using namespace boost; template std::pair< typename graph_traits::vertex_descriptor,typename graph_traits::vertex_descriptor> -fill_random_max_flow_graph(Graph& g, CapacityMap cap, ReverseEdgeMap rev, typename graph_traits::vertices_size_type n_verts, +fill_random_max_flow_graph(Graph& g, CapacityMap cap, ReverseEdgeMap rev, typename graph_traits::vertices_size_type n_verts, typename graph_traits::edges_size_type n_edges, std::size_t seed) { typedef typename graph_traits::edge_descriptor edge_descriptor; typedef typename graph_traits::vertex_descriptor vertex_descriptor; const int cap_low = 1; const int cap_high = 1000; - + //init random numer generator minstd_rand gen(seed); //generate graph generate_random_graph(g, n_verts, n_edges, gen); - + //init an uniform distribution int generator typedef variate_generator > tIntGen; tIntGen int_gen(gen, uniform_int(cap_low, cap_high)); //randomize edge-capacities //randomize_property (g,int_gen); //we cannot use this, as we have no idea how properties are stored, right? typename graph_traits::edge_iterator ei, e_end; - for(tie(ei,e_end) = edges(g); ei != e_end; ++ei) + for(boost::tie(ei,e_end) = edges(g); ei != e_end; ++ei) cap[*ei] = int_gen(); //get source and sink node @@ -76,19 +76,19 @@ fill_random_max_flow_graph(Graph& g, CapacityMap cap, ReverseEdgeMap rev, typena vertex_descriptor t = graph_traits::null_vertex(); while(t == graph_traits::null_vertex() || t == s) t = random_vertex(g, gen); - + //add reverse edges (ugly... how to do better?!) std::list edges_copy; - tie(ei, e_end) = edges(g); + boost::tie(ei, e_end) = edges(g); std::copy(ei, e_end, std::back_insert_iterator< std::list >(edges_copy)); while(!edges_copy.empty()){ edge_descriptor old_edge = edges_copy.front(); edges_copy.pop_front(); - vertex_descriptor source_vertex = target(old_edge, g); + vertex_descriptor source_vertex = target(old_edge, g); vertex_descriptor target_vertex = source(old_edge, g); bool inserted; edge_descriptor new_edge; - tie(new_edge,inserted) = add_edge(source_vertex, target_vertex, g); + boost::tie(new_edge,inserted) = add_edge(source_vertex, target_vertex, g); assert(inserted); rev[old_edge] = new_edge; rev[new_edge] = old_edge ; @@ -107,20 +107,20 @@ long test_adjacency_list_vecS(int n_verts, int n_edges, std::size_t seed){ property > > > tVectorGraph; - + tVectorGraph g; - + graph_traits::vertex_descriptor src,sink; - tie(src,sink) = fill_random_max_flow_graph(g, get(edge_capacity,g), get(edge_reverse, g), n_verts, n_edges, seed); - - return kolmogorov_max_flow(g, get(edge_capacity, g), - get(edge_residual_capacity, g), - get(edge_reverse, g), - get(vertex_predecessor, g), - get(vertex_color, g), - get(vertex_distance, g), - get(vertex_index, g), - src, sink); + boost::tie(src,sink) = fill_random_max_flow_graph(g, get(edge_capacity,g), get(edge_reverse, g), n_verts, n_edges, seed); + + return boykov_kolmogorov_max_flow(g, get(edge_capacity, g), + get(edge_residual_capacity, g), + get(edge_reverse, g), + get(vertex_predecessor, g), + get(vertex_color, g), + get(vertex_distance, g), + get(vertex_index, g), + src, sink); } long test_adjacency_list_listS(int n_verts, int n_edges, std::size_t seed){ @@ -133,26 +133,26 @@ long test_adjacency_list_listS(int n_verts, int n_edges, std::size_t seed){ property > > > tListGraph; - + tListGraph g; - + graph_traits::vertex_descriptor src,sink; - tie(src,sink) = fill_random_max_flow_graph(g, get(edge_capacity,g), get(edge_reverse, g), n_verts, n_edges, seed); - + boost::tie(src,sink) = fill_random_max_flow_graph(g, get(edge_capacity,g), get(edge_reverse, g), n_verts, n_edges, seed); + //initialize vertex indices graph_traits::vertex_iterator vi,v_end; graph_traits::vertices_size_type index = 0; - for(tie(vi, v_end) = vertices(g); vi != v_end; ++vi){ + for(boost::tie(vi, v_end) = vertices(g); vi != v_end; ++vi){ put(vertex_index, g, *vi, index++); } - return kolmogorov_max_flow(g, get(edge_capacity, g), - get(edge_residual_capacity, g), - get(edge_reverse, g), - get(vertex_predecessor, g), - get(vertex_color, g), - get(vertex_distance, g), - get(vertex_index, g), - src, sink); + return boykov_kolmogorov_max_flow(g, get(edge_capacity, g), + get(edge_residual_capacity, g), + get(edge_reverse, g), + get(vertex_predecessor, g), + get(vertex_color, g), + get(vertex_distance, g), + get(vertex_index, g), + src, sink); } template @@ -174,19 +174,19 @@ long test_bundled_properties(int n_verts, int n_edges, std::size_t seed){ typedef Node tVertex; typedef Link tEdge; typedef adjacency_list tBundleGraph; - + tBundleGraph g; graph_traits::vertex_descriptor src,sink; - tie(src,sink) = fill_random_max_flow_graph(g, get(&tEdge::edge_capacity,g), get(&tEdge::edge_reverse, g), n_verts, n_edges, seed); - return kolmogorov_max_flow(g, get(&tEdge::edge_capacity, g), - get(&tEdge::edge_residual_capacity, g), - get(&tEdge::edge_reverse, g), - get(&tVertex::vertex_predecessor, g), - get(&tVertex::vertex_color, g), - get(&tVertex::vertex_distance, g), - get(vertex_index, g), - src, sink); + boost::tie(src,sink) = fill_random_max_flow_graph(g, get(&tEdge::edge_capacity,g), get(&tEdge::edge_reverse, g), n_verts, n_edges, seed); + return boykov_kolmogorov_max_flow(g, get(&tEdge::edge_capacity, g), + get(&tEdge::edge_residual_capacity, g), + get(&tEdge::edge_reverse, g), + get(&tVertex::vertex_predecessor, g), + get(&tVertex::vertex_color, g), + get(&tVertex::vertex_distance, g), + get(vertex_index, g), + src, sink); } long test_overloads(int n_verts, int n_edges, std::size_t seed){ @@ -195,28 +195,50 @@ long test_overloads(int n_verts, int n_edges, std::size_t seed){ property > >tEdgeProperty; typedef adjacency_list tGraph; - + tGraph g; - + graph_traits::vertex_descriptor src,sink; - tie(src,sink) = fill_random_max_flow_graph(g, get(edge_capacity,g), get(edge_reverse, g), n_verts, n_edges, seed); + boost::tie(src,sink) = fill_random_max_flow_graph(g, get(edge_capacity,g), get(edge_reverse, g), n_verts, n_edges, seed); std::vector::edge_descriptor> predecessor_vec(n_verts); std::vector color_vec(n_verts); std::vector::vertices_size_type> distance_vec(n_verts); - long flow_overload_1 = kolmogorov_max_flow(g, get(edge_capacity,g), get(edge_residual_capacity,g), get(edge_reverse,g), get(vertex_index,g), src, sink); - - long flow_overload_2 = kolmogorov_max_flow(g, get(edge_capacity,g), get(edge_residual_capacity,g), get(edge_reverse,g), - &(color_vec[0]), get(vertex_index,g), src, sink); - + long flow_overload_1 = + boykov_kolmogorov_max_flow(g, + get(edge_capacity,g), + get(edge_residual_capacity,g), + get(edge_reverse,g), + get(vertex_index,g), + src, sink); + + long flow_overload_2 = + boykov_kolmogorov_max_flow(g, + get(edge_capacity,g), + get(edge_residual_capacity,g), + get(edge_reverse,g), + &(color_vec[0]), + get(vertex_index,g), + src, sink); + BOOST_CHECK(flow_overload_1 == flow_overload_2); return flow_overload_1; } -template -class kolmogorov_test:public detail::kolmogorov +template +class boykov_kolmogorov_test + : public detail::bk_max_flow< + Graph, EdgeCapacityMap, ResidualCapacityEdgeMap, ReverseEdgeMap, + PredecessorMap, ColorMap, DistanceMap, IndexMap + > { typedef typename graph_traits::edge_descriptor tEdge; @@ -226,14 +248,20 @@ class kolmogorov_test:public detail::kolmogorov::out_edge_iterator tOutEdgeIterator; typedef typename property_traits::value_type tColorValue; typedef color_traits tColorTraits; - typedef typename property_traits::value_type tDistanceVal; - typedef typename detail::kolmogorov tSuper; + typedef typename property_traits::value_type tDistanceVal; + typedef typename detail::bk_max_flow< + Graph, EdgeCapacityMap, ResidualCapacityEdgeMap, ReverseEdgeMap, + PredecessorMap, ColorMap, DistanceMap, IndexMap + > tSuper; public: - kolmogorov_test(Graph& g, typename graph_traits::vertex_descriptor src, typename graph_traits::vertex_descriptor sink): - detail::kolmogorov - (g, get(edge_capacity,g), get(edge_residual_capacity,g), get(edge_reverse, g), get(vertex_predecessor, g), get(vertex_color, g), - get(vertex_distance, g), get(vertex_index, g), src, sink){ - } + boykov_kolmogorov_test(Graph& g, + typename graph_traits::vertex_descriptor src, + typename graph_traits::vertex_descriptor sink) + : tSuper(g, get(edge_capacity,g), get(edge_residual_capacity,g), + get(edge_reverse, g), get(vertex_predecessor, g), + get(vertex_color, g), get(vertex_distance, g), + get(vertex_index, g), src, sink) + { } void invariant_four(tVertex v) const{ //passive nodes in S or T @@ -244,7 +272,7 @@ class kolmogorov_test:public detail::kolmogorovget_tree(v) != tColorTraits::gray() && !is_active){ typename graph_traits::out_edge_iterator ei,e_end; - for(tie(ei, e_end) = out_edges(v, tSuper::m_g); ei != e_end; ++ei){ + for(boost::tie(ei, e_end) = out_edges(v, tSuper::m_g); ei != e_end; ++ei){ const tVertex& other_node = target(*ei, tSuper::m_g); if(this->get_tree(other_node) != this->get_tree(v)){ if(this->get_tree(v) == tColorTraits::black()) @@ -314,7 +342,7 @@ class kolmogorov_test:public detail::kolmogorovgrow(); //find a path from source to sink + boost::tie(connecting_edge, path_found) = this->grow(); //find a path from source to sink if(!path_found){ //we're finished, no more paths were found break; @@ -346,14 +374,14 @@ class kolmogorov_test:public detail::kolmogorovm_source, this->m_g); ei != e_end; ++ei){ + tEdgeVal src_sum = 0; + for(boost::tie(ei, e_end) = out_edges(this->m_source, this->m_g); ei != e_end; ++ei){ src_sum += this->m_cap_map[*ei] - this->m_res_cap_map[*ei]; } BOOST_CHECK(this->m_flow == src_sum); //check if flow is the sum of ingoing edges of sink tEdgeVal sink_sum = 0; - for(tie(ei, e_end) = out_edges(this->m_sink, this->m_g); ei != e_end; ++ei){ + for(boost::tie(ei, e_end) = out_edges(this->m_sink, this->m_g); ei != e_end; ++ei){ tEdge in_edge = this->m_rev_edge_map[*ei]; sink_sum += this->m_cap_map[in_edge] - this->m_res_cap_map[in_edge]; } @@ -373,11 +401,11 @@ long test_algorithms_invariant(int n_verts, int n_edges, std::size_t seed) property > > > tVectorGraph; - + tVectorGraph g; - + graph_traits::vertex_descriptor src, sink; - tie(src,sink) = fill_random_max_flow_graph(g, get(edge_capacity,g), get(edge_reverse, g), n_verts, n_edges, seed); + boost::tie(src,sink) = fill_random_max_flow_graph(g, get(edge_capacity,g), get(edge_reverse, g), n_verts, n_edges, seed); typedef property_map::type tEdgeCapMap; typedef property_map::type tEdgeResCapMap; @@ -386,33 +414,35 @@ long test_algorithms_invariant(int n_verts, int n_edges, std::size_t seed) typedef property_map::type tVertexColorMap; typedef property_map::type tDistanceMap; typedef property_map::type tIndexMap; - typedef kolmogorov_test tKolmo; + typedef boykov_kolmogorov_test< + tVectorGraph, tEdgeCapMap, tEdgeResCapMap, tRevEdgeMap, tVertexPredMap, + tVertexColorMap, tDistanceMap, tIndexMap + > tKolmo; tKolmo instance(g, src, sink); return instance.test(); } int test_main(int argc, char* argv[]) { - int n_verts = 10; + int n_verts = 10; int n_edges = 500; std::size_t seed = 1; - + if (argc > 1) n_verts = lexical_cast(argv[1]); if (argc > 2) n_edges = lexical_cast(argv[2]); if (argc > 3) seed = lexical_cast(argv[3]); //we need at least 2 vertices to create src and sink in random graphs - //this case is also caught in kolmogorov_max_flow + //this case is also caught in boykov_kolmogorov_max_flow if (n_verts<2) n_verts = 2; - /* - * below are checks for different calls to kolmogorov_max_flow and different graph-types - */ + // below are checks for different calls to boykov_kolmogorov_max_flow and different graph-types + //checks support of vecS storage long flow_vecS = test_adjacency_list_vecS(n_verts, n_edges, seed); std::cout << "vecS flow: " << flow_vecS << std::endl; - //checks support of listS storage (especially problems with vertex indices) + //checks support of listS storage (especially problems with vertex indices) long flow_listS = test_adjacency_list_listS(n_verts, n_edges, seed); std::cout << "listS flow: " << flow_listS << std::endl; BOOST_CHECK(flow_vecS == flow_listS); @@ -424,9 +454,9 @@ int test_main(int argc, char* argv[]) long flow_overloads = test_overloads(n_verts, n_edges, seed); std::cout << "overloads flow: " << flow_overloads << std::endl; BOOST_CHECK(flow_bundles == flow_overloads); - /* - * excessive test version where kolmogorov's algorithm invariants are checked - */ + + // excessive test version where Boykov-Kolmogorov's algorithm invariants are + // checked long flow_invariants = test_algorithms_invariant(n_verts, n_edges, seed); std::cout << "invariants flow: " << flow_invariants << std::endl; BOOST_CHECK(flow_overloads == flow_invariants); diff --git a/test/cycle_ratio_tests.cpp b/test/cycle_ratio_tests.cpp index e98996b5..f7ca6921 100644 --- a/test/cycle_ratio_tests.cpp +++ b/test/cycle_ratio_tests.cpp @@ -333,7 +333,7 @@ int test_main(int argc, char* argv[]) typedef graph_traits::vertex_iterator VertexItM; typedef graph_traits::edge_descriptor EdgeM; VertexItM vi1, vi2, vi_end; - for (tie(vi1, vi_end) = vertices(gm); vi1 != vi_end; ++vi1) + for (boost::tie(vi1, vi_end) = vertices(gm); vi1 != vi_end; ++vi1) { for (vi2 = vertices(gm).first; vi2 != vi_end; ++vi2) add_edge(*vi1, *vi2, gm); diff --git a/test/dijkstra_heap_performance.cpp b/test/dijkstra_heap_performance.cpp index 0b78f740..72d40f9c 100644 --- a/test/dijkstra_heap_performance.cpp +++ b/test/dijkstra_heap_performance.cpp @@ -100,7 +100,7 @@ int main(int argc, char* argv[]) std::cout << n << " vertices, " << num_edges(g) << " edges.\n"; uniform_real rand01(0.0, 1.0); graph_traits::edge_iterator ei, ei_end; - for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) + for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) put(edge_weight, g, *ei, rand01(gen)); std::vector binary_heap_distances(n); diff --git a/test/dijkstra_no_color_map_compare.cpp b/test/dijkstra_no_color_map_compare.cpp index 7dd8c82a..a8c140d1 100644 --- a/test/dijkstra_no_color_map_compare.cpp +++ b/test/dijkstra_no_color_map_compare.cpp @@ -16,10 +16,10 @@ #include #include #include -#include #include #include #include +#include #define INITIALIZE_VERTEX 0 #define DISCOVER_VERTEX 1 diff --git a/test/dominator_tree_test.cpp b/test/dominator_tree_test.cpp index 604796a6..5f2f9655 100644 --- a/test/dominator_tree_test.cpp +++ b/test/dominator_tree_test.cpp @@ -238,7 +238,7 @@ int test_main(int, char*[]) IndexMap indexMap(get(vertex_index, g)); graph_traits::vertex_iterator uItr, uEnd; int j = 0; - for (tie(uItr, uEnd) = vertices(g); uItr != uEnd; ++uItr, ++j) + for (boost::tie(uItr, uEnd) = vertices(g); uItr != uEnd; ++uItr, ++j) { put(indexMap, *uItr, j); } @@ -252,7 +252,7 @@ int test_main(int, char*[]) lengauer_tarjan_dominator_tree(g, vertex(0, g), domTreePredMap); vector idom(num_vertices(g)); - for (tie(uItr, uEnd) = vertices(g); uItr != uEnd; ++uItr) + for (boost::tie(uItr, uEnd) = vertices(g); uItr != uEnd; ++uItr) { if (get(domTreePredMap, *uItr) != graph_traits::null_vertex()) idom[get(indexMap, *uItr)] = @@ -276,7 +276,7 @@ int test_main(int, char*[]) iterative_bit_vector_dominator_tree(g, vertex(0, g), domTreePredMap); vector idom2(num_vertices(g)); - for (tie(uItr, uEnd) = vertices(g); uItr != uEnd; ++uItr) + for (boost::tie(uItr, uEnd) = vertices(g); uItr != uEnd; ++uItr) { if (get(domTreePredMap, *uItr) != graph_traits::null_vertex()) idom2[get(indexMap, *uItr)] = diff --git a/test/graphml_test.cpp b/test/graphml_test.cpp index a69f66d3..972768e8 100644 --- a/test/graphml_test.cpp +++ b/test/graphml_test.cpp @@ -74,11 +74,11 @@ int main(int argc, char** argv) assert(num_edges(g) == num_edges(g2)); graph_traits::vertex_iterator v, v_end; - for (tie(v,v_end) = vertices(g); v != v_end; ++v) + for (boost::tie(v,v_end) = vertices(g); v != v_end; ++v) assert(get(vertex_color_t(), g, *v) == get(vertex_color_t(), g2, *v)); graph_traits::edge_iterator e, e_end; - for (tie(e,e_end) = edges(g); e != e_end; ++e) + for (boost::tie(e,e_end) = edges(g); e != e_end; ++e) assert(get(edge_weight_t(), g, *e) == get(edge_weight_t(), g2, *e)); return 0; diff --git a/test/index_graph.cpp b/test/index_graph.cpp index efba110c..b988179f 100644 --- a/test/index_graph.cpp +++ b/test/index_graph.cpp @@ -77,7 +77,7 @@ void build() // Each vertex should be numbered correctly. Iterator i, end; - tie(i, end) = vertices(g); + boost::tie(i, end) = vertices(g); for(size_t x = 0; i != end; ++i, ++x) { BOOST_ASSERT(get_vertex_index(*i, g) == x); } diff --git a/test/layout_test.cpp b/test/layout_test.cpp index 19f8c992..7f85614a 100644 --- a/test/layout_test.cpp +++ b/test/layout_test.cpp @@ -41,7 +41,7 @@ void print_graph_layout(const Graph& g, PositionMap position, const Topology& to typename graph_traits::vertex_iterator vi, vi_end; // Find vertex at this position typename graph_traits::vertices_size_type index = 0; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi, ++index) { + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi, ++index) { if ((int)position[*vi][0] == x && (int)position[*vi][1] == y) break; } @@ -60,14 +60,14 @@ void dump_graph_layout(std::string name, const Graph& g, PositionMap position) out << "graph " << name << " {" << std::endl; typename graph_traits::vertex_iterator vi, vi_end; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) { out << " n" << get(vertex_index, g, *vi) << "[ pos=\"" << (int)position[*vi][0] + 25 << ", " << (int)position[*vi][1] + 25 << "\" ];\n"; } typename graph_traits::edge_iterator ei, ei_end; - for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { + for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { out << " n" << get(vertex_index, g, source(*ei, g)) << " -- n" << get(vertex_index, g, target(*ei, g)) << ";\n"; } @@ -172,11 +172,11 @@ test_cube(Graph*) vertex_iterator vi, vi_end; int i = 0; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) put(vertex_index, g, *vi, i++); edge_iterator ei, ei_end; - for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { + for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { put(edge_weight, g, *ei, 1.0); std::cerr << "(" << (char)(get(vertex_index, g, source(*ei, g)) + 'A') << ", " << (char)(get(vertex_index, g, target(*ei, g)) + 'A') @@ -241,11 +241,11 @@ test_triangular(Graph*) vertex_iterator vi, vi_end; int i = 0; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) put(vertex_index, g, *vi, i++); edge_iterator ei, ei_end; - for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { + for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { put(edge_weight, g, *ei, 1.0); std::cerr << "(" << (char)(get(vertex_index, g, source(*ei, g)) + 'A') << ", " << (char)(get(vertex_index, g, target(*ei, g)) + 'A') @@ -313,11 +313,11 @@ test_disconnected(Graph*) vertex_iterator vi, vi_end; int i = 0; - for (tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) + for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) put(vertex_index, g, *vi, i++); edge_iterator ei, ei_end; - for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { + for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) { put(edge_weight, g, *ei, 1.0); std::cerr << "(" << (char)(get(vertex_index, g, source(*ei, g)) + 'A') << ", " << (char)(get(vertex_index, g, target(*ei, g)) + 'A') diff --git a/test/matching_test.cpp b/test/matching_test.cpp index 81dd566e..784fca58 100644 --- a/test/matching_test.cpp +++ b/test/matching_test.cpp @@ -51,7 +51,7 @@ struct vertex_index_installer vertex_iterator_t vi, vi_end; v_size_t i = 0; - for(tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi, ++i) + for(boost::tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi, ++i) put(vertex_index, g, *vi, i); } }; @@ -66,8 +66,8 @@ void complete_graph(Graph& g, int n) g = Graph(n); vertex_iterator_t vi, vi_end, wi; - tie(vi,vi_end) = vertices(g); - for(tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) + boost::tie(vi,vi_end) = vertices(g); + for(boost::tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) { wi = vi; ++wi; @@ -92,7 +92,7 @@ void gabows_graph(Graph& g, int n) vertex_iterator_t vi, vi_end, ui, ui_end, halfway; - tie(ui,ui_end) = vertices(g); + boost::tie(ui,ui_end) = vertices(g); halfway = ui; for(int i = 0; i < n; ++i) @@ -111,7 +111,7 @@ void gabows_graph(Graph& g, int n) ++ui; } - tie(ui,ui_end) = vertices(g); + boost::tie(ui,ui_end) = vertices(g); while(halfway != ui_end) { @@ -233,7 +233,7 @@ void matching_test(std::size_t num_v, const std::string& graph_name) //Now remove an edge from the edmonds_mate matching. vertex_iterator_t vi,vi_end; - for(tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) + for(boost::tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) if (edmonds_mate[*vi] != graph_traits::null_vertex()) break; @@ -299,7 +299,7 @@ void matching_test(std::size_t num_v, const std::string& graph_name) vertex_descriptor_t v = random_vertex(j,rand_num); if (u != v) { - tie(tuples::ignore, success) = add_edge(u, v, j); + boost::tie(tuples::ignore, success) = add_edge(u, v, j); if (success) num_edges++; } @@ -316,7 +316,7 @@ void matching_test(std::size_t num_v, const std::string& graph_name) } //Now remove an edge from the random_mate matching. - for(tie(vi,vi_end) = vertices(j); vi != vi_end; ++vi) + for(boost::tie(vi,vi_end) = vertices(j); vi != vi_end; ++vi) if (random_mate[*vi] != graph_traits::null_vertex()) break; diff --git a/test/max_flow_test.cpp b/test/max_flow_test.cpp index ec36cdc0..8cd5e4a2 100644 --- a/test/max_flow_test.cpp +++ b/test/max_flow_test.cpp @@ -37,7 +37,7 @@ #include //three max_flows we test here -#include +#include #include #include //boost utilities we use @@ -107,7 +107,7 @@ int test_main(int argc, char* argv[]) property_map < Graph, edge_capacity_t >::type cap = get(edge_capacity, g); std::list edges_copy; graph_traits::edge_iterator ei, e_end; - tie(ei, e_end) = edges(g); + boost::tie(ei, e_end) = edges(g); std::copy(ei, e_end, std::back_insert_iterator< std::list >(edges_copy)); while( ! edges_copy.empty()){ tEdge old_edge=edges_copy.front(); @@ -116,7 +116,7 @@ int test_main(int argc, char* argv[]) tVertex target_vertex = source(old_edge, g); bool inserted; tEdge new_edge; - tie(new_edge,inserted) = add_edge(source_vertex, target_vertex, g); + boost::tie(new_edge,inserted) = add_edge(source_vertex, target_vertex, g); assert(inserted); rev[old_edge] = new_edge; rev[new_edge] = old_edge ; @@ -125,11 +125,11 @@ int test_main(int argc, char* argv[]) typedef property_traits< property_map::const_type>::value_type tEdgeVal; - tEdgeVal kolmo = kolmogorov_max_flow(g,source_vertex,sink_vertex); + tEdgeVal bk = boykov_kolmogorov_max_flow(g,source_vertex,sink_vertex); tEdgeVal push_relabel = push_relabel_max_flow(g,source_vertex,sink_vertex); tEdgeVal edmonds_karp = edmonds_karp_max_flow(g,source_vertex,sink_vertex); - BOOST_REQUIRE( kolmo == push_relabel ); + BOOST_REQUIRE( bk == push_relabel ); BOOST_REQUIRE( push_relabel == edmonds_karp ); return 0; diff --git a/test/metric_tsp_approx.cpp b/test/metric_tsp_approx.cpp index e813bd33..9cde9dfa 100644 --- a/test/metric_tsp_approx.cpp +++ b/test/metric_tsp_approx.cpp @@ -65,7 +65,7 @@ void connectAllEuclidean(VertexListGraph& g, pow(static_cast(points[vmap[*dest]].y - points[vmap[*src]].y), 2.0))); - tie(e, inserted) = add_edge(*src, *dest, g); + boost::tie(e, inserted) = add_edge(*src, *dest, g); wmap[e] = weight; } @@ -152,7 +152,7 @@ void checkAdjList(PositionVec v) //create vertex index map VItr vi, ve; int idx(0); - for (tie(vi, ve) = vertices(g); vi != ve; ++vi) + for (boost::tie(vi, ve) = vertices(g); vi != ve; ++vi) { Vertex v(*vi); v_pmap[v] = idx; diff --git a/test/property_iter.cpp b/test/property_iter.cpp index 9ff0d642..150061e9 100644 --- a/test/property_iter.cpp +++ b/test/property_iter.cpp @@ -123,7 +123,7 @@ int main(int, char* []) TLinkIterator itEdgeBegin, itEdgeEnd; - tie(itEdgeBegin, itEdgeEnd) = get_property_iter_range(g, edge_id); + boost::tie(itEdgeBegin, itEdgeEnd) = get_property_iter_range(g, edge_id); cout << "Edge iteration:" << endl; for (; itEdgeBegin != itEdgeEnd; ++itEdgeBegin) @@ -134,7 +134,7 @@ int main(int, char* []) TNodeIterator itVertexBegin, itVertexEnd; - tie(itVertexBegin, itVertexEnd) = get_property_iter_range(g, vertex_id); + boost::tie(itVertexBegin, itVertexEnd) = get_property_iter_range(g, vertex_id); cout << "Vertex iteration:" << endl; for (; itVertexBegin != itVertexEnd; ++itVertexBegin) diff --git a/test/random_matching_test.cpp b/test/random_matching_test.cpp index e5d55773..7622e694 100644 --- a/test/random_matching_test.cpp +++ b/test/random_matching_test.cpp @@ -60,7 +60,7 @@ int main(int argc, char** argv) if (u != v) { if (!edge(u,v,g).second) - tie(tuples::ignore, success) = add_edge(u, v, g); + boost::tie(tuples::ignore, success) = add_edge(u, v, g); else success = false; @@ -79,13 +79,13 @@ int main(int argc, char** argv) std::cout << "Graph has edges: "; typedef graph_traits::edge_iterator edge_iterator_t; edge_iterator_t ei,ei_end; - for(tie(ei,ei_end) = edges(g); ei != ei_end; ++ei) + for(boost::tie(ei,ei_end) = edges(g); ei != ei_end; ++ei) std:: cout << *ei << ", "; std::cout << std::endl; std::cout << "Matching is: "; vertex_iterator_t vi, vi_end; - for(tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) + for(boost::tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) if (mate[*vi] != graph_traits::null_vertex() && *vi < mate[*vi]) std::cout << "{" << *vi << "," << mate[*vi] << "}, "; @@ -94,7 +94,7 @@ int main(int argc, char** argv) //Now remove an edge from the random_mate matching. vertex_iterator_t vi, vi_end; - for(tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) + for(boost::tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi) if (mate[*vi] != graph_traits::null_vertex()) break; diff --git a/test/random_spanning_tree_test.cpp b/test/random_spanning_tree_test.cpp new file mode 100644 index 00000000..e44803f5 --- /dev/null +++ b/test/random_spanning_tree_test.cpp @@ -0,0 +1,69 @@ +// Copyright 2010 The Trustees of Indiana University. + +// 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) + +// Authors: Jeremiah Willcock +// Andrew Lumsdaine + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace boost; +using namespace std; + +typedef grid_graph<2> graph_type; +typedef graph_traits gt; + +template +void write_spanning_tree(const Graph& g, PredMap pred, WeightMap weight, string filename) { + shared_array_property_map::const_type> edge_style(num_edges(g), get(edge_index, g)); + shared_array_property_map::const_type> vertex_pos(num_vertices(g), get(vertex_index, g)); + BGL_FORALL_EDGES_T(e, g, Graph) { + put(edge_style, e, (get(pred, target(e, g)) == source(e, g) || get(pred, source(e, g)) == target(e, g)) ? "bold" : "dotted"); + } + BGL_FORALL_VERTICES_T(v, g, Graph) { + put(vertex_pos, v, lexical_cast(v[0]) + "," + lexical_cast(v[1])); + } + dynamic_properties dp; + dp.property("style", edge_style); + dp.property("pos", vertex_pos); + dp.property("len", weight); + dp.property("node_id", get(vertex_index, g)); + ofstream out(filename.c_str()); + write_graphviz_dp(out, g, dp); +} + +int main(int, char**) { + + array sizes = {{ 5, 5 }}; + graph_type g(sizes); + + shared_array_property_map::const_type> pred(num_vertices(g), get(vertex_index, g)); + shared_array_property_map::const_type> weight(num_edges(g), get(edge_index, g)); + + BGL_FORALL_EDGES(e, g, graph_type) {put(weight, e, (1. + get(edge_index, g, e)) / num_edges(g));} + + mt19937 gen; + random_spanning_tree(g, pred, gen); + // write_spanning_tree(g, pred, constant_property_map(1.), "unweight_random_st.dot"); + random_spanning_tree(g, pred, gen); + // write_spanning_tree(g, pred, constant_property_map(1.), "unweight_random_st2.dot"); + + weighted_random_spanning_tree(g, pred, weight, gen); + // write_spanning_tree(g, pred, weight, "weight_random_st.dot"); + + return 0; +} diff --git a/test/subgraph.cpp b/test/subgraph.cpp index bb6011d6..d0154a31 100644 --- a/test/subgraph.cpp +++ b/test/subgraph.cpp @@ -105,7 +105,7 @@ int test_main(int, char*[]) subgraph_t sub = g.create_subgraph(vertices(g).first, vertices(g).second); graph_t::edge_iterator ei, ee; - for (tie(ei, ee) = edges(sub); ei != ee; ++ei) { + for (boost::tie(ei, ee) = edges(sub); ei != ee; ++ei) { // This used to segfault. get(edge_weight, sub, *ei); } diff --git a/test/subgraph_bundled.cpp b/test/subgraph_bundled.cpp index 8bad04b1..81629c95 100644 --- a/test/subgraph_bundled.cpp +++ b/test/subgraph_bundled.cpp @@ -125,7 +125,7 @@ int test_main(int, char*[]) Subgraph sub = g.create_subgraph(vertices(g).first, vertices(g).second); graph_traits::edge_iterator ei, ee; - for (tie(ei, ee) = edges(sub); ei != ee; ++ei) { + for (boost::tie(ei, ee) = edges(sub); ei != ee; ++ei) { // This used to segfault. get(edge_weight, sub, *ei); } diff --git a/test/transitive_closure_test.cpp b/test/transitive_closure_test.cpp index c84a2527..16ec350f 100644 --- a/test/transitive_closure_test.cpp +++ b/test/transitive_closure_test.cpp @@ -42,7 +42,7 @@ num_incident(typename graph_traits::vertex_descriptor u, { typename graph_traits::degree_size_type d = 0; typename graph_traits::out_edge_iterator i, i_end; - for (tie(i, i_end) = out_edges(u, g); i != i_end; ++i) + for (boost::tie(i, i_end) = out_edges(u, g); i != i_end; ++i) if (target(*i, g) == v) ++d; return d; @@ -57,13 +57,13 @@ template bool check_transitive_closure(Graph& g, GraphTC& tc) { typename graph_traits::vertex_iterator i, i_end; - for (tie(i, i_end) = vertices(g); i != i_end; ++i) { + for (boost::tie(i, i_end) = vertices(g); i != i_end; ++i) { typename graph_traits::vertex_iterator j, j_end; - for (tie(j, j_end) = vertices(g); j != j_end; ++j) { + for (boost::tie(j, j_end) = vertices(g); j != j_end; ++j) { bool g_has_edge; typename graph_traits::edge_descriptor e_g; typename graph_traits::degree_size_type num_tc; - tie (e_g, g_has_edge) = edge(*i, *j, g); + boost::tie (e_g, g_has_edge) = edge(*i, *j, g); num_tc = num_incident(*i, *j, tc); if (*i == *j) { if (g_has_edge) { @@ -72,7 +72,7 @@ bool check_transitive_closure(Graph& g, GraphTC& tc) } else { bool can_reach = false; typename graph_traits::adjacency_iterator k, k_end; - for (tie(k, k_end) = adjacent_vertices(*i, g); k != k_end; ++k) { + for (boost::tie(k, k_end) = adjacent_vertices(*i, g); k != k_end; ++k) { std::vector color_map_vec(num_vertices(g)); if (is_reachable(*k, *i, g, &color_map_vec[0])) { can_reach = true;