shared_ptr -> std::shared_ptr

This is one of the first commits in a plan to remove all `using namespace std;` lines in the entire codebase as it is considered anti-pattern today.
This commit is contained in:
void_17
2026-03-02 15:58:20 +07:00
parent d63f79325f
commit 7074f35e4b
1373 changed files with 12054 additions and 12054 deletions

View File

@@ -10,19 +10,19 @@
#define BOOST_SELF_AVOIDING_WALK_HPP
/*
This file defines necessary components for SAW.
This file defines necessary components for SAW.
mesh language: (defined by myself to clearify what is what)
A triangle in mesh is called an triangle.
An edge in mesh is called an line.
An edge in mesh is called an line.
A vertex in mesh is called a point.
A triangular mesh corresponds to a graph in which a vertex is a
triangle and an edge(u, v) stands for triangle u and triangle v
triangle and an edge(u, v) stands for triangle u and triangle v
share an line.
After this point, a vertex always refers to vertex in graph,
therefore it is a traingle in mesh.
therefore it is a traingle in mesh.
*/
@@ -43,7 +43,7 @@ namespace boost {
triple(const T1& a, const T2& b, const T3& c) : first(a), second(b), third(c) {}
triple() : first(SAW_SENTINAL), second(SAW_SENTINAL), third(SAW_SENTINAL) {}
};
typedef triple<int, int, int> Triple;
/* Define a vertex property which has a triangle inside. Triangle is
@@ -70,14 +70,14 @@ namespace boost {
if ( a.second == b.second || a.second == b.third )
l.second = a.second;
else if ( a.third == b.second || a.third == b.third )
l.second = a.third;
l.second = a.third;
} else if ( a.first == b.second ) {
l.first = a.first;
if ( a.second == b.third )
l.second = a.second;
else if ( a.third == b.third )
l.second = a.third;
l.second = a.third;
} else if ( a.first == b.third ) {
l.first = a.first;
@@ -90,17 +90,17 @@ namespace boost {
} else if ( a.second == b.second ) {
l.first = a.second;
if ( a.third == b.third )
if ( a.third == b.third )
l.second = a.third;
} else if ( a.second == b.third ) {
l.first = a.second;
} else if ( a.third == b.first
|| a.third == b.second
} else if ( a.third == b.first
|| a.third == b.second
|| a.third == b.third )
l.first = a.third;
l.first = a.third;
/*Make it in order*/
if ( l.first > l.second ) {
@@ -132,7 +132,7 @@ namespace boost {
}
TriangleDecorator td;
};
/* HList has to be a handle of data holder so that pass-by-value is
* in right logic.
*
@@ -146,7 +146,7 @@ namespace boost {
: public bfs_visitor<>, public dfs_visitor<>
{
typedef typename boost::property_traits<IteratorD>::value_type iter;
/*use boost shared_ptr*/
/*use boost std::shared_ptr*/
typedef typename HList::element_type::value_type::second_type Line;
public:
@@ -176,12 +176,12 @@ namespace boost {
using std::make_pair;
typedef typename boost::graph_traits<Graph>::vertex_descriptor Vertex;
Vertex tau = target(e, G);
Vertex i = source(e, G);
Vertex i = source(e, G);
get_vertex_sharing<TriangleDecorator, Vertex, Line> get_sharing_line(td);
Line tau_i = get_sharing_line(tau, i);
iter w_end = hlist->end();
iter w_i = iter_d[i];
@@ -197,7 +197,7 @@ namespace boost {
*b w(i) |- w(i+1) w(i) ~> w(i+1) or no w(i+1) yet
*----------------------------------------------------------
*/
bool a = false, b = false;
--w_i_m_1;
@@ -206,13 +206,13 @@ namespace boost {
if ( w_i_m_1 != w_end ) {
a = ( w_i_m_1->second.first != SAW_SENTINAL );
}
}
if ( a ) {
if ( b ) {
/*Case 1:
/*Case 1:
w(i-1) |- w(i) |- w(i+1)
*/
Line l1 = get_sharing_line(*w_i_m_1, tau);
@@ -221,7 +221,7 @@ namespace boost {
--w_i_m_2;
bool c = true;
if ( w_i_m_2 != w_end ) {
c = w_i_m_2->second != l1;
}
@@ -230,11 +230,11 @@ namespace boost {
/*extension: w(i-1) -> tau |- w(i) */
w_i_m_1->second = l1;
/*insert(pos, const T&) is to insert before pos*/
iter_d[tau] = hlist->insert(w_i, make_pair(tau, tau_i));
iter_d[tau] = hlist->insert(w_i, make_pair(tau, tau_i));
} else { /* w(i-1) ^ tau == w(i-2) ^ w(i-1) */
/*must be w(i-2) ~> w(i-1) */
bool d = true;
//need to handle the case when w_i_p_1 is null
Line l3 = get_sharing_line(*w_i_p_1, tau);
@@ -261,15 +261,15 @@ namespace boost {
;
}
}
}
} else {
} else {
/*Case 2:
w(i-1) |- w(i) ~> w(1+1)
*/
if ( w_i->second.second == tau_i.first
if ( w_i->second.second == tau_i.first
|| w_i->second.second == tau_i.second ) { /*w(i) ^ w(i+1) < w(i) ^ tau*/
/*extension: w(i) |- tau -> w(i+1) */
w_i->second = tau_i;
@@ -296,23 +296,23 @@ namespace boost {
iter_d[w_i_m_1->first] = hlist->insert(w_i_p_1, *w_i_m_1);
hlist->erase(w_i_m_1);
}
}
}
}
} else {
if ( b ) {
/*Case 3:
w(i-1) ~> w(i) |- w(i+1)
*/
bool c = false;
if ( w_i_m_1 != w_end )
c = ( w_i_m_1->second.second == tau_i.first)
|| ( w_i_m_1->second.second == tau_i.second);
if ( c ) { /*w(i-1) ^ w(i) < w(i) ^ tau*/
/* extension: w(i-1) -> tau |- w(i) */
if ( w_i_m_1 != w_end )
@@ -336,7 +336,7 @@ namespace boost {
/*extension: w(i-1) -> w(i+1) |- w(i) |- tau -> w(i+2) */
iter w_i_p_2 = w_i_p_1;
++w_i_p_2;
w_i_p_1->second = w_i->second;
iter_d[i] = hlist->insert(w_i_p_2, make_pair(i, tau_i));
hlist->erase(w_i);
@@ -344,16 +344,16 @@ namespace boost {
iter_d[tau] = hlist->insert(w_i_p_2, make_pair(tau, l2));
}
}
} else {
/*Case 4:
w(i-1) ~> w(i) ~> w(i+1)
*/
bool c = false;
if ( w_i_m_1 != w_end ) {
c = (w_i_m_1->second.second == tau_i.first)
c = (w_i_m_1->second.second == tau_i.first)
|| (w_i_m_1->second.second == tau_i.second);
}
if ( c ) { /*w(i-1) ^ w(i) < w(i) ^ tau */
@@ -361,48 +361,48 @@ namespace boost {
if ( w_i_m_1 != w_end )
w_i_m_1->second = get_sharing_line(*w_i_m_1, tau);
iter_d[tau] = hlist->insert(w_i, make_pair(tau, tau_i));
} else {
} else {
/*extension: w(i) |- tau -> w(i+1) */
w_i->second = tau_i;
Line l1;
l1.first = SAW_SENTINAL;
l1.second = SAW_SENTINAL;
if ( w_i_p_1 != w_end )
if ( w_i_p_1 != w_end )
l1 = get_sharing_line(*w_i_p_1, tau);
iter_d[tau] = hlist->insert(w_i_p_1, make_pair(tau, l1));
}
}
}
return true;
}
protected:
TriangleDecorator td; /*a decorator for vertex*/
HList hlist;
/*This must be a handle of list to record the SAW
The element type of the list is pair<Vertex, Line>
*/
IteratorD iter_d;
IteratorD iter_d;
/*Problem statement: Need a fast access to w for triangle i.
*Possible solution: mantain an array to record.
iter_d[i] will return an iterator
*Possible solution: mantain an array to record.
iter_d[i] will return an iterator
which points to w(i), where i is a vertex
representing triangle i.
*/
};
template <class Triangle, class HList, class Iterator>
inline
inline
SAW_visitor<Triangle, HList, Iterator>
visit_SAW(Triangle t, HList hl, Iterator i) {
return SAW_visitor<Triangle, HList, Iterator>(t, hl, i);
}
template <class Tri, class HList, class Iter>
inline
inline
SAW_visitor< random_access_iterator_property_map<Tri*,Tri,Tri&>,
HList, random_access_iterator_property_map<Iter*,Iter,Iter&> >
visit_SAW_ptr(Tri* t, HList hl, Iter* i) {
@@ -412,7 +412,7 @@ namespace boost {
}
// should also have combo's of pointers, and also const :(
}
#endif /*BOOST_SAW_H*/

View File

@@ -40,7 +40,7 @@ namespace boost { namespace graph { namespace distributed {
struct mpi_process_group::impl
{
typedef mpi_process_group::message_header message_header;
typedef mpi_process_group::outgoing_messages outgoing_messages;
@@ -71,7 +71,7 @@ struct mpi_process_group::impl
std::size_t batch_header_number;
std::size_t batch_buffer_size;
std::size_t batch_message_size;
/**
* The actual MPI communicator used to transmit data.
*/
@@ -90,19 +90,19 @@ struct mpi_process_group::impl
/// The numbers of processors that have entered a synchronization stage
std::vector<int> processors_synchronizing_stage;
/// The synchronization stage of a processor
std::vector<int> synchronizing_stage;
/// Number of processors still sending messages
std::vector<int> synchronizing_unfinished;
/// Number of batches sent since last synchronization stage
std::vector<int> number_sent_batches;
/// Number of batches received minus number of expected batches
std::vector<int> number_received_batches;
/// The context of the currently-executing trigger, or @c trc_none
/// if no trigger is executing.
@@ -124,7 +124,7 @@ struct mpi_process_group::impl
/// The MPI requests for posted sends of oob messages
std::vector<MPI_Request> requests;
/// The MPI buffers for posted irecvs of oob messages
std::map<int,buffer_type> buffers;
@@ -144,14 +144,14 @@ struct mpi_process_group::impl
std::stack<std::size_t> free_batches;
void free_sent_batches();
// Tag allocator
detail::tag_allocator allocated_tags;
impl(std::size_t num_headers, std::size_t buffers_size,
communicator_type parent_comm);
~impl();
private:
void set_batch_size(std::size_t header_num, std::size_t buffer_sz);
};
@@ -175,7 +175,7 @@ mpi_process_group::send_impl(int dest, int tag, const T& value,
header.source = process_id(*this);
header.tag = tag;
header.offset = outgoing.buffer.size();
boost::mpi::packed_oarchive oa(impl_->comm, outgoing.buffer);
oa << value;
@@ -237,7 +237,7 @@ send(const mpi_process_group& pg, mpi_process_group::process_id_type dest,
int tag, const T values[], std::size_t n)
{
pg.send_impl(dest, pg.encode_tag(pg.my_block_number(), tag),
boost::serialization::make_array(values,n),
boost::serialization::make_array(values,n),
boost::mpl::true_());
}
@@ -279,7 +279,7 @@ typename disable_if<boost::mpi::is_mpi_datatype<T>, void>::type
send(const mpi_process_group& pg, mpi_process_group::process_id_type dest,
int tag, const T values[], std::size_t n)
{
pg.array_send_impl(dest, pg.encode_tag(pg.my_block_number(), tag),
pg.array_send_impl(dest, pg.encode_tag(pg.my_block_number(), tag),
values, n);
}
@@ -316,7 +316,7 @@ mpi_process_group::receive_impl(int source, int tag, T& value,
// Unpack the data
if (header->bytes > 0) {
boost::mpi::packed_iarchive ia(impl_->comm, incoming.buffer,
boost::mpi::packed_iarchive ia(impl_->comm, incoming.buffer,
archive::no_header, header->offset);
ia >> value;
}
@@ -364,7 +364,7 @@ mpi_process_group::receive_impl(int source, int tag, T& value,
if (header == incoming.headers.end()) return false;
// Deserialize the data
boost::mpi::packed_iarchive in(impl_->comm, incoming.buffer,
boost::mpi::packed_iarchive in(impl_->comm, incoming.buffer,
archive::no_header, header->offset);
in >> value;
@@ -411,7 +411,7 @@ array_receive_impl(int source, int tag, T* values, std::size_t& n) const
if (header == incoming.headers.end()) return false;
// Deserialize the data
boost::mpi::packed_iarchive in(impl_->comm, incoming.buffer,
boost::mpi::packed_iarchive in(impl_->comm, incoming.buffer,
archive::no_header, header->offset);
std::size_t num_sent;
in >> num_sent;
@@ -455,7 +455,7 @@ template<typename Type, typename Handler>
void mpi_process_group::trigger(int tag, const Handler& handler)
{
BOOST_ASSERT(block_num);
install_trigger(tag,my_block_number(),shared_ptr<trigger_base>(
install_trigger(tag,my_block_number(),std::shared_ptr<trigger_base>(
new trigger_launcher<Type, Handler>(*this, tag, handler)));
}
@@ -463,28 +463,28 @@ template<typename Type, typename Handler>
void mpi_process_group::trigger_with_reply(int tag, const Handler& handler)
{
BOOST_ASSERT(block_num);
install_trigger(tag,my_block_number(),shared_ptr<trigger_base>(
install_trigger(tag,my_block_number(),std::shared_ptr<trigger_base>(
new reply_trigger_launcher<Type, Handler>(*this, tag, handler)));
}
template<typename Type, typename Handler>
void mpi_process_group::global_trigger(int tag, const Handler& handler,
void mpi_process_group::global_trigger(int tag, const Handler& handler,
std::size_t sz)
{
if (sz==0) // normal trigger
install_trigger(tag,0,shared_ptr<trigger_base>(
install_trigger(tag,0,std::shared_ptr<trigger_base>(
new global_trigger_launcher<Type, Handler>(*this, tag, handler)));
else // trigger with irecv
install_trigger(tag,0,shared_ptr<trigger_base>(
install_trigger(tag,0,std::shared_ptr<trigger_base>(
new global_irecv_trigger_launcher<Type, Handler>(*this, tag, handler,sz)));
}
namespace detail {
template<typename Type>
void do_oob_receive(mpi_process_group const& self,
int source, int tag, Type& data, mpl::true_ /*is_mpi_datatype*/)
int source, int tag, Type& data, mpl::true_ /*is_mpi_datatype*/)
{
using boost::mpi::get_mpi_datatype;
@@ -495,7 +495,7 @@ void do_oob_receive(mpi_process_group const& self,
template<typename Type>
void do_oob_receive(mpi_process_group const& self,
int source, int tag, Type& data, mpl::false_ /*is_mpi_datatype*/)
int source, int tag, Type& data, mpl::false_ /*is_mpi_datatype*/)
{
// self.impl_->comm.recv(source,tag,data);
// Receive the size of the data packet
@@ -521,7 +521,7 @@ void do_oob_receive(mpi_process_group const& self,
}
template<typename Type>
void do_oob_receive(mpi_process_group const& self, int source, int tag, Type& data)
void do_oob_receive(mpi_process_group const& self, int source, int tag, Type& data)
{
do_oob_receive(self, source, tag, data,
boost::mpi::is_mpi_datatype<Type>());
@@ -532,13 +532,13 @@ void do_oob_receive(mpi_process_group const& self, int source, int tag, Type& da
template<typename Type, typename Handler>
void
void
mpi_process_group::trigger_launcher<Type, Handler>::
receive(mpi_process_group const&, int source, int tag,
receive(mpi_process_group const&, int source, int tag,
trigger_receive_context context, int block) const
{
#ifdef PBGL_PROCESS_GROUP_DEBUG
std::cerr << (out_of_band? "OOB trigger" : "Trigger")
std::cerr << (out_of_band? "OOB trigger" : "Trigger")
<< " receive from source " << source << " and tag " << tag
<< " in block " << (block == -1 ? self.my_block_number() : block) << std::endl;
#endif
@@ -560,13 +560,13 @@ receive(mpi_process_group const&, int source, int tag,
}
template<typename Type, typename Handler>
void
void
mpi_process_group::reply_trigger_launcher<Type, Handler>::
receive(mpi_process_group const&, int source, int tag,
receive(mpi_process_group const&, int source, int tag,
trigger_receive_context context, int block) const
{
#ifdef PBGL_PROCESS_GROUP_DEBUG
std::cerr << (out_of_band? "OOB reply trigger" : "Reply trigger")
std::cerr << (out_of_band? "OOB reply trigger" : "Reply trigger")
<< " receive from source " << source << " and tag " << tag
<< " in block " << (block == -1 ? self.my_block_number() : block) << std::endl;
#endif
@@ -581,18 +581,18 @@ receive(mpi_process_group const&, int source, int tag,
// Pass the message off to the handler and send the result back to
// the source.
send_oob(self, source, data.first,
send_oob(self, source, data.first,
handler(source, tag, data.second, context), -2);
}
template<typename Type, typename Handler>
void
void
mpi_process_group::global_trigger_launcher<Type, Handler>::
receive(mpi_process_group const& self, int source, int tag,
receive(mpi_process_group const& self, int source, int tag,
trigger_receive_context context, int block) const
{
#ifdef PBGL_PROCESS_GROUP_DEBUG
std::cerr << (out_of_band? "OOB trigger" : "Trigger")
std::cerr << (out_of_band? "OOB trigger" : "Trigger")
<< " receive from source " << source << " and tag " << tag
<< " in block " << (block == -1 ? self.my_block_number() : block) << std::endl;
#endif
@@ -615,13 +615,13 @@ receive(mpi_process_group const& self, int source, int tag,
template<typename Type, typename Handler>
void
void
mpi_process_group::global_irecv_trigger_launcher<Type, Handler>::
receive(mpi_process_group const& self, int source, int tag,
receive(mpi_process_group const& self, int source, int tag,
trigger_receive_context context, int block) const
{
#ifdef PBGL_PROCESS_GROUP_DEBUG
std::cerr << (out_of_band? "OOB trigger" : "Trigger")
std::cerr << (out_of_band? "OOB trigger" : "Trigger")
<< " receive from source " << source << " and tag " << tag
<< " in block " << (block == -1 ? self.my_block_number() : block) << std::endl;
#endif
@@ -644,12 +644,12 @@ receive(mpi_process_group const& self, int source, int tag,
template<typename Type, typename Handler>
void
void
mpi_process_group::global_irecv_trigger_launcher<Type, Handler>::
prepare_receive(mpi_process_group const& self, int tag, bool force) const
{
#ifdef PBGL_PROCESS_GROUP_DEBUG
std::cerr << ("Posting Irecv for trigger")
std::cerr << ("Posting Irecv for trigger")
<< " receive with tag " << tag << std::endl;
#endif
if (self.impl_->buffers.find(tag) == self.impl_->buffers.end()) {
@@ -657,7 +657,7 @@ prepare_receive(mpi_process_group const& self, int tag, bool force) const
force = true;
}
BOOST_ASSERT(static_cast<int>(self.impl_->buffers[tag].size()) >= buffer_size);
//BOOST_MPL_ASSERT(mpl::not_<is_mpi_datatype<Type> >);
if (force) {
self.impl_->requests.push_back(MPI_Request());
@@ -681,8 +681,8 @@ receive(const mpi_process_group& pg, int tag, T& value)
}
template<typename T>
typename
enable_if<boost::mpi::is_mpi_datatype<T>,
typename
enable_if<boost::mpi::is_mpi_datatype<T>,
std::pair<mpi_process_group::process_id_type, std::size_t> >::type
receive(const mpi_process_group& pg, int tag, T values[], std::size_t n)
{
@@ -691,15 +691,15 @@ receive(const mpi_process_group& pg, int tag, T values[], std::size_t n)
pg.receive_impl(source, pg.encode_tag(pg.my_block_number(), tag),
boost::serialization::make_array(values,n),
boost::mpl::true_());
if (result)
if (result)
return std::make_pair(source, n);
}
BOOST_ASSERT(false);
}
template<typename T>
typename
disable_if<boost::mpi::is_mpi_datatype<T>,
typename
disable_if<boost::mpi::is_mpi_datatype<T>,
std::pair<mpi_process_group::process_id_type, std::size_t> >::type
receive(const mpi_process_group& pg, int tag, T values[], std::size_t n)
{
@@ -730,14 +730,14 @@ receive(const mpi_process_group& pg,
}
template<typename T>
typename
enable_if<boost::mpi::is_mpi_datatype<T>,
typename
enable_if<boost::mpi::is_mpi_datatype<T>,
std::pair<mpi_process_group::process_id_type, std::size_t> >::type
receive(const mpi_process_group& pg, int source, int tag, T values[],
receive(const mpi_process_group& pg, int source, int tag, T values[],
std::size_t n)
{
if (pg.receive_impl(source, pg.encode_tag(pg.my_block_number(), tag),
boost::serialization::make_array(values,n),
boost::serialization::make_array(values,n),
boost::mpl::true_()))
return std::make_pair(source,n);
else {
@@ -751,10 +751,10 @@ receive(const mpi_process_group& pg, int source, int tag, T values[],
}
template<typename T>
typename
disable_if<boost::mpi::is_mpi_datatype<T>,
typename
disable_if<boost::mpi::is_mpi_datatype<T>,
std::pair<mpi_process_group::process_id_type, std::size_t> >::type
receive(const mpi_process_group& pg, int source, int tag, T values[],
receive(const mpi_process_group& pg, int source, int tag, T values[],
std::size_t n)
{
pg.array_receive_impl(source, pg.encode_tag(pg.my_block_number(), tag),
@@ -775,7 +775,7 @@ all_reduce(const mpi_process_group& pg, T* first, T* last, T* out,
if (inplace) out = new T [last-first];
boost::mpi::all_reduce(boost::mpi::communicator(communicator(pg),
boost::mpi::comm_attach),
boost::mpi::comm_attach),
first, last-first, out, bin_op);
if (inplace) {
@@ -789,10 +789,10 @@ all_reduce(const mpi_process_group& pg, T* first, T* last, T* out,
template<typename T>
void
broadcast(const mpi_process_group& pg, T& val,
broadcast(const mpi_process_group& pg, T& val,
mpi_process_group::process_id_type root)
{
// broadcast the seed
// broadcast the seed
boost::mpi::communicator comm(communicator(pg),boost::mpi::comm_attach);
boost::mpi::broadcast(comm,val,root);
}
@@ -914,7 +914,7 @@ Receiver* mpi_process_group::get_receiver()
template<typename T>
typename enable_if<boost::mpi::is_mpi_datatype<T> >::type
receive_oob(const mpi_process_group& pg,
receive_oob(const mpi_process_group& pg,
mpi_process_group::process_id_type source, int tag, T& value, int block)
{
using boost::mpi::get_mpi_datatype;
@@ -926,8 +926,8 @@ receive_oob(const mpi_process_group& pg,
// Post a non-blocking receive that waits until we complete this request.
MPI_Request request;
MPI_Irecv(&value, 1, get_mpi_datatype<T>(value),
source, actual.second, actual.first, &request);
MPI_Irecv(&value, 1, get_mpi_datatype<T>(value),
source, actual.second, actual.first, &request);
int done = 0;
do {
@@ -939,7 +939,7 @@ receive_oob(const mpi_process_group& pg,
template<typename T>
typename disable_if<boost::mpi::is_mpi_datatype<T> >::type
receive_oob(const mpi_process_group& pg,
receive_oob(const mpi_process_group& pg,
mpi_process_group::process_id_type source, int tag, T& value, int block)
{
// Determine the actual message we expect to receive, and which
@@ -967,11 +967,11 @@ receive_oob(const mpi_process_group& pg,
MPI_Get_count(&mpi_status, MPI_PACKED, &size);
in.resize(size);
#endif
// Receive the message data
MPI_Recv(in.address(), in.size(), MPI_PACKED,
status->source(), status->tag(), actual.first, MPI_STATUS_IGNORE);
// Unpack the message data
in >> value;
}
@@ -979,7 +979,7 @@ receive_oob(const mpi_process_group& pg,
template<typename SendT, typename ReplyT>
typename enable_if<boost::mpi::is_mpi_datatype<ReplyT> >::type
send_oob_with_reply(const mpi_process_group& pg,
send_oob_with_reply(const mpi_process_group& pg,
mpi_process_group::process_id_type dest,
int tag, const SendT& send_value, ReplyT& reply_value,
int block)
@@ -992,14 +992,14 @@ send_oob_with_reply(const mpi_process_group& pg,
template<typename SendT, typename ReplyT>
typename disable_if<boost::mpi::is_mpi_datatype<ReplyT> >::type
send_oob_with_reply(const mpi_process_group& pg,
send_oob_with_reply(const mpi_process_group& pg,
mpi_process_group::process_id_type dest,
int tag, const SendT& send_value, ReplyT& reply_value,
int block)
{
detail::tag_allocator::token reply_tag = pg.impl_->allocated_tags.get_tag();
send_oob(pg, dest, tag,
boost::parallel::detail::make_untracked_pair((int)reply_tag,
send_oob(pg, dest, tag,
boost::parallel::detail::make_untracked_pair((int)reply_tag,
send_value), block);
receive_oob(pg, dest, reply_tag, reply_value);
}

View File

@@ -20,7 +20,7 @@
#define SEND_OOB_BSEND
#include <boost/optional.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/std::shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include <utility>
#include <memory>
@@ -48,7 +48,7 @@ class mpi_process_group
* The type of a "receive" handler, that will be provided with
* (source, tag) pairs when a message is received. Users can provide a
* receive handler for a distributed data structure, for example, to
* automatically pick up and respond to messages as needed.
* automatically pick up and respond to messages as needed.
*/
typedef function<void(int source, int tag)> receiver_type;
@@ -75,7 +75,7 @@ class mpi_process_group
/// Classification of the capabilities of this process group
struct communication_category
: virtual parallel::bsp_process_group_tag,
: virtual parallel::bsp_process_group_tag,
virtual mpi_process_group_tag { };
// TBD: We can eliminate the "source" field and possibly the
@@ -92,7 +92,7 @@ class mpi_process_group
/// The length of the message in the buffer, in bytes
std::size_t bytes;
template <class Archive>
void serialize(Archive& ar, int)
{
@@ -113,14 +113,14 @@ class mpi_process_group
std::vector<message_header> headers;
buffer_type buffer;
template <class Archive>
void serialize(Archive& ar, int)
{
ar & headers & buffer;
}
void swap(outgoing_messages& x)
void swap(outgoing_messages& x)
{
headers.swap(x.headers);
buffer.swap(x.buffer);
@@ -137,21 +137,21 @@ private:
public:
explicit trigger_base(int tag) : tag_(tag) { }
/// Retrieve the tag associated with this trigger
/// Retrieve the tag associated with this trigger
int tag() const { return tag_; }
virtual ~trigger_base() { }
/**
* Invoked to receive a message that matches a particular trigger.
* Invoked to receive a message that matches a particular trigger.
*
* @param source the source of the message
* @param tag the (local) tag of the message
* @param context the context under which the trigger is being
* invoked
*/
virtual void
receive(mpi_process_group const& pg, int source, int tag,
virtual void
receive(mpi_process_group const& pg, int source, int tag,
trigger_receive_context context, int block=-1) const = 0;
protected:
@@ -162,19 +162,19 @@ private:
/**
* Launches a specific handler in response to a trigger. This
* function object wraps up the handler function object and a buffer
* for incoming data.
* for incoming data.
*/
template<typename Type, typename Handler>
class trigger_launcher : public trigger_base
{
public:
explicit trigger_launcher(mpi_process_group& self, int tag,
const Handler& handler)
: trigger_base(tag), self(self), handler(handler)
explicit trigger_launcher(mpi_process_group& self, int tag,
const Handler& handler)
: trigger_base(tag), self(self), handler(handler)
{}
void
receive(mpi_process_group const& pg, int source, int tag,
void
receive(mpi_process_group const& pg, int source, int tag,
trigger_receive_context context, int block=-1) const;
private:
@@ -191,13 +191,13 @@ private:
class reply_trigger_launcher : public trigger_base
{
public:
explicit reply_trigger_launcher(mpi_process_group& self, int tag,
const Handler& handler)
: trigger_base(tag), self(self), handler(handler)
explicit reply_trigger_launcher(mpi_process_group& self, int tag,
const Handler& handler)
: trigger_base(tag), self(self), handler(handler)
{}
void
receive(mpi_process_group const& pg, int source, int tag,
void
receive(mpi_process_group const& pg, int source, int tag,
trigger_receive_context context, int block=-1) const;
private:
@@ -209,14 +209,14 @@ private:
class global_trigger_launcher : public trigger_base
{
public:
explicit global_trigger_launcher(mpi_process_group& self, int tag,
const Handler& handler)
: trigger_base(tag), handler(handler)
{
explicit global_trigger_launcher(mpi_process_group& self, int tag,
const Handler& handler)
: trigger_base(tag), handler(handler)
{
}
void
receive(mpi_process_group const& pg, int source, int tag,
void
receive(mpi_process_group const& pg, int source, int tag,
trigger_receive_context context, int block=-1) const;
private:
@@ -229,15 +229,15 @@ private:
class global_irecv_trigger_launcher : public trigger_base
{
public:
explicit global_irecv_trigger_launcher(mpi_process_group& self, int tag,
const Handler& handler, int sz)
explicit global_irecv_trigger_launcher(mpi_process_group& self, int tag,
const Handler& handler, int sz)
: trigger_base(tag), handler(handler), buffer_size(sz)
{
{
prepare_receive(self,tag);
}
void
receive(mpi_process_group const& pg, int source, int tag,
void
receive(mpi_process_group const& pg, int source, int tag,
trigger_receive_context context, int block=-1) const;
private:
@@ -249,32 +249,32 @@ private:
};
public:
/**
/**
* Construct a new BSP process group from an MPI communicator. The
* MPI communicator will be duplicated to create a new communicator
* for this process group to use.
*/
mpi_process_group(communicator_type parent_comm = communicator_type());
/**
/**
* Construct a new BSP process group from an MPI communicator. The
* MPI communicator will be duplicated to create a new communicator
* for this process group to use. This constructor allows to tune the
* size of message batches.
*
*
* @param num_headers The maximum number of headers in a message batch
*
* @param buffer_size The maximum size of the message buffer in a batch.
*
*/
mpi_process_group( std::size_t num_headers, std::size_t buffer_size,
mpi_process_group( std::size_t num_headers, std::size_t buffer_size,
communicator_type parent_comm = communicator_type());
/**
* Construct a copy of the BSP process group for a new distributed
* data structure. This data structure will synchronize with all
* other members of the process group's equivalence class (including
* @p other), but will have its own set of tags.
* @p other), but will have its own set of tags.
*
* @param other The process group that this new process group will
* be based on, using a different set of tags within the same
@@ -296,9 +296,9 @@ public:
* Construct a copy of the BSP process group for a new distributed
* data structure. This data structure will synchronize with all
* other members of the process group's equivalence class (including
* @p other), but will have its own set of tags.
* @p other), but will have its own set of tags.
*/
mpi_process_group(const mpi_process_group& other,
mpi_process_group(const mpi_process_group& other,
attach_distributed_object,
bool out_of_band_receive = false);
@@ -335,7 +335,7 @@ public:
void
replace_on_synchronize_handler(const on_synchronize_event_type& handler = 0);
/**
/**
* Return the block number of the current data structure. A value of
* 0 indicates that this particular instance of the process group is
* not associated with any distributed data structure.
@@ -350,7 +350,7 @@ public:
{ return block_num * max_tags + tag; }
/**
* Decode an encoded tag into a block number/tag pair.
* Decode an encoded tag into a block number/tag pair.
*/
std::pair<int, int> decode_tag(int encoded_tag) const
{ return std::make_pair(encoded_tag / max_tags, encoded_tag % max_tags); }
@@ -366,13 +366,13 @@ public:
*/
int allocate_block(bool out_of_band_receive = false);
/** Potentially emit a receive event out of band. Returns true if an event
* was actually sent, false otherwise.
/** Potentially emit a receive event out of band. Returns true if an event
* was actually sent, false otherwise.
*/
bool maybe_emit_receive(int process, int encoded_tag) const;
/** Emit a receive event. Returns true if an event was actually
* sent, false otherwise.
* sent, false otherwise.
*/
bool emit_receive(int process, int encoded_tag) const;
@@ -450,7 +450,7 @@ public:
void trigger_with_reply(int tag, const Handler& handler);
template<typename Type, typename Handler>
void global_trigger(int tag, const Handler& handler, std::size_t buffer_size=0);
void global_trigger(int tag, const Handler& handler, std::size_t buffer_size=0);
@@ -468,7 +468,7 @@ public:
* @param synchronizing whether we are currently synchronizing the
* process group
*/
optional<std::pair<int, int> >
optional<std::pair<int, int> >
poll(bool wait = false, int block = -1, bool synchronizing = false) const;
/**
@@ -489,11 +489,11 @@ public:
///
/// Determine the actual communicator and tag will be used for a
/// transmission with the given tag.
std::pair<boost::mpi::communicator, int>
std::pair<boost::mpi::communicator, int>
actual_communicator_and_tag(int tag, int block) const;
/// set the size of the message buffer used for buffered oob sends
static void set_message_buffer_size(std::size_t s);
/// get the size of the message buffer used for buffered oob sends
@@ -503,12 +503,12 @@ public:
static void* old_buffer;
private:
void install_trigger(int tag, int block,
shared_ptr<trigger_base> const& launcher);
void install_trigger(int tag, int block,
std::shared_ptr<trigger_base> const& launcher);
void poll_requests(int block=-1) const;
// send a batch if the buffer is full now or would get full
void maybe_send_batch(process_id_type dest) const;
@@ -527,7 +527,7 @@ private:
void receive_batch(boost::mpi::status& status) const;
//void free_finished_sends() const;
/// Status messages used internally by the process group
enum status_messages {
/// the first of the reserved message tags
@@ -557,13 +557,13 @@ private:
/// Handler for receive events
receiver_type on_receive;
/// Handler executed at the start of synchronization
/// Handler executed at the start of synchronization
on_synchronize_event_type on_synchronize;
/// Individual message triggers. Note: at present, this vector is
/// indexed by the (local) tag of the trigger. Any tags that
/// don't have triggers will have NULL pointers in that spot.
std::vector<shared_ptr<trigger_base> > triggers;
std::vector<std::shared_ptr<trigger_base> > triggers;
};
/**
@@ -581,7 +581,7 @@ private:
* @c block_num.
*/
struct deallocate_block;
static std::vector<char> message_buffer;
public:
@@ -589,17 +589,17 @@ public:
* Data associated with the process group and all of its attached
* distributed data structures.
*/
shared_ptr<impl> impl_;
std::shared_ptr<impl> impl_;
/**
* When non-null, indicates that this copy of the process group is
* associated with a particular distributed data structure. The
* integer value contains the block number (a value > 0) associated
* with that data structure. The deleter for this @c shared_ptr is a
* with that data structure. The deleter for this @c std::shared_ptr is a
* @c deallocate_block object that will deallocate the associated
* block in @c impl_->blocks.
*/
shared_ptr<int> block_num;
std::shared_ptr<int> block_num;
/**
* Rank of this process, to avoid having to call rank() repeatedly.
@@ -615,11 +615,11 @@ public:
inline mpi_process_group::process_id_type
inline mpi_process_group::process_id_type
process_id(const mpi_process_group& pg)
{ return pg.rank; }
inline mpi_process_group::process_size_type
inline mpi_process_group::process_size_type
num_processes(const mpi_process_group& pg)
{ return pg.size; }
@@ -683,7 +683,7 @@ process_subgroup(const mpi_process_group& pg,
template<typename T>
void
broadcast(const mpi_process_group& pg, T& val,
broadcast(const mpi_process_group& pg, T& val,
mpi_process_group::process_id_type root);
@@ -705,15 +705,15 @@ send_oob(const mpi_process_group& pg, mpi_process_group::process_id_type dest,
#ifdef SEND_OOB_BSEND
if (mpi_process_group::message_buffer_size()) {
MPI_Bsend(const_cast<T*>(&value), 1, get_mpi_datatype<T>(value), dest,
MPI_Bsend(const_cast<T*>(&value), 1, get_mpi_datatype<T>(value), dest,
actual.second, actual.first);
return;
}
#endif
MPI_Request request;
MPI_Isend(const_cast<T*>(&value), 1, get_mpi_datatype<T>(value), dest,
MPI_Isend(const_cast<T*>(&value), 1, get_mpi_datatype<T>(value), dest,
actual.second, actual.first, &request);
int done=0;
do {
pg.poll();
@@ -759,24 +759,24 @@ send_oob(const mpi_process_group& pg, mpi_process_group::process_id_type dest,
template<typename T>
typename enable_if<boost::mpi::is_mpi_datatype<T> >::type
receive_oob(const mpi_process_group& pg,
receive_oob(const mpi_process_group& pg,
mpi_process_group::process_id_type source, int tag, T& value, int block=-1);
template<typename T>
typename disable_if<boost::mpi::is_mpi_datatype<T> >::type
receive_oob(const mpi_process_group& pg,
receive_oob(const mpi_process_group& pg,
mpi_process_group::process_id_type source, int tag, T& value, int block=-1);
template<typename SendT, typename ReplyT>
typename enable_if<boost::mpi::is_mpi_datatype<ReplyT> >::type
send_oob_with_reply(const mpi_process_group& pg,
send_oob_with_reply(const mpi_process_group& pg,
mpi_process_group::process_id_type dest,
int tag, const SendT& send_value, ReplyT& reply_value,
int block = -1);
template<typename SendT, typename ReplyT>
typename disable_if<boost::mpi::is_mpi_datatype<ReplyT> >::type
send_oob_with_reply(const mpi_process_group& pg,
send_oob_with_reply(const mpi_process_group& pg,
mpi_process_group::process_id_type dest,
int tag, const SendT& send_value, ReplyT& reply_value,
int block = -1);
@@ -791,7 +791,7 @@ namespace boost { namespace mpi {
namespace std {
/// optimized swap for outgoing messages
inline void
inline void
swap(boost::graph::distributed::mpi_process_group::outgoing_messages& x,
boost::graph::distributed::mpi_process_group::outgoing_messages& y)
{

View File

@@ -15,7 +15,7 @@
#include <boost/graph/parallel/process_group.hpp>
#include <boost/optional.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/std::shared_ptr.hpp>
#include <vector>
namespace boost { namespace graph { namespace distributed {
@@ -213,12 +213,12 @@ class distributed_queue
void setup_triggers();
// Message handlers
void
handle_push(int source, int tag, const value_type& value,
void
handle_push(int source, int tag, const value_type& value,
trigger_receive_context);
void
handle_multipush(int source, int tag, const std::vector<value_type>& values,
void
handle_multipush(int source, int tag, const std::vector<value_type>& values,
trigger_receive_context);
mutable ProcessGroup process_group;
@@ -229,7 +229,7 @@ class distributed_queue
typedef std::vector<value_type> outgoing_buffer_t;
typedef std::vector<outgoing_buffer_t> outgoing_buffers_t;
shared_ptr<outgoing_buffers_t> outgoing_buffers;
std::shared_ptr<outgoing_buffers_t> outgoing_buffers;
};
/// Helper macro containing the normal names for the template

View File

@@ -25,7 +25,7 @@ namespace boost {
// requires an MPI process group. Run-time is slightly worse than
// the unique rmat generator. Edge list generated is sorted and
// unique.
template<typename ProcessGroup, typename Distribution,
template<typename ProcessGroup, typename Distribution,
typename RandomGenerator, typename Graph>
class scalable_rmat_iterator
{
@@ -47,8 +47,8 @@ namespace boost {
// Initialize for edge generation
scalable_rmat_iterator(ProcessGroup pg, Distribution distrib,
RandomGenerator& gen, vertices_size_type n,
edges_size_type m, double a, double b, double c,
RandomGenerator& gen, vertices_size_type n,
edges_size_type m, double a, double b, double c,
double d, bool permute_vertices = true)
: gen(), done(false)
{
@@ -58,12 +58,12 @@ namespace boost {
this->gen.reset(new uniform_01<RandomGenerator>(gen));
std::vector<vertices_size_type> vertexPermutation;
if (permute_vertices)
if (permute_vertices)
generate_permutation_vector(gen, vertexPermutation, n);
int SCALE = int(floor(log(double(n))/log(2.)));
boost::uniform_01<RandomGenerator> prob(gen);
std::map<value_type, bool> edge_map;
edges_size_type generated = 0, local_edges = 0;
@@ -121,13 +121,13 @@ namespace boost {
reference operator*() const { return current; }
pointer operator->() const { return &current; }
scalable_rmat_iterator& operator++()
{
if (!values.empty()) {
current = values.back();
values.pop_back();
} else
} else
done = true;
return *this;
@@ -151,7 +151,7 @@ namespace boost {
private:
// Parameters
shared_ptr<uniform_01<RandomGenerator> > gen;
std::shared_ptr<uniform_01<RandomGenerator> > gen;
// Internal data structures
std::vector<value_type> values;

View File

@@ -16,7 +16,7 @@
#include <boost/graph/graph_traits.hpp>
#include <vector>
#include <boost/shared_ptr.hpp>
#include <boost/std::shared_ptr.hpp>
#include <boost/property_map/property_map.hpp>
#include <boost/graph/parallel/algorithm.hpp>
#include <boost/graph/parallel/container_traits.hpp>
@@ -25,9 +25,9 @@
namespace boost { namespace graph {
// --------------------------------------------------------------------------
// Global index map built from a distribution
// Global index map built from a distribution
// --------------------------------------------------------------------------
template<typename Distribution, typename OwnerPropertyMap,
template<typename Distribution, typename OwnerPropertyMap,
typename LocalPropertyMap>
class distribution_global_index_map
{
@@ -47,16 +47,16 @@ class distribution_global_index_map
LocalPropertyMap local;
};
template<typename Distribution, typename OwnerPropertyMap,
template<typename Distribution, typename OwnerPropertyMap,
typename LocalPropertyMap>
inline
inline
typename distribution_global_index_map<Distribution, OwnerPropertyMap,
LocalPropertyMap>::value_type
get(const distribution_global_index_map<Distribution, OwnerPropertyMap,
LocalPropertyMap>& p,
typename distribution_global_index_map<Distribution, OwnerPropertyMap,
LocalPropertyMap>::key_type x)
{
{
using boost::get;
return p.distribution_.global(get(p.owner, x), get(p.local, x));
}
@@ -64,15 +64,15 @@ get(const distribution_global_index_map<Distribution, OwnerPropertyMap,
template<typename Graph, typename Distribution>
inline
distribution_global_index_map<
Distribution,
Distribution,
typename property_map<Graph, vertex_owner_t>::const_type,
typename property_map<Graph, vertex_local_t>::const_type>
make_distribution_global_index_map(const Graph& g, const Distribution& d)
{
typedef distribution_global_index_map<
Distribution,
Distribution,
typename property_map<Graph, vertex_owner_t>::const_type,
typename property_map<Graph, vertex_local_t>::const_type>
typename property_map<Graph, vertex_local_t>::const_type>
result_type;
return result_type(d, get(vertex_owner, g), get(vertex_local, g));
}
@@ -86,7 +86,7 @@ class stored_global_index_map : public IndexMap
public:
typedef readable_property_map_tag category;
stored_global_index_map(const IndexMap& index_map) : IndexMap(index_map) {
stored_global_index_map(const IndexMap& index_map) : IndexMap(index_map) {
// When we have a global index, we need to always have the indices
// of every key we've seen
this->set_max_ghost_cells(0);
@@ -98,13 +98,13 @@ class stored_global_index_map : public IndexMap
// --------------------------------------------------------------------------
namespace detail {
template<typename PropertyMap, typename ForwardIterator>
inline void
initialize_global_index_map(const PropertyMap&,
ForwardIterator, ForwardIterator)
inline void
initialize_global_index_map(const PropertyMap&,
ForwardIterator, ForwardIterator)
{ }
template<typename IndexMap, typename ForwardIterator>
void
void
initialize_global_index_map(stored_global_index_map<IndexMap>& p,
ForwardIterator first, ForwardIterator last)
{
@@ -126,18 +126,18 @@ class vertex_list_adaptor : public graph_traits<Graph>
typedef graph_traits<Graph> inherited;
typedef typename inherited::traversal_category base_traversal_category;
public:
typedef typename inherited::vertex_descriptor vertex_descriptor;
typedef typename std::vector<vertex_descriptor>::iterator vertex_iterator;
typedef typename std::vector<vertex_descriptor>::size_type
vertices_size_type;
struct traversal_category
struct traversal_category
: public virtual base_traversal_category,
public virtual vertex_list_graph_tag {};
vertex_list_adaptor(const Graph& g,
vertex_list_adaptor(const Graph& g,
const GlobalIndexMap& index_map = GlobalIndexMap())
: g(&g), index_map(index_map)
{
@@ -146,7 +146,7 @@ class vertex_list_adaptor : public graph_traits<Graph>
all_vertices_.reset(new std::vector<vertex_descriptor>());
all_gather(process_group(), vertices(g).first, vertices(g).second,
*all_vertices_);
detail::initialize_global_index_map(this->index_map,
detail::initialize_global_index_map(this->index_map,
all_vertices_->begin(),
all_vertices_->end());
}
@@ -156,13 +156,13 @@ class vertex_list_adaptor : public graph_traits<Graph>
// --------------------------------------------------------------------------
// Distributed Container
// --------------------------------------------------------------------------
typedef typename boost::graph::parallel::process_group_type<Graph>::type
typedef typename boost::graph::parallel::process_group_type<Graph>::type
process_group_type;
process_group_type process_group() const
{
process_group_type process_group() const
{
using boost::graph::parallel::process_group;
return process_group(*g);
return process_group(*g);
}
std::pair<vertex_iterator, vertex_iterator> vertices() const
@@ -175,7 +175,7 @@ class vertex_list_adaptor : public graph_traits<Graph>
private:
const Graph* g;
GlobalIndexMap index_map;
shared_ptr<std::vector<vertex_descriptor> > all_vertices_;
std::shared_ptr<std::vector<vertex_descriptor> > all_vertices_;
};
template<typename Graph, typename GlobalIndexMap>
@@ -197,18 +197,18 @@ namespace detail {
}
template<typename Graph>
inline
vertex_list_adaptor<Graph,
inline
vertex_list_adaptor<Graph,
typename detail::default_global_index_map<Graph>::type>
make_vertex_list_adaptor(const Graph& g)
{
typedef typename detail::default_global_index_map<Graph>::type
{
typedef typename detail::default_global_index_map<Graph>::type
GlobalIndexMap;
typedef typename detail::default_global_index_map<Graph>::distributed_map
DistributedMap;
typedef vertex_list_adaptor<Graph, GlobalIndexMap> result_type;
return result_type(g,
GlobalIndexMap(DistributedMap(num_vertices(g),
return result_type(g,
GlobalIndexMap(DistributedMap(num_vertices(g),
get(vertex_index, g))));
}
@@ -375,7 +375,7 @@ namespace boost {
// Property Graph: vertex_index property
// --------------------------------------------------------------------------
template<typename Graph, typename GlobalIndexMap>
class property_map<vertex_index_t,
class property_map<vertex_index_t,
graph::vertex_list_adaptor<Graph, GlobalIndexMap> >
{
public:
@@ -384,7 +384,7 @@ public:
};
template<typename Graph, typename GlobalIndexMap>
class property_map<vertex_index_t,
class property_map<vertex_index_t,
const graph::vertex_list_adaptor<Graph, GlobalIndexMap> >
{
public:

View File

@@ -13,7 +13,7 @@
#include <boost/assert.hpp>
#include <iterator>
#include <utility>
#include <boost/shared_ptr.hpp>
#include <boost/std::shared_ptr.hpp>
#include <boost/random/uniform_int.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/random/geometric_distribution.hpp>
@@ -31,7 +31,7 @@ namespace boost {
std::pair<typename graph_traits<Graph>::vertices_size_type,
typename graph_traits<Graph>::vertices_size_type>,
std::input_iterator_tag,
const
const
std::pair<typename graph_traits<Graph>::vertices_size_type,
typename graph_traits<Graph>::vertices_size_type>&>
{
@@ -97,7 +97,7 @@ namespace boost {
std::pair<typename graph_traits<Graph>::vertices_size_type,
typename graph_traits<Graph>::vertices_size_type>,
std::input_iterator_tag,
const
const
std::pair<typename graph_traits<Graph>::vertices_size_type,
typename graph_traits<Graph>::vertices_size_type>&>
{
@@ -181,7 +181,7 @@ namespace boost {
if (src == n) src = (std::numeric_limits<vertices_size_type>::max)();
}
shared_ptr<uniform_01<RandomGenerator*> > gen;
std::shared_ptr<uniform_01<RandomGenerator*> > gen;
geometric_distribution<vertices_size_type> rand_vertex;
vertices_size_type n;
bool allow_self_loops;

View File

@@ -26,13 +26,13 @@
#include <boost/graph/properties.hpp>
#include <boost/random/uniform_01.hpp>
#include <boost/random/linear_congruential.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/std::shared_ptr.hpp>
#include <boost/graph/breadth_first_search.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/named_function_params.hpp>
#include <boost/graph/topology.hpp>
namespace boost {
namespace boost {
namespace detail {
@@ -62,12 +62,12 @@ struct update_position_visitor {
double distance_limit,
double learning_constant,
double falloff_ratio):
position_map(position_map), node_distance(node_distance),
position_map(position_map), node_distance(node_distance),
space(space),
input_vector(input_vector), distance_limit(distance_limit),
learning_constant(learning_constant), falloff_ratio(falloff_ratio) {}
void operator()(vertex_descriptor v, const Graph&) const
void operator()(vertex_descriptor v, const Graph&) const
{
#ifndef BOOST_NO_STDC_NAMESPACE
using std::pow;
@@ -77,7 +77,7 @@ struct update_position_visitor {
BOOST_THROW_EXCEPTION(over_distance_limit());
Point old_position = get(position_map, v);
double distance = get(node_distance, v);
double fraction =
double fraction =
learning_constant * pow(falloff_ratio, distance * distance);
put(position_map, v,
space.move_position_toward(old_position, fraction, input_vector));
@@ -88,7 +88,7 @@ template<typename EdgeWeightMap>
struct gursoy_shortest
{
template<typename Graph, typename NodeDistanceMap, typename UpdatePosition>
static inline void
static inline void
run(const Graph& g, typename graph_traits<Graph>::vertex_descriptor s,
NodeDistanceMap node_distance, UpdatePosition& update_position,
EdgeWeightMap weight)
@@ -104,7 +104,7 @@ template<>
struct gursoy_shortest<dummy_property_map>
{
template<typename Graph, typename NodeDistanceMap, typename UpdatePosition>
static inline void
static inline void
run(const Graph& g, typename graph_traits<Graph>::vertex_descriptor s,
NodeDistanceMap node_distance, UpdatePosition& update_position,
dummy_property_map)
@@ -119,11 +119,11 @@ struct gursoy_shortest<dummy_property_map>
} // namespace detail
template <typename VertexListAndIncidenceGraph, typename Topology,
typename PositionMap, typename Diameter, typename VertexIndexMap,
typename PositionMap, typename Diameter, typename VertexIndexMap,
typename EdgeWeightMap>
void
void
gursoy_atun_step
(const VertexListAndIncidenceGraph& graph,
(const VertexListAndIncidenceGraph& graph,
const Topology& space,
PositionMap position,
Diameter diameter,
@@ -143,21 +143,21 @@ gursoy_atun_step
typedef typename Topology::point_type point_type;
vertex_iterator i, iend;
std::vector<double> distance_from_input_vector(num_vertices(graph));
typedef boost::iterator_property_map<std::vector<double>::iterator,
typedef boost::iterator_property_map<std::vector<double>::iterator,
VertexIndexMap,
double, double&>
DistanceFromInputMap;
DistanceFromInputMap distance_from_input(distance_from_input_vector.begin(),
vertex_index_map);
std::vector<double> node_distance_map_vector(num_vertices(graph));
typedef boost::iterator_property_map<std::vector<double>::iterator,
typedef boost::iterator_property_map<std::vector<double>::iterator,
VertexIndexMap,
double, double&>
NodeDistanceMap;
NodeDistanceMap node_distance(node_distance_map_vector.begin(),
vertex_index_map);
point_type input_vector = space.random_point();
vertex_descriptor min_distance_loc
vertex_descriptor min_distance_loc
= graph_traits<VertexListAndIncidenceGraph>::null_vertex();
double min_distance = 0.0;
bool min_distance_unset = true;
@@ -173,24 +173,24 @@ gursoy_atun_step
BOOST_ASSERT (!min_distance_unset); // Graph must have at least one vertex
boost::detail::update_position_visitor<
PositionMap, NodeDistanceMap, Topology,
VertexListAndIncidenceGraph>
VertexListAndIncidenceGraph>
update_position(position, node_distance, space,
input_vector, diameter, learning_constant,
input_vector, diameter, learning_constant,
exp(-1. / (2 * diameter * diameter)));
std::fill(node_distance_map_vector.begin(), node_distance_map_vector.end(), 0);
try {
typedef detail::gursoy_shortest<EdgeWeightMap> shortest;
shortest::run(graph, min_distance_loc, node_distance, update_position,
weight);
} catch (detail::over_distance_limit) {
/* Thrown to break out of BFS or Dijkstra early */
weight);
} catch (detail::over_distance_limit) {
/* Thrown to break out of BFS or Dijkstra early */
}
}
template <typename VertexListAndIncidenceGraph, typename Topology,
typename PositionMap, typename VertexIndexMap,
typename PositionMap, typename VertexIndexMap,
typename EdgeWeightMap>
void gursoy_atun_refine(const VertexListAndIncidenceGraph& graph,
void gursoy_atun_refine(const VertexListAndIncidenceGraph& graph,
const Topology& space,
PositionMap position,
int nsteps,
@@ -199,7 +199,7 @@ void gursoy_atun_refine(const VertexListAndIncidenceGraph& graph,
double learning_constant_initial,
double learning_constant_final,
VertexIndexMap vertex_index_map,
EdgeWeightMap weight)
EdgeWeightMap weight)
{
#ifndef BOOST_NO_STDC_NAMESPACE
using std::pow;
@@ -213,17 +213,17 @@ void gursoy_atun_refine(const VertexListAndIncidenceGraph& graph,
typedef typename Topology::point_type point_type;
vertex_iterator i, iend;
double diameter_ratio = (double)diameter_final / diameter_initial;
double learning_constant_ratio =
double learning_constant_ratio =
learning_constant_final / learning_constant_initial;
std::vector<double> distance_from_input_vector(num_vertices(graph));
typedef boost::iterator_property_map<std::vector<double>::iterator,
typedef boost::iterator_property_map<std::vector<double>::iterator,
VertexIndexMap,
double, double&>
DistanceFromInputMap;
DistanceFromInputMap distance_from_input(distance_from_input_vector.begin(),
vertex_index_map);
std::vector<int> node_distance_map_vector(num_vertices(graph));
typedef boost::iterator_property_map<std::vector<int>::iterator,
typedef boost::iterator_property_map<std::vector<int>::iterator,
VertexIndexMap, double, double&>
NodeDistanceMap;
NodeDistanceMap node_distance(node_distance_map_vector.begin(),
@@ -231,17 +231,17 @@ void gursoy_atun_refine(const VertexListAndIncidenceGraph& graph,
for (int round = 0; round < nsteps; ++round) {
double part_done = (double)round / (nsteps - 1);
int diameter = (int)(diameter_initial * pow(diameter_ratio, part_done));
double learning_constant =
double learning_constant =
learning_constant_initial * pow(learning_constant_ratio, part_done);
gursoy_atun_step(graph, space, position, diameter, learning_constant,
gursoy_atun_step(graph, space, position, diameter, learning_constant,
vertex_index_map, weight);
}
}
template <typename VertexListAndIncidenceGraph, typename Topology,
typename PositionMap, typename VertexIndexMap,
typename PositionMap, typename VertexIndexMap,
typename EdgeWeightMap>
void gursoy_atun_layout(const VertexListAndIncidenceGraph& graph,
void gursoy_atun_layout(const VertexListAndIncidenceGraph& graph,
const Topology& space,
PositionMap position,
int nsteps,
@@ -260,14 +260,14 @@ void gursoy_atun_layout(const VertexListAndIncidenceGraph& graph,
}
gursoy_atun_refine(graph, space,
position, nsteps,
diameter_initial, diameter_final,
diameter_initial, diameter_final,
learning_constant_initial, learning_constant_final,
vertex_index_map, weight);
}
template <typename VertexListAndIncidenceGraph, typename Topology,
typename PositionMap, typename VertexIndexMap>
void gursoy_atun_layout(const VertexListAndIncidenceGraph& graph,
void gursoy_atun_layout(const VertexListAndIncidenceGraph& graph,
const Topology& space,
PositionMap position,
int nsteps,
@@ -277,15 +277,15 @@ void gursoy_atun_layout(const VertexListAndIncidenceGraph& graph,
double learning_constant_final,
VertexIndexMap vertex_index_map)
{
gursoy_atun_layout(graph, space, position, nsteps,
diameter_initial, diameter_final,
learning_constant_initial, learning_constant_final,
gursoy_atun_layout(graph, space, position, nsteps,
diameter_initial, diameter_final,
learning_constant_initial, learning_constant_final,
vertex_index_map, dummy_property_map());
}
template <typename VertexListAndIncidenceGraph, typename Topology,
typename PositionMap>
void gursoy_atun_layout(const VertexListAndIncidenceGraph& graph,
void gursoy_atun_layout(const VertexListAndIncidenceGraph& graph,
const Topology& space,
PositionMap position,
int nsteps,
@@ -293,15 +293,15 @@ void gursoy_atun_layout(const VertexListAndIncidenceGraph& graph,
double diameter_final = 1.0,
double learning_constant_initial = 0.8,
double learning_constant_final = 0.2)
{
{
gursoy_atun_layout(graph, space, position, nsteps, diameter_initial,
diameter_final, learning_constant_initial,
learning_constant_final, get(vertex_index, graph));
learning_constant_final, get(vertex_index, graph));
}
template <typename VertexListAndIncidenceGraph, typename Topology,
typename PositionMap>
void gursoy_atun_layout(const VertexListAndIncidenceGraph& graph,
void gursoy_atun_layout(const VertexListAndIncidenceGraph& graph,
const Topology& space,
PositionMap position,
int nsteps)
@@ -310,13 +310,13 @@ void gursoy_atun_layout(const VertexListAndIncidenceGraph& graph,
using std::sqrt;
#endif
gursoy_atun_layout(graph, space, position, nsteps,
gursoy_atun_layout(graph, space, position, nsteps,
sqrt((double)num_vertices(graph)));
}
template <typename VertexListAndIncidenceGraph, typename Topology,
typename PositionMap>
void gursoy_atun_layout(const VertexListAndIncidenceGraph& graph,
void gursoy_atun_layout(const VertexListAndIncidenceGraph& graph,
const Topology& space,
PositionMap position)
{
@@ -325,8 +325,8 @@ void gursoy_atun_layout(const VertexListAndIncidenceGraph& graph,
template<typename VertexListAndIncidenceGraph, typename Topology,
typename PositionMap, typename P, typename T, typename R>
void
gursoy_atun_layout(const VertexListAndIncidenceGraph& graph,
void
gursoy_atun_layout(const VertexListAndIncidenceGraph& graph,
const Topology& space,
PositionMap position,
const bgl_named_params<P,T,R>& params)
@@ -340,17 +340,17 @@ gursoy_atun_layout(const VertexListAndIncidenceGraph& graph,
gursoy_atun_layout(graph, space, position,
choose_param(get_param(params, iterations_t()),
num_vertices(graph)),
choose_param(get_param(params, diameter_range_t()),
choose_param(get_param(params, diameter_range_t()),
diam).first,
choose_param(get_param(params, diameter_range_t()),
choose_param(get_param(params, diameter_range_t()),
diam).second,
choose_param(get_param(params, learning_constant_range_t()),
choose_param(get_param(params, learning_constant_range_t()),
learn).first,
choose_param(get_param(params, learning_constant_range_t()),
choose_param(get_param(params, learning_constant_range_t()),
learn).second,
choose_const_pmap(get_param(params, vertex_index), graph,
vertex_index),
choose_param(get_param(params, edge_weight),
choose_param(get_param(params, edge_weight),
dummy_property_map()));
}

View File

@@ -46,11 +46,11 @@ namespace boost {
// Algorithms", and the application to connected components is
// similar to the algorithm described in Ch. 22 of "Intro to
// Algorithms" by Cormen, et. all.
//
//
// An implementation of disjoint sets can be found in
// boost/pending/disjoint_sets.hpp
template <class EdgeListGraph, class DisjointSets>
void incremental_components(EdgeListGraph& g, DisjointSets& ds)
{
@@ -58,35 +58,35 @@ namespace boost {
for (boost::tie(e,end) = edges(g); e != end; ++e)
ds.union_set(source(*e,g),target(*e,g));
}
template <class ParentIterator>
void compress_components(ParentIterator first, ParentIterator last)
{
for (ParentIterator current = first; current != last; ++current)
for (ParentIterator current = first; current != last; ++current)
detail::find_representative_with_full_compression(first, current-first);
}
template <class ParentIterator>
typename boost::detail::iterator_traits<ParentIterator>::difference_type
component_count(ParentIterator first, ParentIterator last)
{
std::ptrdiff_t count = 0;
for (ParentIterator current = first; current != last; ++current)
if (*current == current - first) ++count;
for (ParentIterator current = first; current != last; ++current)
if (*current == current - first) ++count;
return count;
}
// This algorithm can be applied to the result container of the
// connected_components algorithm to normalize
// the components.
template <class ParentIterator>
void normalize_components(ParentIterator first, ParentIterator last)
{
for (ParentIterator current = first; current != last; ++current)
for (ParentIterator current = first; current != last; ++current)
detail::normalize_node(first, current - first);
}
template <class VertexListGraph, class DisjointSets>
template <class VertexListGraph, class DisjointSets>
void initialize_incremental_components(VertexListGraph& G, DisjointSets& ds)
{
typename graph_traits<VertexListGraph>
@@ -129,7 +129,7 @@ namespace boost {
m_index_list(make_shared<IndexContainer>(m_num_elements)) {
build_index_lists(parent_start, index_map);
} // component_index
template <typename ParentIterator>
@@ -222,10 +222,10 @@ namespace boost {
protected:
IndexType m_num_elements;
shared_ptr<IndexContainer> m_components, m_index_list;
std::shared_ptr<IndexContainer> m_components, m_index_list;
}; // class component_index
} // namespace boost
#endif // BOOST_INCREMENTAL_COMPONENTS_HPP

View File

@@ -35,13 +35,13 @@ namespace boost {
struct mcgregor_common_subgraph_traits {
typedef typename graph_traits<GraphFirst>::vertex_descriptor vertex_first_type;
typedef typename graph_traits<GraphSecond>::vertex_descriptor vertex_second_type;
typedef shared_array_property_map<vertex_second_type, VertexIndexMapFirst>
correspondence_map_first_to_second_type;
typedef shared_array_property_map<vertex_first_type, VertexIndexMapSecond>
correspondence_map_second_to_first_type;
};
};
} // namespace detail
@@ -52,7 +52,7 @@ namespace boost {
template <typename PropertyMapFirst,
typename PropertyMapSecond>
struct property_map_equivalent {
property_map_equivalent(const PropertyMapFirst property_map1,
const PropertyMapSecond property_map2) :
m_property_map1(property_map1),
@@ -63,7 +63,7 @@ namespace boost {
bool operator()(const ItemFirst item1, const ItemSecond item2) {
return (get(m_property_map1, item1) == get(m_property_map2, item2));
}
private:
const PropertyMapFirst m_property_map1;
const PropertyMapSecond m_property_map2;
@@ -86,7 +86,7 @@ namespace boost {
// Binary function object that always returns true. Used when
// vertices or edges are always equivalent (i.e. have no labels).
struct always_equivalent {
template <typename ItemFirst,
typename ItemSecond>
bool operator()(const ItemFirst&, const ItemSecond&) {
@@ -123,7 +123,7 @@ namespace boost {
{
typedef typename graph_traits<GraphFirst>::vertex_descriptor VertexFirst;
typedef typename graph_traits<GraphSecond>::vertex_descriptor VertexSecond;
typedef typename graph_traits<GraphFirst>::edge_descriptor EdgeFirst;
typedef typename graph_traits<GraphSecond>::edge_descriptor EdgeSecond;
@@ -153,7 +153,7 @@ namespace boost {
// first matching edge is always chosen.
EdgeFirst edge_to_new1, edge_from_new1;
bool edge_to_new_exists1 = false, edge_from_new_exists1 = false;
EdgeSecond edge_to_new2, edge_from_new2;
bool edge_to_new_exists2 = false, edge_from_new_exists2 = false;
@@ -179,7 +179,7 @@ namespace boost {
if ((edge_to_new_exists1 != edge_to_new_exists2) ||
((edge_to_new_exists1 && edge_to_new_exists2) &&
!edges_equivalent(edge_to_new1, edge_to_new2))) {
return (false);
}
@@ -225,7 +225,7 @@ namespace boost {
if ((edge_from_new_exists1 != edge_from_new_exists2) ||
((edge_from_new_exists1 && edge_from_new_exists2) &&
!edges_equivalent(edge_from_new1, edge_from_new2))) {
return (false);
}
@@ -244,7 +244,7 @@ namespace boost {
}
return (true);
}
}
// Recursive method that does a depth-first search in the space of
// potential subgraphs. At each level, every new vertex pair from
@@ -284,14 +284,14 @@ namespace boost {
// Get iterators for vertices from both graphs
typename graph_traits<GraphFirst>::vertex_iterator
vertex1_iter, vertex1_end;
typename graph_traits<GraphSecond>::vertex_iterator
vertex2_begin, vertex2_end, vertex2_iter;
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
BGL_FORALL_VERTICES_T(new_vertex1, graph1, GraphFirst) {
@@ -301,7 +301,7 @@ namespace boost {
if (existing_vertex2 != graph_traits<GraphSecond>::null_vertex()) {
continue;
}
BGL_FORALL_VERTICES_T(new_vertex2, graph2, GraphSecond) {
VertexFirst existing_vertex1 = get(correspondence_map_2_to_1, new_vertex2);
@@ -330,7 +330,7 @@ namespace boost {
// Only output sub-graphs larger than a single vertex
if (new_graph_size > 1) {
// Returning false from the callback will cancel iteration
if (!subgraph_callback(correspondence_map_1_to_2,
correspondence_map_2_to_1,
@@ -338,7 +338,7 @@ namespace boost {
return (false);
}
}
// Depth-first search into the state space of possible sub-graphs
bool continue_iteration =
mcgregor_common_subgraphs_internal
@@ -352,10 +352,10 @@ namespace boost {
if (!continue_iteration) {
return (false);
}
// Restore previous state
if (vertex_stack1.size() > old_graph_size) {
VertexFirst stack_vertex1 = vertex_stack1.top();
VertexSecond stack_vertex2 = get(correspondence_map_1_to_2,
stack_vertex1);
@@ -363,10 +363,10 @@ namespace boost {
// Contract subgraph
put(correspondence_map_1_to_2, stack_vertex1,
graph_traits<GraphSecond>::null_vertex());
put(correspondence_map_2_to_1, stack_vertex2,
graph_traits<GraphFirst>::null_vertex());
vertex_stack1.pop();
}
@@ -401,7 +401,7 @@ namespace boost {
typedef mcgregor_common_subgraph_traits<GraphFirst,
GraphSecond, VertexIndexMapFirst,
VertexIndexMapSecond> SubGraphTraits;
typename SubGraphTraits::correspondence_map_first_to_second_type
correspondence_map_1_to_2(num_vertices(graph1), vindex_map1);
@@ -409,7 +409,7 @@ namespace boost {
put(correspondence_map_1_to_2, vertex1,
graph_traits<GraphSecond>::null_vertex());
}
typename SubGraphTraits::correspondence_map_second_to_first_type
correspondence_map_2_to_1(num_vertices(graph2), vindex_map2);
@@ -420,7 +420,7 @@ namespace boost {
typedef typename graph_traits<GraphFirst>::vertex_descriptor
VertexFirst;
std::stack<VertexFirst> vertex_stack1;
mcgregor_common_subgraphs_internal
@@ -432,7 +432,7 @@ namespace boost {
only_connected_subgraphs,
subgraph_callback);
}
} // namespace detail
// ==========================================================================
@@ -457,7 +457,7 @@ namespace boost {
bool only_connected_subgraphs,
SubGraphCallback user_callback)
{
detail::mcgregor_common_subgraphs_internal_init
(graph1, graph2,
vindex_map1, vindex_map2,
@@ -465,7 +465,7 @@ namespace boost {
only_connected_subgraphs,
user_callback);
}
// Variant of mcgregor_common_subgraphs with all default parameters
template <typename GraphFirst,
typename GraphSecond,
@@ -476,7 +476,7 @@ namespace boost {
bool only_connected_subgraphs,
SubGraphCallback user_callback)
{
detail::mcgregor_common_subgraphs_internal_init
(graph1, graph2,
get(vertex_index, graph1), get(vertex_index, graph2),
@@ -498,7 +498,7 @@ namespace boost {
SubGraphCallback user_callback,
const bgl_named_params<Param, Tag, Rest>& params)
{
detail::mcgregor_common_subgraphs_internal_init
(graph1, graph2,
choose_const_pmap(get_param(params, vertex_index1),
@@ -532,7 +532,7 @@ namespace boost {
typedef mcgregor_common_subgraph_traits<GraphFirst, GraphSecond,
VertexIndexMapFirst, VertexIndexMapSecond> SubGraphTraits;
typedef typename SubGraphTraits::correspondence_map_first_to_second_type
CachedCorrespondenceMapFirstToSecond;
@@ -542,19 +542,19 @@ namespace boost {
typedef std::pair<VertexSizeFirst,
std::pair<CachedCorrespondenceMapFirstToSecond,
CachedCorrespondenceMapSecondToFirst> > SubGraph;
typedef std::vector<SubGraph> SubGraphList;
unique_subgraph_interceptor(const GraphFirst& graph1,
const GraphSecond& graph2,
const VertexIndexMapFirst vindex_map1,
const VertexIndexMapSecond vindex_map2,
SubGraphCallback user_callback) :
SubGraphCallback user_callback) :
m_graph1(graph1), m_graph2(graph2),
m_vindex_map1(vindex_map1), m_vindex_map2(vindex_map2),
m_subgraphs(make_shared<SubGraphList>()),
m_user_callback(user_callback) { }
template <typename CorrespondenceMapFirstToSecond,
typename CorrespondenceMapSecondToFirst>
bool operator()(CorrespondenceMapFirstToSecond correspondence_map_1_to_2,
@@ -572,16 +572,16 @@ namespace boost {
if (subgraph_size != subgraph_cached.first) {
continue;
}
if (!are_property_maps_different(correspondence_map_1_to_2,
subgraph_cached.second.first,
m_graph1)) {
// New subgraph is a duplicate
return (true);
}
}
// Subgraph is unique, so make a cached copy
CachedCorrespondenceMapFirstToSecond
new_subgraph_1_to_2 = CachedCorrespondenceMapFirstToSecond
@@ -602,21 +602,21 @@ namespace boost {
m_subgraphs->push_back(std::make_pair(subgraph_size,
std::make_pair(new_subgraph_1_to_2,
new_subgraph_2_to_1)));
return (m_user_callback(correspondence_map_1_to_2,
correspondence_map_2_to_1,
subgraph_size));
}
private:
const GraphFirst& m_graph1;
const GraphFirst& m_graph2;
const VertexIndexMapFirst m_vindex_map1;
const VertexIndexMapSecond m_vindex_map2;
shared_ptr<SubGraphList> m_subgraphs;
std::shared_ptr<SubGraphList> m_subgraphs;
SubGraphCallback m_user_callback;
};
} // namespace detail
// Enumerates all unique common subgraphs between graph1 and graph2.
@@ -645,7 +645,7 @@ namespace boost {
(graph1, graph2,
vindex_map1, vindex_map2,
user_callback);
detail::mcgregor_common_subgraphs_internal_init
(graph1, graph2,
vindex_map1, vindex_map2,
@@ -717,7 +717,7 @@ namespace boost {
typedef mcgregor_common_subgraph_traits<GraphFirst, GraphSecond,
VertexIndexMapFirst, VertexIndexMapSecond> SubGraphTraits;
typedef typename SubGraphTraits::correspondence_map_first_to_second_type
CachedCorrespondenceMapFirstToSecond;
@@ -753,7 +753,7 @@ namespace boost {
}
if (subgraph_size == *m_largest_size_so_far) {
// Make a cached copy
CachedCorrespondenceMapFirstToSecond
new_subgraph_1_to_2 = CachedCorrespondenceMapFirstToSecond
@@ -797,11 +797,11 @@ namespace boost {
const GraphFirst& m_graph2;
const VertexIndexMapFirst m_vindex_map1;
const VertexIndexMapSecond m_vindex_map2;
shared_ptr<SubGraphList> m_subgraphs;
shared_ptr<VertexSizeFirst> m_largest_size_so_far;
std::shared_ptr<SubGraphList> m_subgraphs;
std::shared_ptr<VertexSizeFirst> m_largest_size_so_far;
SubGraphCallback m_user_callback;
};
} // namespace detail
// Enumerates the largest common subgraphs found between graph1
@@ -828,7 +828,7 @@ namespace boost {
VertexIndexMapFirst, VertexIndexMapSecond, SubGraphCallback>
max_interceptor
(graph1, graph2, vindex_map1, vindex_map2, user_callback);
detail::mcgregor_common_subgraphs_internal_init
(graph1, graph2,
vindex_map1, vindex_map2,
@@ -903,7 +903,7 @@ namespace boost {
typedef mcgregor_common_subgraph_traits<GraphFirst, GraphSecond,
VertexIndexMapFirst, VertexIndexMapSecond> SubGraphTraits;
typedef typename SubGraphTraits::correspondence_map_first_to_second_type
CachedCorrespondenceMapFirstToSecond;
@@ -920,13 +920,13 @@ namespace boost {
const GraphSecond& graph2,
const VertexIndexMapFirst vindex_map1,
const VertexIndexMapSecond vindex_map2,
SubGraphCallback user_callback) :
SubGraphCallback user_callback) :
m_graph1(graph1), m_graph2(graph2),
m_vindex_map1(vindex_map1), m_vindex_map2(vindex_map2),
m_subgraphs(make_shared<SubGraphList>()),
m_largest_size_so_far(make_shared<VertexSizeFirst>(0)),
m_user_callback(user_callback) { }
m_user_callback(user_callback) { }
template <typename CorrespondenceMapFirstToSecond,
typename CorrespondenceMapSecondToFirst>
bool operator()(CorrespondenceMapFirstToSecond correspondence_map_1_to_2,
@@ -945,18 +945,18 @@ namespace boost {
subgraph_iter = m_subgraphs->begin();
subgraph_iter != m_subgraphs->end();
++subgraph_iter) {
SubGraph subgraph_cached = *subgraph_iter;
if (!are_property_maps_different(correspondence_map_1_to_2,
subgraph_cached.second.first,
m_graph1)) {
// New subgraph is a duplicate
return (true);
}
}
// Subgraph is unique, so make a cached copy
CachedCorrespondenceMapFirstToSecond
new_subgraph_1_to_2 = CachedCorrespondenceMapFirstToSecond
@@ -978,7 +978,7 @@ namespace boost {
std::make_pair(new_subgraph_1_to_2,
new_subgraph_2_to_1)));
}
return (true);
}
@@ -994,17 +994,17 @@ namespace boost {
subgraph_cached.first);
}
}
private:
const GraphFirst& m_graph1;
const GraphFirst& m_graph2;
const VertexIndexMapFirst m_vindex_map1;
const VertexIndexMapSecond m_vindex_map2;
shared_ptr<SubGraphList> m_subgraphs;
shared_ptr<VertexSizeFirst> m_largest_size_so_far;
std::shared_ptr<SubGraphList> m_subgraphs;
std::shared_ptr<VertexSizeFirst> m_largest_size_so_far;
SubGraphCallback m_user_callback;
};
} // namespace detail
// Enumerates the largest, unique common subgraphs found between
@@ -1031,7 +1031,7 @@ namespace boost {
VertexIndexMapFirst, VertexIndexMapSecond, SubGraphCallback>
unique_max_interceptor
(graph1, graph2, vindex_map1, vindex_map2, user_callback);
detail::mcgregor_common_subgraphs_internal_init
(graph1, graph2,
vindex_map1, vindex_map2,
@@ -1122,7 +1122,7 @@ namespace boost {
// Returns a filtered sub-graph of graph whose edge and vertex
// inclusion is dictated by membership_map.
template <typename Graph,
typename MembershipMap>
typename MembershipMap>
typename membership_filtered_graph_traits<Graph, MembershipMap>::graph_type
make_membership_filtered_graph
(const Graph& graph,
@@ -1134,9 +1134,9 @@ namespace boost {
typename MFGTraits::vertex_filter_type v_filter(membership_map);
return (MembershipFilteredGraph(graph, keep_all(), v_filter));
}
} // namespace boost
#endif // BOOST_GRAPH_MCGREGOR_COMMON_SUBGRAPHS_HPP

View File

@@ -28,7 +28,7 @@
#include <vector>
#include <boost/shared_ptr.hpp>
#include <boost/std::shared_ptr.hpp>
#include <boost/concept_check.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/graph_as_tree.hpp>

View File

@@ -21,7 +21,7 @@
#include <boost/assert.hpp>
#include <boost/iterator/counting_iterator.hpp>
#include <boost/random/uniform_int.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/std::shared_ptr.hpp>
#include <typeinfo>
namespace boost { namespace parallel {
@@ -86,13 +86,13 @@ public:
size_type block_size(process_id_type id, size_type n) const
{ return distribution_->block_size(id, n); }
process_id_type operator()(size_type i) const
{ return distribution_->in_process(i); }
size_type local(size_type i) const
{ return distribution_->local(i); }
size_type global(size_type n) const
{ return distribution_->global(n); }
@@ -122,13 +122,13 @@ public:
}
private:
shared_ptr<basic_distribution> distribution_;
std::shared_ptr<basic_distribution> distribution_;
};
struct block
{
template<typename LinearProcessGroup>
explicit block(const LinearProcessGroup& pg, std::size_t n)
explicit block(const LinearProcessGroup& pg, std::size_t n)
: id(process_id(pg)), p(num_processes(pg)), n(n) { }
// If there are n elements in the distributed data structure, returns the number of elements stored locally.
@@ -144,7 +144,7 @@ struct block
// Returns the processor on which element with global index i is stored
template<typename SizeType>
SizeType operator()(SizeType i) const
{
{
SizeType cutoff_processor = n % p;
SizeType cutoff = cutoff_processor * (n / p + 1);
@@ -165,7 +165,7 @@ struct block
// Find the local index for the ith global element
template<typename SizeType>
SizeType local(SizeType i) const
{
{
SizeType owner = (*this)(i);
return i - start(owner);
}
@@ -192,9 +192,9 @@ struct uneven_block
typedef std::vector<std::size_t> size_vector;
template<typename LinearProcessGroup>
explicit uneven_block(const LinearProcessGroup& pg, const std::vector<std::size_t>& local_sizes)
explicit uneven_block(const LinearProcessGroup& pg, const std::vector<std::size_t>& local_sizes)
: id(process_id(pg)), p(num_processes(pg)), local_sizes(local_sizes)
{
{
BOOST_ASSERT(local_sizes.size() == p);
local_starts.resize(p + 1);
local_starts[0] = 0;
@@ -204,7 +204,7 @@ struct uneven_block
// To do maybe: enter local size in each process and gather in constructor (much handier)
// template<typename LinearProcessGroup>
// explicit uneven_block(const LinearProcessGroup& pg, std::size_t my_local_size)
// explicit uneven_block(const LinearProcessGroup& pg, std::size_t my_local_size)
// If there are n elements in the distributed data structure, returns the number of elements stored locally.
template<typename SizeType>
@@ -227,7 +227,7 @@ struct uneven_block
// Find the starting index for processor with the given id
template<typename ID>
std::size_t start(ID id) const
std::size_t start(ID id) const
{
return local_starts[id];
}
@@ -235,7 +235,7 @@ struct uneven_block
// Find the local index for the ith global element
template<typename SizeType>
SizeType local(SizeType i) const
{
{
SizeType owner = (*this)(i);
return i - start(owner);
}
@@ -264,10 +264,10 @@ struct oned_block_cyclic
template<typename LinearProcessGroup>
explicit oned_block_cyclic(const LinearProcessGroup& pg, std::size_t size)
: id(process_id(pg)), p(num_processes(pg)), size(size) { }
template<typename SizeType>
SizeType block_size(SizeType n) const
{
{
return block_size(id, n);
}
@@ -279,20 +279,20 @@ struct oned_block_cyclic
SizeType everyone_gets = all_blocks / p;
SizeType extra_blocks = all_blocks % p;
SizeType my_blocks = everyone_gets + (p < extra_blocks? 1 : 0);
SizeType my_elements = my_blocks * size
SizeType my_elements = my_blocks * size
+ (p == extra_blocks? extra_elements : 0);
return my_elements;
}
template<typename SizeType>
SizeType operator()(SizeType i) const
{
{
return (i / size) % p;
}
template<typename SizeType>
SizeType local(SizeType i) const
{
{
return ((i / size) / p) * size + i % size;
}
@@ -302,7 +302,7 @@ struct oned_block_cyclic
template<typename ProcessID, typename SizeType>
SizeType global(ProcessID id, SizeType i) const
{
{
return ((i / size) * p + id) * size + i % size;
}
@@ -318,14 +318,14 @@ struct twod_block_cyclic
explicit twod_block_cyclic(const LinearProcessGroup& pg,
std::size_t block_rows, std::size_t block_columns,
std::size_t data_columns_per_row)
: id(process_id(pg)), p(num_processes(pg)),
block_rows(block_rows), block_columns(block_columns),
: id(process_id(pg)), p(num_processes(pg)),
block_rows(block_rows), block_columns(block_columns),
data_columns_per_row(data_columns_per_row)
{ }
template<typename SizeType>
SizeType block_size(SizeType n) const
{
{
return block_size(id, n);
}
@@ -346,7 +346,7 @@ struct twod_block_cyclic
template<typename SizeType>
SizeType operator()(SizeType i) const
{
{
SizeType result = get_block_num(i) % p;
// std::cerr << "Item " << i << " goes on processor " << result << std::endl;
return result;
@@ -354,7 +354,7 @@ struct twod_block_cyclic
template<typename SizeType>
SizeType local(SizeType i) const
{
{
// Compute the start of the block
std::size_t block_num = get_block_num(i);
// std::cerr << "Item " << i << " is in block #" << block_num << std::endl;
@@ -362,11 +362,11 @@ struct twod_block_cyclic
std::size_t local_block_num = block_num / p;
std::size_t block_start = local_block_num * block_rows * block_columns;
// Compute the offset into the block
// Compute the offset into the block
std::size_t data_row = i / data_columns_per_row;
std::size_t data_col = i % data_columns_per_row;
std::size_t block_offset = (data_row % block_rows) * block_columns
+ (data_col % block_columns);
std::size_t block_offset = (data_row % block_rows) * block_columns
+ (data_col % block_columns);
// std::cerr << "Item " << i << " maps to local index " << block_start+block_offset << std::endl;
return block_start + block_offset;
@@ -374,7 +374,7 @@ struct twod_block_cyclic
template<typename SizeType>
SizeType global(SizeType i) const
{
{
// Compute the (global) block in which this element resides
SizeType local_block_num = i / (block_rows * block_columns);
SizeType block_offset = i % (block_rows * block_columns);
@@ -401,7 +401,7 @@ struct twod_block_cyclic
+ row_in_block * block_rows + col_in_block;
std::cerr << "global(" << i << "@" << id << ") = " << result
std::cerr << "global(" << i << "@" << id << ") = " << result
<< " =? " << local(result) << std::endl;
BOOST_ASSERT(i == local(result));
return result;
@@ -444,7 +444,7 @@ class twod_random
private:
RandomNumberGen& gen;
};
public:
template<typename LinearProcessGroup, typename RandomNumberGen>
explicit twod_random(const LinearProcessGroup& pg,
@@ -452,11 +452,11 @@ class twod_random
std::size_t data_columns_per_row,
std::size_t n,
RandomNumberGen& gen)
: id(process_id(pg)), p(num_processes(pg)),
block_rows(block_rows), block_columns(block_columns),
: id(process_id(pg)), p(num_processes(pg)),
block_rows(block_rows), block_columns(block_columns),
data_columns_per_row(data_columns_per_row),
global_to_local(n / (block_rows * block_columns))
{
{
std::copy(make_counting_iterator(std::size_t(0)),
make_counting_iterator(global_to_local.size()),
global_to_local.begin());
@@ -464,10 +464,10 @@ class twod_random
random_int<RandomNumberGen> rand(gen);
std::random_shuffle(global_to_local.begin(), global_to_local.end(), rand);
}
template<typename SizeType>
SizeType block_size(SizeType n) const
{
{
return block_size(id, n);
}
@@ -488,7 +488,7 @@ class twod_random
template<typename SizeType>
SizeType operator()(SizeType i) const
{
{
SizeType result = get_block_num(i) % p;
// std::cerr << "Item " << i << " goes on processor " << result << std::endl;
return result;
@@ -496,7 +496,7 @@ class twod_random
template<typename SizeType>
SizeType local(SizeType i) const
{
{
// Compute the start of the block
std::size_t block_num = get_block_num(i);
// std::cerr << "Item " << i << " is in block #" << block_num << std::endl;
@@ -504,11 +504,11 @@ class twod_random
std::size_t local_block_num = block_num / p;
std::size_t block_start = local_block_num * block_rows * block_columns;
// Compute the offset into the block
// Compute the offset into the block
std::size_t data_row = i / data_columns_per_row;
std::size_t data_col = i % data_columns_per_row;
std::size_t block_offset = (data_row % block_rows) * block_columns
+ (data_col % block_columns);
std::size_t block_offset = (data_row % block_rows) * block_columns
+ (data_col % block_columns);
// std::cerr << "Item " << i << " maps to local index " << block_start+block_offset << std::endl;
return block_start + block_offset;
@@ -552,7 +552,7 @@ class random_distribution
private:
RandomNumberGen& gen;
};
public:
template<typename LinearProcessGroup, typename RandomNumberGen>
random_distribution(const LinearProcessGroup& pg, RandomNumberGen& gen,
@@ -565,7 +565,7 @@ class random_distribution
random_int<RandomNumberGen> rand(gen);
std::random_shuffle(local_to_global.begin(), local_to_global.end(), rand);
for (std::vector<std::size_t>::size_type i = 0; i < n; ++i)
global_to_local[local_to_global[i]] = i;
@@ -587,19 +587,19 @@ class random_distribution
template<typename SizeType>
SizeType local(SizeType i) const
{
{
return base.local(global_to_local[i]);
}
template<typename ProcessID, typename SizeType>
SizeType global(ProcessID p, SizeType i) const
{
{
return local_to_global[base.global(p, i)];
}
template<typename SizeType>
SizeType global(SizeType i) const
{
{
return local_to_global[base.global(i)];
}

View File

@@ -12,7 +12,7 @@
#include <list>
#include <boost/graph/graph_traits.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/std::shared_ptr.hpp>
// A "face handle" is an optimization meant to serve two purposes in
@@ -26,7 +26,7 @@
// sequence of edges. The functions first_vertex/second_vertex and
// first_edge/second_edge allow fast access to the beginning and end of the
// stored sequence, which allows one to traverse the outer face of the partial
// planar embedding as it's being created.
// planar embedding as it's being created.
//
// There are some policies below that define the contents of the face handles:
// in the case no embedding is needed (for example, if one just wants to use
@@ -48,7 +48,7 @@ namespace boost { namespace graph { namespace detail {
//face handle policies
//EmbeddingStorage policy
struct store_embedding {};
struct recursive_lazy_list : public store_embedding {};
@@ -65,14 +65,14 @@ namespace boost { namespace graph { namespace detail {
template<typename DataType>
struct lazy_list_node
{
typedef shared_ptr< lazy_list_node<DataType> > ptr_t;
typedef std::shared_ptr< lazy_list_node<DataType> > ptr_t;
lazy_list_node(const DataType& data) :
m_reversed(false),
m_data(data),
m_has_data(true)
{}
lazy_list_node(ptr_t left_child, ptr_t right_child) :
m_reversed(false),
m_has_data(false),
@@ -83,10 +83,10 @@ namespace boost { namespace graph { namespace detail {
bool m_reversed;
DataType m_data;
bool m_has_data;
shared_ptr<lazy_list_node> m_left_child;
shared_ptr<lazy_list_node> m_right_child;
std::shared_ptr<lazy_list_node> m_left_child;
std::shared_ptr<lazy_list_node> m_right_child;
};
template <typename StoreOldHandlesPolicy, typename Vertex, typename Edge>
@@ -139,7 +139,7 @@ namespace boost { namespace graph { namespace detail {
struct edge_list_storage<recursive_lazy_list, Edge>
{
typedef lazy_list_node<Edge> node_type;
typedef shared_ptr< node_type > type;
typedef std::shared_ptr< node_type > type;
type value;
void push_back(Edge e)
@@ -178,17 +178,17 @@ namespace boost { namespace graph { namespace detail {
private:
template <typename OutputIterator>
void get_list_helper(OutputIterator o_itr,
void get_list_helper(OutputIterator o_itr,
type root,
bool flipped = false
)
{
if (!root)
return;
if (root->m_has_data)
*o_itr = root->m_data;
if ((flipped && !root->m_reversed) ||
(!flipped && root->m_reversed)
)
@@ -201,9 +201,9 @@ namespace boost { namespace graph { namespace detail {
get_list_helper(o_itr, root->m_left_child, false);
get_list_helper(o_itr, root->m_right_child, false);
}
}
};
@@ -254,20 +254,20 @@ namespace boost { namespace graph { namespace detail {
template<typename Graph,
typename StoreOldHandlesPolicy,
typename StoreEmbeddingPolicy
template<typename Graph,
typename StoreOldHandlesPolicy,
typename StoreEmbeddingPolicy
>
struct face_handle_impl
{
typedef typename graph_traits<Graph>::vertex_descriptor vertex_t;
typedef typename graph_traits<Graph>::edge_descriptor edge_t;
typedef typename edge_list_storage<StoreEmbeddingPolicy, edge_t>::type
typedef typename edge_list_storage<StoreEmbeddingPolicy, edge_t>::type
edge_list_storage_t;
face_handle_impl() :
face_handle_impl() :
cached_first_vertex(graph_traits<Graph>::null_vertex()),
cached_second_vertex(graph_traits<Graph>::null_vertex()),
true_first_vertex(graph_traits<Graph>::null_vertex()),
@@ -308,11 +308,11 @@ namespace boost { namespace graph { namespace detail {
template <typename Graph,
typename StoreOldHandlesPolicy = store_old_handles,
template <typename Graph,
typename StoreOldHandlesPolicy = store_old_handles,
typename StoreEmbeddingPolicy = recursive_lazy_list
>
class face_handle
class face_handle
{
public:
typedef typename graph_traits<Graph>::vertex_descriptor vertex_t;
@@ -347,19 +347,19 @@ namespace boost { namespace graph { namespace detail {
}
//default copy construction, assignment okay.
void push_first(edge_t e, const Graph& g)
{
void push_first(edge_t e, const Graph& g)
{
pimpl->edge_list.push_front(e);
pimpl->cached_first_vertex = pimpl->true_first_vertex =
pimpl->cached_first_vertex = pimpl->true_first_vertex =
source(e, g) == pimpl->anchor ? target(e,g) : source(e,g);
pimpl->cached_first_edge = e;
}
void push_second(edge_t e, const Graph& g)
{
void push_second(edge_t e, const Graph& g)
{
pimpl->edge_list.push_back(e);
pimpl->cached_second_vertex = pimpl->true_second_vertex =
pimpl->cached_second_vertex = pimpl->true_second_vertex =
source(e, g) == pimpl->anchor ? target(e,g) : source(e,g);
pimpl->cached_second_edge = e;
}
@@ -370,22 +370,22 @@ namespace boost { namespace graph { namespace detail {
}
inline vertex_t first_vertex() const
{
{
return pimpl->cached_first_vertex;
}
inline vertex_t second_vertex() const
{
inline vertex_t second_vertex() const
{
return pimpl->cached_second_vertex;
}
inline vertex_t true_first_vertex() const
{
inline vertex_t true_first_vertex() const
{
return pimpl->true_first_vertex;
}
inline vertex_t true_second_vertex() const
{
inline vertex_t true_second_vertex() const
{
return pimpl->true_second_vertex;
}
@@ -413,17 +413,17 @@ namespace boost { namespace graph { namespace detail {
{
return pimpl->cached_first_edge;
}
inline edge_t second_edge() const
{
return pimpl->cached_second_edge;
}
inline vertex_t get_anchor() const
{
return pimpl->anchor;
}
void glue_first_to_second
(face_handle<Graph,StoreOldHandlesPolicy,StoreEmbeddingPolicy>& bottom)
{
@@ -432,7 +432,7 @@ namespace boost { namespace graph { namespace detail {
pimpl->cached_first_vertex = bottom.pimpl->cached_first_vertex;
pimpl->cached_first_edge = bottom.pimpl->cached_first_edge;
}
void glue_second_to_first
(face_handle<Graph,StoreOldHandlesPolicy,StoreEmbeddingPolicy>& bottom)
{
@@ -441,7 +441,7 @@ namespace boost { namespace graph { namespace detail {
pimpl->cached_second_vertex = bottom.pimpl->cached_second_vertex;
pimpl->cached_second_edge = bottom.pimpl->cached_second_edge;
}
void flip()
{
pimpl->edge_list.reverse();
@@ -449,7 +449,7 @@ namespace boost { namespace graph { namespace detail {
std::swap(pimpl->cached_first_vertex, pimpl->cached_second_vertex);
std::swap(pimpl->cached_first_edge, pimpl->cached_second_edge);
}
template <typename OutputIterator>
void get_list(OutputIterator o_itr)
{
@@ -481,12 +481,12 @@ namespace boost { namespace graph { namespace detail {
pimpl->old_handles.first_edge = pimpl->cached_first_edge;
pimpl->old_handles.second_edge = pimpl->cached_second_edge;
}
void store_old_face_handles_dispatch(no_old_handles) {}
boost::shared_ptr<impl_t> pimpl;
boost::std::shared_ptr<impl_t> pimpl;
};

View File

@@ -12,7 +12,7 @@
#include <iterator>
#include <utility>
#include <boost/random/uniform_int.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/std::shared_ptr.hpp>
#include <boost/graph/graph_traits.hpp>
#include <vector>
#include <map>
@@ -21,7 +21,7 @@
namespace boost {
template<typename RandomGenerator>
class out_directed_plod_iterator
class out_directed_plod_iterator
{
public:
typedef std::forward_iterator_tag iterator_category;
@@ -32,10 +32,10 @@ namespace boost {
out_directed_plod_iterator() : gen(0), at_end(true) { }
out_directed_plod_iterator(RandomGenerator& gen, std::size_t n,
double alpha, double beta,
out_directed_plod_iterator(RandomGenerator& gen, std::size_t n,
double alpha, double beta,
bool allow_self_loops)
: gen(&gen), n(n), alpha(alpha), beta(beta),
: gen(&gen), n(n), alpha(alpha), beta(beta),
allow_self_loops(allow_self_loops), at_end(false), degree(0),
current(0, 0)
{
@@ -50,7 +50,7 @@ namespace boost {
pointer operator->() const { return &current; }
out_directed_plod_iterator& operator++()
{
{
using std::pow;
uniform_int<std::size_t> x(0, n-1);
@@ -66,7 +66,7 @@ namespace boost {
}
std::size_t xv = x(*gen);
degree = (xv == 0? 0 : std::size_t(beta * pow(xv, -alpha)));
degree = (xv == 0? 0 : std::size_t(beta * pow(xv, -alpha)));
}
do {
@@ -85,16 +85,16 @@ namespace boost {
}
bool operator==(const out_directed_plod_iterator& other) const
{
return at_end == other.at_end;
{
return at_end == other.at_end;
}
bool operator!=(const out_directed_plod_iterator& other) const
{
return !(*this == other);
{
return !(*this == other);
}
private:
private:
RandomGenerator* gen;
std::size_t n;
double alpha;
@@ -106,7 +106,7 @@ namespace boost {
};
template<typename RandomGenerator>
class undirected_plod_iterator
class undirected_plod_iterator
{
typedef std::vector<std::pair<std::size_t, std::size_t> > out_degrees_t;
@@ -117,11 +117,11 @@ namespace boost {
typedef const value_type* pointer;
typedef std::ptrdiff_t difference_type;
undirected_plod_iterator()
undirected_plod_iterator()
: gen(0), out_degrees(), degrees_left(0), allow_self_loops(false) { }
undirected_plod_iterator(RandomGenerator& gen, std::size_t n,
double alpha, double beta,
undirected_plod_iterator(RandomGenerator& gen, std::size_t n,
double alpha, double beta,
bool allow_self_loops = false)
: gen(&gen), n(n), out_degrees(new out_degrees_t),
degrees_left(0), allow_self_loops(allow_self_loops)
@@ -145,7 +145,7 @@ namespace boost {
pointer operator->() const { return &current; }
undirected_plod_iterator& operator++()
{
{
next();
return *this;
}
@@ -158,8 +158,8 @@ namespace boost {
}
bool operator==(const undirected_plod_iterator& other) const
{
return degrees_left == other.degrees_left;
{
return degrees_left == other.degrees_left;
}
bool operator!=(const undirected_plod_iterator& other) const
@@ -192,7 +192,7 @@ namespace boost {
(*out_degrees)[source] = out_degrees->back();
out_degrees->pop_back();
continue;
}
}
// Select target vertex
target = x(*gen);
@@ -200,7 +200,7 @@ namespace boost {
(*out_degrees)[target] = out_degrees->back();
out_degrees->pop_back();
continue;
} else if (source != target
} else if (source != target
|| (allow_self_loops && (*out_degrees)[source].second > 2)) {
break;
}
@@ -217,7 +217,7 @@ namespace boost {
RandomGenerator* gen;
std::size_t n;
shared_ptr<out_degrees_t> out_degrees;
std::shared_ptr<out_degrees_t> out_degrees;
std::size_t degrees_left;
bool allow_self_loops;
value_type current;
@@ -243,7 +243,7 @@ namespace boost {
public:
plod_iterator() : inherited() { }
plod_iterator(RandomGenerator& gen, std::size_t n,
plod_iterator(RandomGenerator& gen, std::size_t n,
double alpha, double beta, bool allow_self_loops = false)
: inherited(gen, n, alpha, beta, allow_self_loops) { }
};

View File

@@ -15,7 +15,7 @@
#include <vector>
#include <queue>
#include <map>
#include <boost/shared_ptr.hpp>
#include <boost/std::shared_ptr.hpp>
#include <boost/assert.hpp>
#include <boost/random/uniform_int.hpp>
#include <boost/random/uniform_01.hpp>
@@ -24,7 +24,7 @@
#include <boost/type_traits/is_same.hpp>
#include <boost/test/floating_point_comparison.hpp>
using boost::shared_ptr;
using boost::std::shared_ptr;
using boost::uniform_01;
// Returns floor(log_2(n)), and -1 when n is 0
@@ -76,7 +76,7 @@ generate_permutation_vector(RandomGenerator& gen, std::vector<T>& vertexPermutat
template <typename RandomGenerator, typename T>
std::pair<T,T>
generate_edge(shared_ptr<uniform_01<RandomGenerator> > prob, T n,
generate_edge(std::shared_ptr<uniform_01<RandomGenerator> > prob, T n,
unsigned int SCALE, double a, double b, double c, double d)
{
T u = 0, v = 0;
@@ -213,7 +213,7 @@ namespace boost {
private:
// Parameters
shared_ptr<uniform_01<RandomGenerator> > gen;
std::shared_ptr<uniform_01<RandomGenerator> > gen;
vertices_size_type n;
double a, b, c, d;
int edge;
@@ -328,7 +328,7 @@ namespace boost {
private:
// Parameters
shared_ptr<uniform_01<RandomGenerator> > gen;
std::shared_ptr<uniform_01<RandomGenerator> > gen;
bool permute_vertices;
// Internal data structures
@@ -442,7 +442,7 @@ namespace boost {
private:
// Parameters
shared_ptr<uniform_01<RandomGenerator> > gen;
std::shared_ptr<uniform_01<RandomGenerator> > gen;
// Internal data structures
std::vector<value_type> values;
@@ -576,7 +576,7 @@ namespace boost {
private:
// Parameters
shared_ptr<uniform_01<RandomGenerator> > gen;
std::shared_ptr<uniform_01<RandomGenerator> > gen;
bool bidirectional;
// Internal data structures

View File

@@ -29,10 +29,10 @@ namespace boost {
* Topologies *
***********************************************************/
template<std::size_t Dims>
class convex_topology
class convex_topology
{
public: // For VisualAge C++
struct point
struct point
{
BOOST_STATIC_CONSTANT(std::size_t, dimensions = Dims);
point() { }
@@ -129,7 +129,7 @@ class convex_topology
typedef point point_type;
typedef point_difference point_difference_type;
double distance(point a, point b) const
double distance(point a, point b) const
{
double dist = 0.;
for (std::size_t i = 0; i < Dims; ++i) {
@@ -142,7 +142,7 @@ class convex_topology
return dist;
}
point move_position_toward(point a, double fraction, point b) const
point move_position_toward(point a, double fraction, point b) const
{
point result;
for (std::size_t i = 0; i < Dims; ++i)
@@ -206,15 +206,15 @@ class hypercube_topology : public convex_topology<Dims>
typedef typename convex_topology<Dims>::point_type point_type;
typedef typename convex_topology<Dims>::point_difference_type point_difference_type;
explicit hypercube_topology(double scaling = 1.0)
: gen_ptr(new RandomNumberGenerator), rand(new rand_t(*gen_ptr)),
scaling(scaling)
explicit hypercube_topology(double scaling = 1.0)
: gen_ptr(new RandomNumberGenerator), rand(new rand_t(*gen_ptr)),
scaling(scaling)
{ }
hypercube_topology(RandomNumberGenerator& gen, double scaling = 1.0)
hypercube_topology(RandomNumberGenerator& gen, double scaling = 1.0)
: gen_ptr(), rand(new rand_t(gen)), scaling(scaling) { }
point_type random_point() const
point_type random_point() const
{
point_type p;
for (std::size_t i = 0; i < Dims; ++i)
@@ -268,8 +268,8 @@ class hypercube_topology : public convex_topology<Dims>
}
private:
shared_ptr<RandomNumberGenerator> gen_ptr;
shared_ptr<rand_t> rand;
std::shared_ptr<RandomNumberGenerator> gen_ptr;
std::shared_ptr<rand_t> rand;
double scaling;
};
@@ -280,8 +280,8 @@ class square_topology : public hypercube_topology<2, RandomNumberGenerator>
public:
explicit square_topology(double scaling = 1.0) : inherited(scaling) { }
square_topology(RandomNumberGenerator& gen, double scaling = 1.0)
square_topology(RandomNumberGenerator& gen, double scaling = 1.0)
: inherited(gen, scaling) { }
};
@@ -308,7 +308,7 @@ class rectangle_topology : public convex_topology<2>
typedef typename convex_topology<2>::point_type point_type;
typedef typename convex_topology<2>::point_difference_type point_difference_type;
point_type random_point() const
point_type random_point() const
{
point_type p;
p[0] = (*rand)() * (right - left) + left;
@@ -362,8 +362,8 @@ class rectangle_topology : public convex_topology<2>
}
private:
shared_ptr<RandomNumberGenerator> gen_ptr;
shared_ptr<rand_t> rand;
std::shared_ptr<RandomNumberGenerator> gen_ptr;
std::shared_ptr<rand_t> rand;
double left, top, right, bottom;
};
@@ -374,8 +374,8 @@ class cube_topology : public hypercube_topology<3, RandomNumberGenerator>
public:
explicit cube_topology(double scaling = 1.0) : inherited(scaling) { }
cube_topology(RandomNumberGenerator& gen, double scaling = 1.0)
cube_topology(RandomNumberGenerator& gen, double scaling = 1.0)
: inherited(gen, scaling) { }
};
@@ -389,15 +389,15 @@ class ball_topology : public convex_topology<Dims>
typedef typename convex_topology<Dims>::point_type point_type;
typedef typename convex_topology<Dims>::point_difference_type point_difference_type;
explicit ball_topology(double radius = 1.0)
: gen_ptr(new RandomNumberGenerator), rand(new rand_t(*gen_ptr)),
radius(radius)
explicit ball_topology(double radius = 1.0)
: gen_ptr(new RandomNumberGenerator), rand(new rand_t(*gen_ptr)),
radius(radius)
{ }
ball_topology(RandomNumberGenerator& gen, double radius = 1.0)
ball_topology(RandomNumberGenerator& gen, double radius = 1.0)
: gen_ptr(), rand(new rand_t(gen)), radius(radius) { }
point_type random_point() const
point_type random_point() const
{
point_type p;
double dist_sum;
@@ -457,8 +457,8 @@ class ball_topology : public convex_topology<Dims>
}
private:
shared_ptr<RandomNumberGenerator> gen_ptr;
shared_ptr<rand_t> rand;
std::shared_ptr<RandomNumberGenerator> gen_ptr;
std::shared_ptr<rand_t> rand;
double radius;
};
@@ -469,8 +469,8 @@ class circle_topology : public ball_topology<2, RandomNumberGenerator>
public:
explicit circle_topology(double radius = 1.0) : inherited(radius) { }
circle_topology(RandomNumberGenerator& gen, double radius = 1.0)
circle_topology(RandomNumberGenerator& gen, double radius = 1.0)
: inherited(gen, radius) { }
};
@@ -481,13 +481,13 @@ class sphere_topology : public ball_topology<3, RandomNumberGenerator>
public:
explicit sphere_topology(double radius = 1.0) : inherited(radius) { }
sphere_topology(RandomNumberGenerator& gen, double radius = 1.0)
sphere_topology(RandomNumberGenerator& gen, double radius = 1.0)
: inherited(gen, radius) { }
};
template<typename RandomNumberGenerator = minstd_rand>
class heart_topology
class heart_topology
{
// Heart is defined as the union of three shapes:
// Square w/ corners (+-1000, -1000), (0, 0), (0, -2000)
@@ -495,7 +495,7 @@ class heart_topology
// Circle centered at (500, -500) radius 500*sqrt(2)
// Bounding box (-1000, -2000) - (1000, 500*(sqrt(2) - 1))
struct point
struct point
{
point() { values[0] = 0.0; values[1] = 0.0; }
point(double x, double y) { values[0] = x; values[1] = y; }
@@ -507,7 +507,7 @@ class heart_topology
double values[2];
};
bool in_heart(point p) const
bool in_heart(point p) const
{
#ifndef BOOST_NO_STDC_NAMESPACE
using std::abs;
@@ -522,7 +522,7 @@ class heart_topology
return false;
}
bool segment_within_heart(point p1, point p2) const
bool segment_within_heart(point p1, point p2) const
{
// Assumes that p1 and p2 are within the heart
if ((p1[0] < 0) == (p2[0] < 0)) return true; // Same side of symmetry line
@@ -538,13 +538,13 @@ class heart_topology
public:
typedef point point_type;
heart_topology()
heart_topology()
: gen_ptr(new RandomNumberGenerator), rand(new rand_t(*gen_ptr)) { }
heart_topology(RandomNumberGenerator& gen)
heart_topology(RandomNumberGenerator& gen)
: gen_ptr(), rand(new rand_t(gen)) { }
point random_point() const
point random_point() const
{
point result;
do {
@@ -556,7 +556,7 @@ class heart_topology
// Not going to provide clipping to bounding region or distance from boundary
double distance(point a, point b) const
double distance(point a, point b) const
{
if (segment_within_heart(a, b)) {
// Straight line
@@ -567,7 +567,7 @@ class heart_topology
}
}
point move_position_toward(point a, double fraction, point b) const
point move_position_toward(point a, double fraction, point b) const
{
if (segment_within_heart(a, b)) {
// Straight line
@@ -576,10 +576,10 @@ class heart_topology
} else {
double distance_to_point_a = boost::math::hypot(a[0], a[1]);
double distance_to_point_b = boost::math::hypot(b[0], b[1]);
double location_of_point = distance_to_point_a /
double location_of_point = distance_to_point_a /
(distance_to_point_a + distance_to_point_b);
if (fraction < location_of_point)
return point(a[0] * (1 - fraction / location_of_point),
return point(a[0] * (1 - fraction / location_of_point),
a[1] * (1 - fraction / location_of_point));
else
return point(
@@ -589,8 +589,8 @@ class heart_topology
}
private:
shared_ptr<RandomNumberGenerator> gen_ptr;
shared_ptr<rand_t> rand;
std::shared_ptr<RandomNumberGenerator> gen_ptr;
std::shared_ptr<rand_t> rand;
};
} // namespace boost