2
0
mirror of https://github.com/boostorg/graph.git synced 2026-01-19 04:12:11 +00:00

Merge branch 'bucket_sorter' of https://github.com/deinst/graph into develop

Fixed Conflicts:
	example/Jamfile.v2
This commit is contained in:
jzmaddock
2019-01-26 09:05:44 +00:00
3 changed files with 29 additions and 40 deletions

View File

@@ -30,6 +30,7 @@ run boost_web_graph.cpp : $(TEST_DIR)/boost_web.dat ;
exe boykov_kolmogorov-eg : boykov_kolmogorov-eg.cpp ;
exe bron_kerbosch_clique_number : bron_kerbosch_clique_number.cpp ;
exe bron_kerbosch_print_cliques : bron_kerbosch_print_cliques.cpp ;
run bucket_sorter.cpp ;
run canonical_ordering.cpp ;
run city_visitor.cpp ;
exe closeness_centrality : closeness_centrality.cpp ;
@@ -223,7 +224,3 @@ explicit girth ;
# This one dereferences a null-iterator:
#
# run ordered_out_edges.cpp ;
#
# does not compile:
#
# run bucket_sorter.cpp ;

View File

@@ -24,38 +24,27 @@
#include <stdlib.h>
#include <boost/pending/bucket_sorter.hpp>
template <class Integral>
struct trivial_id {
std::size_t operator[](Integral i) {
return i;
}
std::size_t operator[](Integral i) const {
return i;
}
};
int main() {
using namespace std;
using boost::bucket_sorter;
const std::size_t N = 10;
vector<std::size_t> bucket(N);
for (std::size_t i=0; i<N; i++) {
bucket[i] = rand() % N;
cout.width(6);
cout << "Number " << i << " has its bucket " << bucket[i] << endl;
cout << "Number " << i << " is in bucket " << bucket[i] << endl;
}
typedef trivial_id<int> ID;
typedef bucket_sorter<std::size_t, int,
typedef boost::identity_property_map ID;
typedef bucket_sorter<std::size_t, int,
vector<std::size_t>::iterator, ID> BS;
BS my_bucket_sorter(N, N, bucket.begin());
for (std::size_t ii=0; ii<N; ii++)
my_bucket_sorter.push(ii);
std::size_t j;
for (j=0; j<N; j++) {
cout << "The bucket " << j;
@@ -68,7 +57,7 @@ int main() {
} while ( ! my_bucket_sorter[j].empty() );
cout << endl;
} else {
cout << " has no number associated with." << endl;
cout << " has no number associated with it." << endl;
}
}
@@ -78,7 +67,7 @@ int main() {
my_bucket_sorter.remove(5);
my_bucket_sorter.remove(7);
cout << "Afer remove number 5 and 7, check correctness again." << endl;
cout << "After removing numbers 5 and 7, check correctness again." << endl;
for (j=0; j<N; j++) {
cout << "The bucket " << j;
@@ -91,7 +80,7 @@ int main() {
} while ( ! my_bucket_sorter[j].empty() );
cout << endl;
} else {
cout << " has no number associated with." << endl;
cout << " has no number associated with it." << endl;
}
}