Skip to content

Commit

Permalink
Revert non-library changes
Browse files Browse the repository at this point in the history
  • Loading branch information
georgthegreat committed Dec 22, 2024
1 parent 1a9cab9 commit 371f28e
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 22 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ target_link_libraries(boost_graph
Boost::conversion
Boost::core
Boost::detail
Boost::foreach
Boost::function
Boost::integer
Boost::iterator
Expand Down
7 changes: 4 additions & 3 deletions doc/incremental_components.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ <H3>Example</H3>
print_graph(graph, get(boost::vertex_index, graph));
std::cout << std::endl;

for (Vertex current_vertex: vertices(graph)) {
BOOST_FOREACH(Vertex current_vertex, vertices(graph)) {
std::cout << "representative[" << current_vertex << "] = " <<
ds.find_set(current_vertex) << std::endl;
}
Expand All @@ -158,11 +158,12 @@ <H3>Example</H3>
Components components(parent.begin(), parent.end());
// Iterate through the component indices
for (VertexIndex current_index: components) {
BOOST_FOREACH(VertexIndex current_index, components) {
std::cout << "component " << current_index << " contains: ";

// Iterate through the child vertex indices for [current_index]
for (VertexIndex child_index: components[current_index]) {
BOOST_FOREACH(VertexIndex child_index,
components[current_index]) {
std::cout << child_index << " ";
}

Expand Down
3 changes: 2 additions & 1 deletion example/graph-thingie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <boost/graph/graphviz.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/foreach.hpp>
#include <string>
#include <sstream>
#include <cstdlib>
Expand Down Expand Up @@ -98,7 +99,7 @@ int main()
cout << "graph " << get("name", dp, &graph) << " ("
<< get("identifier", dp, &graph) << ")\n\n";

for (graph_t::vertex_descriptor v: vertices(graph))
BOOST_FOREACH (graph_t::vertex_descriptor v, vertices(graph))
{
cout << "vertex " << get("node_id", dp, v) << " ("
<< get("label", dp, v) << ")\n";
Expand Down
7 changes: 4 additions & 3 deletions example/incremental-components-eg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <iostream>
#include <vector>

#include <boost/foreach.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/incremental_components.hpp>
#include <boost/pending/disjoint_sets.hpp>
Expand Down Expand Up @@ -52,7 +53,7 @@ int main(int argc, char* argv[])
ds.union_set(4, 0);
ds.union_set(2, 5);

for (Vertex current_vertex: vertices(graph))
BOOST_FOREACH (Vertex current_vertex, vertices(graph))
{
std::cout << "representative[" << current_vertex
<< "] = " << ds.find_set(current_vertex) << std::endl;
Expand All @@ -68,12 +69,12 @@ int main(int argc, char* argv[])
Components components(parent.begin(), parent.end());

// Iterate through the component indices
for (VertexIndex component_index: components)
BOOST_FOREACH (VertexIndex component_index, components)
{
std::cout << "component " << component_index << " contains: ";

// Iterate through the child vertex indices for [component_index]
for (VertexIndex child_index: components[component_index])
BOOST_FOREACH (VertexIndex child_index, components[component_index])
{
std::cout << child_index << " ";
}
Expand Down
7 changes: 4 additions & 3 deletions example/incremental_components.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <iostream>
#include <vector>

#include <boost/foreach.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graph_utility.hpp>
#include <boost/graph/incremental_components.hpp>
Expand Down Expand Up @@ -85,7 +86,7 @@ int main(int argc, char* argv[])
print_graph(graph, get(boost::vertex_index, graph));
std::cout << std::endl;

for (Vertex current_vertex: vertices(graph))
BOOST_FOREACH (Vertex current_vertex, vertices(graph))
{
std::cout << "representative[" << current_vertex
<< "] = " << ds.find_set(current_vertex) << std::endl;
Expand All @@ -102,12 +103,12 @@ int main(int argc, char* argv[])
Components components(parent.begin(), parent.end());

// Iterate through the component indices
for (VertexIndex current_index: components)
BOOST_FOREACH (VertexIndex current_index, components)
{
std::cout << "component " << current_index << " contains: ";

// Iterate through the child vertex indices for [current_index]
for (VertexIndex child_index: components[current_index])
BOOST_FOREACH (VertexIndex child_index, components[current_index])
{
std::cout << child_index << " ";
}
Expand Down
14 changes: 8 additions & 6 deletions test/grid_graph_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <set>
#include <ctime>

#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/graph/grid_graph.hpp>
#include <boost/random.hpp>
Expand Down Expand Up @@ -99,7 +100,7 @@ template < unsigned int Dims > void do_test(minstd_rand& generator)

// Verify all vertices are within bounds
vertices_size_type vertex_count = 0;
for (vertex_descriptor current_vertex: vertices(graph))
BOOST_FOREACH (vertex_descriptor current_vertex, vertices(graph))
{

vertices_size_type current_index
Expand All @@ -117,7 +118,8 @@ template < unsigned int Dims > void do_test(minstd_rand& generator)
edges_size_type out_edge_count = 0;
std::set< vertices_size_type > target_vertices;

for (edge_descriptor out_edge: out_edges(current_vertex, graph))
BOOST_FOREACH (
edge_descriptor out_edge, out_edges(current_vertex, graph))
{

target_vertices.insert(
Expand All @@ -131,7 +133,7 @@ template < unsigned int Dims > void do_test(minstd_rand& generator)
// Verify in-edges of this vertex
edges_size_type in_edge_count = 0;

for (edge_descriptor in_edge: in_edges(current_vertex, graph))
BOOST_FOREACH (edge_descriptor in_edge, in_edges(current_vertex, graph))
{

BOOST_TEST(target_vertices.count(get(boost::vertex_index, graph,
Expand All @@ -151,7 +153,7 @@ template < unsigned int Dims > void do_test(minstd_rand& generator)
// Verify adjacent vertices to this vertex
vertices_size_type adjacent_count = 0;

for (vertex_descriptor adjacent_vertex:
BOOST_FOREACH (vertex_descriptor adjacent_vertex,
adjacent_vertices(current_vertex, graph))
{

Expand All @@ -166,7 +168,7 @@ template < unsigned int Dims > void do_test(minstd_rand& generator)

// Verify that this vertex is not listed as connected to any
// vertices outside of its adjacent vertices.
for (vertex_descriptor unconnected_vertex: vertices(graph))
BOOST_FOREACH (vertex_descriptor unconnected_vertex, vertices(graph))
{

vertices_size_type unconnected_index
Expand All @@ -191,7 +193,7 @@ template < unsigned int Dims > void do_test(minstd_rand& generator)

// Verify all edges are within bounds
edges_size_type edge_count = 0;
for (edge_descriptor current_edge: edges(graph))
BOOST_FOREACH (edge_descriptor current_edge, edges(graph))
{

vertices_size_type source_index
Expand Down
15 changes: 9 additions & 6 deletions test/incremental_components_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <set>
#include <ctime>

#include <boost/foreach.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/incremental_components.hpp>
#include <boost/graph/random.hpp>
Expand Down Expand Up @@ -68,19 +69,20 @@ template < typename Graph > void test_graph(const Graph& graph)
// Create a reverse-lookup map for vertex indices
std::vector< vertex_descriptor > reverse_index_map(num_vertices(graph));

for (vertex_descriptor vertex: vertices(graph))
BOOST_FOREACH (vertex_descriptor vertex, vertices(graph))
{
reverse_index_map[get(get(boost::vertex_index, graph), vertex)]
= vertex;
}

// Verify that components are really connected
for (vertices_size_type component_index: vertex_components)
BOOST_FOREACH (vertices_size_type component_index, vertex_components)
{

std::set< vertex_descriptor > component_vertices;

for (vertices_size_type child_index: vertex_components[component_index])
BOOST_FOREACH (
vertices_size_type child_index, vertex_components[component_index])
{

vertex_descriptor child_vertex = reverse_index_map[child_index];
Expand All @@ -90,7 +92,7 @@ template < typename Graph > void test_graph(const Graph& graph)

// Verify that children are connected to each other in some
// manner, but not to vertices outside their component.
for (vertex_descriptor child_vertex: component_vertices)
BOOST_FOREACH (vertex_descriptor child_vertex, component_vertices)
{

// Skip orphan vertices
Expand All @@ -103,7 +105,8 @@ template < typename Graph > void test_graph(const Graph& graph)
// another vertex in the component.
bool edge_exists = false;

for (edge_descriptor child_edge: out_edges(child_vertex, graph))
BOOST_FOREACH (
edge_descriptor child_edge, out_edges(child_vertex, graph))
{

if (component_vertices.count(target(child_edge, graph)) > 0)
Expand Down Expand Up @@ -159,7 +162,7 @@ int main(int argc, char* argv[])

// Assign indices to list_graph's vertices
graph_traits< ListGraph >::vertices_size_type index = 0;
for (graph_traits< ListGraph >::vertex_descriptor vertex:
BOOST_FOREACH (graph_traits< ListGraph >::vertex_descriptor vertex,
vertices(list_graph))
{
put(get(boost::vertex_index, list_graph), vertex, index++);
Expand Down

0 comments on commit 371f28e

Please sign in to comment.