2
0
mirror of https://github.com/boostorg/graph.git synced 2026-02-26 04:42:16 +00:00

Qualified more calls to tie; fixes #6112

[SVN r75431]
This commit is contained in:
Jeremiah Willcock
2011-11-10 15:04:27 +00:00
parent 3619e54948
commit 2b2f2d464e
39 changed files with 120 additions and 63 deletions

View File

@@ -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++);
*/

View File

@@ -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++);
}
};

View File

@@ -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);

View File

@@ -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;

View File

@@ -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);
}
}

View File

@@ -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);

View File

@@ -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++);
}

View File

@@ -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));

View File

@@ -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++);
*/

View File

@@ -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);
}

View File

@@ -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;