mirror of
https://github.com/boostorg/graph.git
synced 2025-05-11 21:34:00 +00:00
parent
3a546c9418
commit
a88250f76f
@ -54,7 +54,7 @@ int main(int argc, char** argv)
|
||||
property_map<graph, edge_index_t>::type e_index = get(edge_index, g);
|
||||
graph_traits<graph>::edges_size_type edge_count = 0;
|
||||
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)
|
||||
put(e_index, *ei, edge_count++);
|
||||
|
||||
|
||||
|
@ -75,7 +75,7 @@ main(int argc, char *argv[])
|
||||
|
||||
// Print the closeness centrality of each vertex.
|
||||
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) {
|
||||
cout << setw(12) << setiosflags(ios::left)
|
||||
<< g[*i].name << get(cm, *i) << endl;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ main(int argc, char *argv[])
|
||||
|
||||
// Print the clustering coefficient of each vertex.
|
||||
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) {
|
||||
cout << setw(12) << setiosflags(ios::left)
|
||||
<< g[*i].name << get(cm, *i) << endl;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ main(int argc, char *argv[])
|
||||
|
||||
// Print the degree centrality of each vertex.
|
||||
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) {
|
||||
cout << setiosflags(ios::left) << setw(12)
|
||||
<< g[*i].name << cm[*i] << endl;
|
||||
}
|
||||
|
@ -473,18 +473,18 @@ int main (int argc, char const *argv[]) {
|
||||
// 5 vertices
|
||||
std::cout << "Vertices, outgoing edges, and adjacent vertices" << std::endl;
|
||||
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_descriptor u = *vi;
|
||||
std::cout << "Vertex " << u << ": ";
|
||||
// Adjacenct edges
|
||||
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++)
|
||||
std::cout << *ei << " ";
|
||||
std::cout << " Adjacent vertices ";
|
||||
// Adjacent vertices
|
||||
// Here we want our adjacency_iterator and not boost::adjacency_iterator.
|
||||
::adjacency_iterator ai, ai_end;
|
||||
for (tie(ai, ai_end) = adjacent_vertices(u, g); ai != ai_end; ai++) {
|
||||
for (boost::tie(ai, ai_end) = adjacent_vertices(u, g); ai != ai_end; ai++) {
|
||||
std::cout << *ai << " ";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
@ -503,7 +503,7 @@ int main (int argc, char const *argv[]) {
|
||||
// 5 edges
|
||||
std::cout << "Edges and weights" << std::endl;
|
||||
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++) {
|
||||
edge_descriptor e = *ei;
|
||||
std::cout << e << " weight " << get(edge_weight, g, e) << std::endl;
|
||||
}
|
||||
@ -528,7 +528,7 @@ int main (int argc, char const *argv[]) {
|
||||
distance_map(&dist[0]) );
|
||||
|
||||
std::cout << "Dijkstra search from vertex " << source << std::endl;
|
||||
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 u = *vi;
|
||||
std::cout << "Vertex " << u << ": "
|
||||
<< "parent "<< pred[*vi] << ", "
|
||||
|
@ -121,7 +121,7 @@ main(int argc, char *argv[])
|
||||
cout << setw(12) << setiosflags(ios::left) << "excluding";
|
||||
cout << setw(12) << setiosflags(ios::left) << "including" << endl;
|
||||
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) {
|
||||
cout << setw(12) << setiosflags(ios::left)
|
||||
<< g[*i].name
|
||||
<< setw(12) << get(exmap, *i)
|
||||
|
@ -62,7 +62,7 @@ main(int argc, char *argv[])
|
||||
|
||||
// Print the degree centrality of each vertex
|
||||
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) {
|
||||
Vertex v = *i;
|
||||
cout << setiosflags(ios::left) << setw(12)
|
||||
<< g[v].name << "\t"
|
||||
|
@ -55,7 +55,7 @@ int main(int argc, char** argv)
|
||||
property_map<graph, edge_index_t>::type e_index = get(edge_index, g);
|
||||
graph_traits<graph>::edges_size_type edge_count = 0;
|
||||
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)
|
||||
put(e_index, *ei, edge_count++);
|
||||
|
||||
|
||||
|
@ -51,7 +51,7 @@ int main(int argc, char** argv)
|
||||
property_map<graph, edge_index_t>::type e_index = get(edge_index, g);
|
||||
graph_traits<graph>::edges_size_type edge_count = 0;
|
||||
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)
|
||||
put(e_index, *ei, edge_count++);
|
||||
|
||||
|
||||
@ -86,7 +86,7 @@ int main(int argc, char** argv)
|
||||
|
||||
// Re-initialize the edge index, since we just added a few edges
|
||||
edge_count = 0;
|
||||
for(tie(ei, ei_end) = edges(g); ei != ei_end; ++ei)
|
||||
for(boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei)
|
||||
put(e_index, *ei, edge_count++);
|
||||
|
||||
// Re-size the storage for the biconnected components, since we
|
||||
|
@ -74,7 +74,7 @@ int main(int argc, char** argv)
|
||||
property_map<graph, edge_index_t>::type e_index = get(edge_index, g);
|
||||
graph_traits<graph>::edges_size_type edge_count = 0;
|
||||
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)
|
||||
put(e_index, *ei, edge_count++);
|
||||
|
||||
|
||||
@ -94,7 +94,7 @@ int main(int argc, char** argv)
|
||||
|
||||
// Re-initialize the edge index, since we just added a few edges
|
||||
edge_count = 0;
|
||||
for(tie(ei, ei_end) = edges(g); ei != ei_end; ++ei)
|
||||
for(boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei)
|
||||
put(e_index, *ei, edge_count++);
|
||||
|
||||
|
||||
@ -116,7 +116,7 @@ int main(int argc, char** argv)
|
||||
|
||||
// Re-initialize the edge index, since we just added a few edges
|
||||
edge_count = 0;
|
||||
for(tie(ei, ei_end) = edges(g); ei != ei_end; ++ei)
|
||||
for(boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei)
|
||||
put(e_index, *ei, edge_count++);
|
||||
|
||||
// Test for planarity one final time; compute the planar embedding as a
|
||||
|
4
example/matching_example.cpp
Executable file → Normal file
4
example/matching_example.cpp
Executable file → Normal file
@ -83,7 +83,7 @@ int main()
|
||||
std::cout << "The matching is:" << std::endl;
|
||||
|
||||
graph_traits<my_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 (mate[*vi] != graph_traits<my_graph>::null_vertex() && *vi < mate[*vi])
|
||||
std::cout << "{" << *vi << ", " << mate[*vi] << "}" << std::endl;
|
||||
|
||||
@ -109,7 +109,7 @@ int main()
|
||||
|
||||
std::cout << "The matching is:" << std::endl;
|
||||
|
||||
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<my_graph>::null_vertex() && *vi < mate[*vi])
|
||||
std::cout << "{" << *vi << ", " << mate[*vi] << "}" << std::endl;
|
||||
|
||||
|
@ -77,7 +77,7 @@ main(int argc, char *argv[])
|
||||
// Print the mean geodesic distance of each vertex and finally,
|
||||
// the graph itself.
|
||||
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) {
|
||||
cout << setw(12) << setiosflags(ios::left)
|
||||
<< g[*i].name << get(gm, *i) << endl;
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ int main(int argc, char** argv)
|
||||
property_map<graph, edge_index_t>::type e_index = get(edge_index, g);
|
||||
graph_traits<graph>::edges_size_type edge_count = 0;
|
||||
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)
|
||||
put(e_index, *ei, edge_count++);
|
||||
|
||||
|
||||
|
@ -104,7 +104,7 @@ main(int argc, char *argv[])
|
||||
|
||||
// Print the scaled closeness centrality of each vertex.
|
||||
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) {
|
||||
cout << setw(12) << setiosflags(ios::left)
|
||||
<< g[*i].name << get(cm, *i) << endl;
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ int main(int argc, char** argv)
|
||||
|
||||
std::cout << "The straight line drawing is: " << std::endl;
|
||||
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)
|
||||
{
|
||||
coord_t coord(get(straight_line_drawing,*vi));
|
||||
std::cout << *vi << " -> (" << coord.x << ", " << coord.y << ")"
|
||||
|
@ -240,7 +240,7 @@ namespace boost
|
||||
(*ordering_begin,0,g,x,delta_x,left,right);
|
||||
|
||||
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);
|
||||
drawing[v].x = x[v];
|
||||
|
@ -126,7 +126,7 @@ all_closeness_centralities(const Graph& g,
|
||||
typedef typename property_traits<CentralityMap>::value_type Centrality;
|
||||
|
||||
typename 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) {
|
||||
DistanceMap dm = get(dist, *i);
|
||||
Centrality c = closeness_centrality(g, dm, measure);
|
||||
put(cent, *i, c);
|
||||
|
@ -101,7 +101,7 @@ all_degree_centralities(const Graph& g, CentralityMap cent, Measure measure)
|
||||
typedef typename property_traits<CentralityMap>::value_type Centrality;
|
||||
|
||||
VertexIterator i, end;
|
||||
for(tie(i, end) = vertices(g); i != end; ++i) {
|
||||
for(boost::tie(i, end) = vertices(g); i != end; ++i) {
|
||||
Centrality c = degree_centrality(g, *i, measure);
|
||||
put(cent, *i, c);
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ namespace detail {
|
||||
// zero, so it shouldn't be too problematic.
|
||||
Distance ret = init;
|
||||
VertexIterator i, end;
|
||||
for(tie(i, end) = vertices(g); i != end; ++i) {
|
||||
for(boost::tie(i, end) = vertices(g); i != end; ++i) {
|
||||
Vertex v = *i;
|
||||
if(get(dist, v) != DistanceNumbers::infinity()) {
|
||||
ret = combine(ret, get(dist, v));
|
||||
|
@ -156,7 +156,7 @@ all_mean_geodesics(const Graph& g,
|
||||
Result inf = numeric_values<Result>::infinity();
|
||||
Result sum = numeric_values<Result>::zero();
|
||||
VertexIterator i, end;
|
||||
for(tie(i, end) = vertices(g); i != end; ++i) {
|
||||
for(boost::tie(i, end) = vertices(g); i != end; ++i) {
|
||||
DistanceMap dm = get(dist, *i);
|
||||
Result r = mean_geodesic(g, dm, measure);
|
||||
put(geo, *i, r);
|
||||
|
@ -33,7 +33,7 @@ namespace boost
|
||||
{
|
||||
typename graph_traits<Graph>::vertex_iterator vi, vi_end, inner_vi;
|
||||
Graph K_5(5);
|
||||
for(tie(vi,vi_end) = vertices(K_5); vi != vi_end; ++vi)
|
||||
for(boost::tie(vi,vi_end) = vertices(K_5); vi != vi_end; ++vi)
|
||||
for(inner_vi = next(vi); inner_vi != vi_end; ++inner_vi)
|
||||
add_edge(*vi, *inner_vi, K_5);
|
||||
return K_5;
|
||||
@ -47,7 +47,7 @@ namespace boost
|
||||
vi, vi_end, bipartition_start, inner_vi;
|
||||
Graph K_3_3(6);
|
||||
bipartition_start = next(next(next(vertices(K_3_3).first)));
|
||||
for(tie(vi, vi_end) = vertices(K_3_3); vi != bipartition_start; ++vi)
|
||||
for(boost::tie(vi, vi_end) = vertices(K_3_3); vi != bipartition_start; ++vi)
|
||||
for(inner_vi= bipartition_start; inner_vi != vi_end; ++inner_vi)
|
||||
add_edge(*vi, *inner_vi, K_3_3);
|
||||
return K_3_3;
|
||||
@ -158,7 +158,7 @@ namespace boost
|
||||
{
|
||||
|
||||
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);
|
||||
|
||||
@ -242,7 +242,7 @@ namespace boost
|
||||
if (max_size == 3)
|
||||
{
|
||||
// check to see whether we should go on to find a K_5
|
||||
for(tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi)
|
||||
for(boost::tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi)
|
||||
if (neighbors[*vi].size() == 4)
|
||||
{
|
||||
target_graph = detail::tg_k_5;
|
||||
@ -261,7 +261,7 @@ namespace boost
|
||||
v_list_t main_vertices;
|
||||
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 (!neighbors[*vi].empty())
|
||||
main_vertices.push_back(*vi);
|
||||
|
@ -126,7 +126,7 @@ namespace boost
|
||||
active_map_t active_edges;
|
||||
|
||||
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_t e(*ei);
|
||||
vertex_t s(source(e,g));
|
||||
|
@ -62,7 +62,7 @@ namespace boost
|
||||
degree(degree_vector.begin(), vm)
|
||||
{
|
||||
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(degree, *vi, out_degree(*vi, g));
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ namespace boost
|
||||
|
||||
// Mark all of the min degree vertex's neighbors
|
||||
adjacency_iterator_t ai, ai_end;
|
||||
for(tie(ai,ai_end) = adjacent_vertices(vertices_on_face.front(),g);
|
||||
for(boost::tie(ai,ai_end) = adjacent_vertices(vertices_on_face.front(),g);
|
||||
ai != ai_end; ++ai
|
||||
)
|
||||
{
|
||||
|
@ -67,7 +67,7 @@ namespace boost
|
||||
vertex_t first_vertex = *vertices(g).first;
|
||||
vertex_t second_vertex;
|
||||
adjacency_iterator_t ai, ai_end;
|
||||
for(tie(ai,ai_end) = adjacent_vertices(first_vertex,g); ai != ai_end; ++ai)
|
||||
for(boost::tie(ai,ai_end) = adjacent_vertices(first_vertex,g); ai != ai_end; ++ai)
|
||||
{
|
||||
if (*ai == first_vertex)
|
||||
continue;
|
||||
|
@ -98,7 +98,7 @@ namespace boost
|
||||
// PlanarEmbedding so that get(next_edge, e)[v] is the edge that comes
|
||||
// after e in the clockwise embedding around vertex v.
|
||||
|
||||
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);
|
||||
pi_begin = embedding[v].begin();
|
||||
@ -122,7 +122,7 @@ namespace boost
|
||||
std::vector<edge_t> edges_cache;
|
||||
std::vector<vertex_t> vertices_in_edge;
|
||||
|
||||
for(tie(fi,fi_end) = edges(g); fi != fi_end; ++fi)
|
||||
for(boost::tie(fi,fi_end) = edges(g); fi != fi_end; ++fi)
|
||||
{
|
||||
edge_t e(*fi);
|
||||
edges_cache.push_back(e);
|
||||
|
@ -550,8 +550,8 @@ namespace boost {
|
||||
}
|
||||
// do the bottom
|
||||
u = bos;
|
||||
ai = out_edges(u, g).first;
|
||||
while (get(excess_flow, u) > 0) {
|
||||
boost::tie(ai, a_end) = out_edges(u, g);
|
||||
while (get(excess_flow, u) > 0 && ai != a_end) {
|
||||
if (get(capacity, *ai) == 0 && is_residual_edge(*ai))
|
||||
push_flow(*ai);
|
||||
++ai;
|
||||
|
@ -193,7 +193,7 @@ namespace detail
|
||||
u = p.back(),
|
||||
v = p.front();
|
||||
OutIterator i, end;
|
||||
for(tie(i, end) = out_edges(u, g); i != end; ++i) {
|
||||
for(boost::tie(i, end) = out_edges(u, g); i != end; ++i) {
|
||||
if((target(*i, g) == v)) {
|
||||
return true;
|
||||
}
|
||||
@ -220,7 +220,7 @@ namespace detail
|
||||
|
||||
// AdjacencyIterator i, end;
|
||||
OutIterator i, end;
|
||||
for(tie(i, end) = out_edges(u, g); i != end; ++i) {
|
||||
for(boost::tie(i, end) = out_edges(u, g); i != end; ++i) {
|
||||
Vertex v = target(*i, g);
|
||||
|
||||
// if we can actually extend along this edge,
|
||||
@ -324,7 +324,7 @@ tiernan_all_cycles(const Graph& g,
|
||||
typedef typename graph_traits<Graph>::vertex_iterator VertexIterator;
|
||||
|
||||
VertexIterator i, end;
|
||||
for(tie(i, end) = vertices(g); i != end; ++i) {
|
||||
for(boost::tie(i, end) = vertices(g); i != end; ++i) {
|
||||
detail::all_cycles_from_vertex(g, *i, vis, minlen, maxlen);
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ void write_dimacs_max_flow(const Graph& g,
|
||||
|
||||
//output the edges
|
||||
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){
|
||||
out << "a " << idx[ source(*ei, g) ] + 1 << " " << idx[ target(*ei, g) ] + 1 << " " << get(capacity,*ei) << std::endl;
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ int test_graph(const std::string& dimacs_filename)
|
||||
// Initialize the interior edge index
|
||||
property_map<graph, edge_index_t>::type e_index = get(edge_index, g);
|
||||
e_size_t edge_count = 0;
|
||||
for(tie(ei, ei_end) = edges(g); ei != ei_end; ++ei)
|
||||
for(boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei)
|
||||
put(e_index, *ei, edge_count++);
|
||||
|
||||
// Initialize the interior vertex index - not needed if the vertices
|
||||
@ -145,7 +145,7 @@ int test_graph(const std::string& dimacs_filename)
|
||||
/*
|
||||
property_map<graph, vertex_index_t>::type v_index = get(vertex_index, g);
|
||||
v_size_t vertex_count = 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(v_index, *vi, vertex_count++);
|
||||
*/
|
||||
|
||||
|
@ -25,7 +25,7 @@ struct VertexIndexUpdater
|
||||
typename property_map<Graph, vertex_index_t>::type index = get(vertex_index, g);
|
||||
typename graph_traits<Graph>::vertex_iterator vi, vi_end;
|
||||
typename graph_traits<Graph>::vertices_size_type cnt = 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(index, *vi, cnt++);
|
||||
}
|
||||
};
|
||||
|
@ -42,7 +42,7 @@ int test_main(int, char*[])
|
||||
weight_pmap = get(edge_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<int> parent(numVertex);
|
||||
|
@ -93,6 +93,63 @@ void generate_random_digraph(Graph& g, double edge_probability)
|
||||
}
|
||||
}
|
||||
|
||||
void test_isomorphism2()
|
||||
{
|
||||
typedef adjacency_list<vecS, vecS, bidirectionalS> graph1;
|
||||
typedef adjacency_list<listS, listS, bidirectionalS,
|
||||
property<vertex_index_t, int> > graph2;
|
||||
|
||||
graph1 g1(2);
|
||||
add_edge(vertex(0, g1), vertex(1, g1), g1);
|
||||
add_edge(vertex(1, g1), vertex(1, g1), g1);
|
||||
graph2 g2;
|
||||
randomly_permute_graph(g1, g2);
|
||||
|
||||
int v_idx = 0;
|
||||
for (graph2::vertex_iterator v = vertices(g2).first;
|
||||
v != vertices(g2).second; ++v) {
|
||||
put(vertex_index_t(), g2, *v, v_idx++);
|
||||
}
|
||||
|
||||
std::map<graph1::vertex_descriptor, graph2::vertex_descriptor> mapping;
|
||||
|
||||
bool isomorphism_correct;
|
||||
clock_t start = clock();
|
||||
BOOST_CHECK(isomorphism_correct = isomorphism
|
||||
(g1, g2, isomorphism_map(make_assoc_property_map(mapping))));
|
||||
clock_t end = clock();
|
||||
|
||||
std::cout << "Elapsed time (clock cycles): " << (end - start) << std::endl;
|
||||
|
||||
bool verify_correct;
|
||||
BOOST_CHECK(verify_correct =
|
||||
verify_isomorphism(g1, g2, make_assoc_property_map(mapping)));
|
||||
|
||||
if (!isomorphism_correct || !verify_correct) {
|
||||
// Output graph 1
|
||||
{
|
||||
std::ofstream out("isomorphism_failure.bg1");
|
||||
out << num_vertices(g1) << std::endl;
|
||||
for (graph1::edge_iterator e = edges(g1).first;
|
||||
e != edges(g1).second; ++e) {
|
||||
out << get(vertex_index_t(), g1, source(*e, g1)) << ' '
|
||||
<< get(vertex_index_t(), g1, target(*e, g1)) << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
// Output graph 2
|
||||
{
|
||||
std::ofstream out("isomorphism_failure.bg2");
|
||||
out << num_vertices(g2) << std::endl;
|
||||
for (graph2::edge_iterator e = edges(g2).first;
|
||||
e != edges(g2).second; ++e) {
|
||||
out << get(vertex_index_t(), g2, source(*e, g2)) << ' '
|
||||
<< get(vertex_index_t(), g2, target(*e, g2)) << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void test_isomorphism(int n, double edge_probability)
|
||||
{
|
||||
typedef adjacency_list<vecS, vecS, bidirectionalS> graph1;
|
||||
|
@ -62,7 +62,7 @@ void label_graph(Graph& g)
|
||||
typedef typename graph_traits<Graph>::vertex_iterator Iter;
|
||||
Iter f, l;
|
||||
int x = 0;
|
||||
for(tie(f, l) = vertices(g); f != l; ++f, ++x) {
|
||||
for(boost::tie(f, l) = vertices(g); f != l; ++f, ++x) {
|
||||
label_vertex(*f, x, g);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ void reset_edge_index(Graph& g)
|
||||
typename property_map<Graph, edge_index_t>::type index = get(edge_index, g);
|
||||
typename graph_traits<Graph>::edge_iterator ei, ei_end;
|
||||
typename graph_traits<Graph>::edges_size_type cnt = 0;
|
||||
for(tie(ei,ei_end) = edges(g); ei != ei_end; ++ei)
|
||||
for(boost::tie(ei,ei_end) = edges(g); ei != ei_end; ++ei)
|
||||
put(index, *ei, cnt++);
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ struct UpdateVertexIndex
|
||||
typename property_map<Graph, vertex_index_t>::type index = get(vertex_index, g);
|
||||
typename graph_traits<Graph>::vertex_iterator vi, vi_end;
|
||||
typename graph_traits<Graph>::vertices_size_type cnt = 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(index, *vi, cnt++);
|
||||
}
|
||||
};
|
||||
@ -87,7 +87,7 @@ void test_line_graph(VertexIndexUpdater vertex_index_updater, int size)
|
||||
embedding_t embedding(embedding_storage.begin(), get(vertex_index, g));
|
||||
|
||||
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)
|
||||
std::copy(out_edges(*vi,g).first, out_edges(*vi,g).second, std::back_inserter(embedding[*vi]));
|
||||
|
||||
BOOST_CHECK(biconnected_components(g, make_vector_property_map<int>(get(edge_index,g))) > 1);
|
||||
|
@ -24,7 +24,7 @@ void reset_edge_index(Graph& g)
|
||||
typename property_map<Graph, edge_index_t>::type index = get(edge_index, g);
|
||||
typename graph_traits<Graph>::edge_iterator ei, ei_end;
|
||||
typename graph_traits<Graph>::edges_size_type cnt = 0;
|
||||
for(tie(ei,ei_end) = edges(g); ei != ei_end; ++ei)
|
||||
for(boost::tie(ei,ei_end) = edges(g); ei != ei_end; ++ei)
|
||||
put(index, *ei, cnt++);
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ void reset_vertex_index(Graph& g)
|
||||
typename property_map<Graph, vertex_index_t>::type index = get(vertex_index, g);
|
||||
typename graph_traits<Graph>::vertex_iterator vi, vi_end;
|
||||
typename graph_traits<Graph>::vertices_size_type cnt = 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(index, *vi, cnt++);
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ void reset_edge_index(Graph& g)
|
||||
typename property_map<Graph, edge_index_t>::type index = get(edge_index, g);
|
||||
typename graph_traits<Graph>::edge_iterator ei, ei_end;
|
||||
typename graph_traits<Graph>::edges_size_type cnt = 0;
|
||||
for(tie(ei,ei_end) = edges(g); ei != ei_end; ++ei)
|
||||
for(boost::tie(ei,ei_end) = edges(g); ei != ei_end; ++ei)
|
||||
put(index, *ei, cnt++);
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ struct UpdateVertexIndex
|
||||
typename property_map<Graph, vertex_index_t>::type index = get(vertex_index, g);
|
||||
typename graph_traits<Graph>::vertex_iterator vi, vi_end;
|
||||
typename graph_traits<Graph>::vertices_size_type cnt = 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(index, *vi, cnt++);
|
||||
}
|
||||
};
|
||||
@ -89,7 +89,7 @@ void test_cycle(VertexIndexUpdater vertex_index_updater, int size)
|
||||
embedding_t embedding(embedding_storage.begin(), get(vertex_index, g));
|
||||
|
||||
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)
|
||||
std::copy(out_edges(*vi,g).first, out_edges(*vi,g).second, std::back_inserter(embedding[*vi]));
|
||||
|
||||
BOOST_CHECK(boyer_myrvold_planarity_test(g));
|
||||
|
@ -111,7 +111,7 @@ void read_dimacs(Graph& g, const std::string& filename)
|
||||
vertex_iterator_t vi, vi_end;
|
||||
long count = 0;
|
||||
long mult_count = 0;
|
||||
for(tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
|
||||
for(boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
|
||||
{
|
||||
if (count % vertex_stride == 0)
|
||||
{
|
||||
@ -210,7 +210,7 @@ int test_graph(const std::string& dimacs_filename)
|
||||
// Initialize the interior edge index
|
||||
property_map<graph, edge_index_t>::type e_index = get(edge_index, g);
|
||||
e_size_t edge_count = 0;
|
||||
for(tie(ei, ei_end) = edges(g); ei != ei_end; ++ei)
|
||||
for(boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei)
|
||||
put(e_index, *ei, edge_count++);
|
||||
|
||||
// Initialize the interior vertex index - not needed if the vertices
|
||||
@ -218,7 +218,7 @@ int test_graph(const std::string& dimacs_filename)
|
||||
/*
|
||||
property_map<graph, vertex_index_t>::type v_index = get(vertex_index, g);
|
||||
v_size_t vertex_count = 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(v_index, *vi, vertex_count++);
|
||||
*/
|
||||
|
||||
|
@ -93,7 +93,7 @@ void connect_graph(Graph& g, VertexSet const& verts, boost::mpl::false_) {
|
||||
|
||||
std::cout << "...connect_normal\n";
|
||||
Pair *f, *l;
|
||||
for(tie(f, l) = edge_pairs(); f != l; ++f) {
|
||||
for(boost::tie(f, l) = edge_pairs(); f != l; ++f) {
|
||||
Pair const& e = *f;
|
||||
add_edge(verts[e.first], verts[e.second], g);
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ int main(int argc, char *argv[]) {
|
||||
<< endl;
|
||||
cout << "transitive closure: ";
|
||||
graph_t::edge_iterator i,iend;
|
||||
for(tie(i,iend) = edges(g_TC);i!=iend;++i) {
|
||||
for(boost::tie(i,iend) = edges(g_TC);i!=iend;++i) {
|
||||
cout << source(*i,g_TC) << "->" << target(*i,g_TC) << " ";
|
||||
}
|
||||
cout << endl;
|
||||
|
Loading…
x
Reference in New Issue
Block a user