1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239
|
// Copyright (C) 2007 Douglas Gregor
// Copyright (C) 2007 Hartmut Kaiser
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// TODO:
// - Cache (some) remote vertex names?
#ifndef BOOST_GRAPH_DISTRIBUTED_NAMED_GRAPH_HPP
#define BOOST_GRAPH_DISTRIBUTED_NAMED_GRAPH_HPP
#ifndef BOOST_GRAPH_USE_MPI
#error "Parallel BGL files should not be included unless <boost/graph/use_mpi.hpp> has been included"
#endif
#include <boost/assert.hpp>
#include <boost/graph/named_graph.hpp>
#include <boost/functional/hash.hpp>
#include <boost/variant.hpp>
#include <boost/graph/parallel/simple_trigger.hpp>
#include <boost/graph/parallel/process_group.hpp>
#include <boost/graph/parallel/detail/property_holders.hpp>
namespace boost { namespace graph { namespace distributed {
using boost::parallel::trigger_receive_context;
using boost::detail::parallel::pair_with_property;
/*******************************************************************
* Hashed distribution of named entities *
*******************************************************************/
template<typename T>
struct hashed_distribution
{
template<typename ProcessGroup>
hashed_distribution(const ProcessGroup& pg, std::size_t /*num_vertices*/ = 0)
: n(num_processes(pg)) { }
int operator()(const T& value) const
{
return hasher(value) % n;
}
std::size_t n;
hash<T> hasher;
};
/// Specialization for named graphs
template <typename InDistribution, typename VertexProperty, typename VertexSize,
typename ProcessGroup,
typename ExtractName
= typename internal_vertex_name<VertexProperty>::type>
struct select_distribution
{
private:
/// The type used to name vertices in the graph
typedef typename remove_cv<
typename remove_reference<
typename ExtractName::result_type>::type>::type
vertex_name_type;
public:
/**
* The @c type field provides a distribution object that maps
* vertex names to processors. The distribution object will be
* constructed with the process group over which communication will
* occur. The distribution object shall also be a function
* object mapping from the type of the name to a processor number
* in @c [0, @c p) (for @c p processors). By default, the mapping
* function uses the @c boost::hash value of the name, modulo @c p.
*/
typedef typename mpl::if_<is_same<InDistribution, defaultS>,
hashed_distribution<vertex_name_type>,
InDistribution>::type
type;
/// for named graphs the default type is the same as the stored distribution
/// type
typedef type default_type;
};
/// Specialization for non-named graphs
template <typename InDistribution, typename VertexProperty, typename VertexSize,
typename ProcessGroup>
struct select_distribution<InDistribution, VertexProperty, VertexSize,
ProcessGroup, void>
{
/// the distribution type stored in the graph for non-named graphs should be
/// the variant_distribution type
typedef typename mpl::if_<is_same<InDistribution, defaultS>,
boost::parallel::variant_distribution<ProcessGroup,
VertexSize>,
InDistribution>::type type;
/// default_type is used as the distribution functor for the
/// adjacency_list, it should be parallel::block by default
typedef typename mpl::if_<is_same<InDistribution, defaultS>,
boost::parallel::block, type>::type
default_type;
};
/*******************************************************************
* Named graph mixin *
*******************************************************************/
/**
* named_graph is a mixin that provides names for the vertices of a
* graph, including a mapping from names to vertices. Graph types that
* may or may not be have vertex names (depending on the properties
* supplied by the user) should use maybe_named_graph.
*
* Template parameters:
*
* Graph: the graph type that derives from named_graph
*
* Vertex: the type of a vertex descriptor in Graph. Note: we cannot
* use graph_traits here, because the Graph is not yet defined.
*
* VertexProperty: the type of the property stored along with the
* vertex.
*
* ProcessGroup: the process group over which the distributed name
* graph mixin will communicate.
*/
template<typename Graph, typename Vertex, typename Edge, typename Config>
class named_graph
{
public:
/// Messages passed within the distributed named graph
enum message_kind {
/**
* Requests the addition of a vertex on a remote processor. The
* message data is a @c vertex_name_type.
*/
msg_add_vertex_name,
/**
* Requests the addition of a vertex on a remote processor. The
* message data is a @c vertex_name_type. The remote processor
* will send back a @c msg_add_vertex_name_reply message
* containing the vertex descriptor.
*/
msg_add_vertex_name_with_reply,
/**
* Requests the vertex descriptor corresponding to the given
* vertex name. The remote process will reply with a
* @c msg_find_vertex_reply message containing the answer.
*/
msg_find_vertex,
/**
* Requests the addition of an edge on a remote processor. The
* data stored in these messages is a @c pair<source, target>@,
* where @c source and @c target may be either names (of type @c
* vertex_name_type) or vertex descriptors, depending on what
* information we have locally.
*/
msg_add_edge_name_name,
msg_add_edge_vertex_name,
msg_add_edge_name_vertex,
/**
* These messages are identical to msg_add_edge_*_*, except that
* the process actually adding the edge will send back a @c
* pair<edge_descriptor,bool>
*/
msg_add_edge_name_name_with_reply,
msg_add_edge_vertex_name_with_reply,
msg_add_edge_name_vertex_with_reply,
/**
* Requests the addition of an edge with a property on a remote
* processor. The data stored in these messages is a @c
* pair<vertex_property_type, pair<source, target>>@, where @c
* source and @c target may be either names (of type @c
* vertex_name_type) or vertex descriptors, depending on what
* information we have locally.
*/
msg_add_edge_name_name_with_property,
msg_add_edge_vertex_name_with_property,
msg_add_edge_name_vertex_with_property,
/**
* These messages are identical to msg_add_edge_*_*_with_property,
* except that the process actually adding the edge will send back
* a @c pair<edge_descriptor,bool>.
*/
msg_add_edge_name_name_with_reply_and_property,
msg_add_edge_vertex_name_with_reply_and_property,
msg_add_edge_name_vertex_with_reply_and_property
};
/// The vertex descriptor type
typedef Vertex vertex_descriptor;
/// The edge descriptor type
typedef Edge edge_descriptor;
/// The vertex property type
typedef typename Config::vertex_property_type vertex_property_type;
/// The vertex property type
typedef typename Config::edge_property_type edge_property_type;
/// The type used to extract names from the property structure
typedef typename internal_vertex_name<vertex_property_type>::type
extract_name_type;
/// The type used to name vertices in the graph
typedef typename remove_cv<
typename remove_reference<
typename extract_name_type::result_type>::type>::type
vertex_name_type;
/// The type used to distribute named vertices in the graph
typedef typename Config::distribution_type distribution_type;
typedef typename Config::base_distribution_type base_distribution_type;
/// The type used for communication in the distributed structure
typedef typename Config::process_group_type process_group_type;
/// Type used to identify processes
typedef typename process_group_type::process_id_type process_id_type;
/// a reference to this class, which is used for disambiguation of the
// add_vertex function
typedef named_graph named_graph_type;
/// Structure returned when adding a vertex by vertex name
struct lazy_add_vertex;
friend struct lazy_add_vertex;
/// Structure returned when adding an edge by vertex name
struct lazy_add_edge;
friend struct lazy_add_edge;
/// Structure returned when adding an edge by vertex name with a property
struct lazy_add_edge_with_property;
friend struct lazy_add_edge_with_property;
explicit named_graph(const process_group_type& pg);
named_graph(const process_group_type& pg, const base_distribution_type& distribution);
/// Set up triggers, but only for the BSP process group
void setup_triggers();
/// Retrieve the derived instance
Graph& derived() { return static_cast<Graph&>(*this); }
const Graph& derived() const { return static_cast<const Graph&>(*this); }
/// Retrieve the process group
process_group_type& process_group() { return process_group_; }
const process_group_type& process_group() const { return process_group_; }
// Retrieve the named distribution
distribution_type& named_distribution() { return distribution_; }
const distribution_type& named_distribution() const { return distribution_; }
/// Notify the named_graph that we have added the given vertex. This
/// is a no-op.
void added_vertex(Vertex) { }
/// Notify the named_graph that we are removing the given
/// vertex. This is a no-op.
template <typename VertexIterStability>
void removing_vertex(Vertex, VertexIterStability) { }
/// Notify the named_graph that we are clearing the graph
void clearing_graph() { }
/// Retrieve the owner of a given vertex based on the properties
/// associated with that vertex. This operation just returns the
/// number of the local processor, adding all vertices locally.
process_id_type owner_by_property(const vertex_property_type&);
protected:
void
handle_add_vertex_name(int source, int tag, const vertex_name_type& msg,
trigger_receive_context);
vertex_descriptor
handle_add_vertex_name_with_reply(int source, int tag,
const vertex_name_type& msg,
trigger_receive_context);
boost::parallel::detail::untracked_pair<vertex_descriptor, bool>
handle_find_vertex(int source, int tag, const vertex_name_type& msg,
trigger_receive_context);
template<typename U, typename V>
void handle_add_edge(int source, int tag, const boost::parallel::detail::untracked_pair<U, V>& msg,
trigger_receive_context);
template<typename U, typename V>
boost::parallel::detail::untracked_pair<edge_descriptor, bool>
handle_add_edge_with_reply(int source, int tag, const boost::parallel::detail::untracked_pair<U, V>& msg,
trigger_receive_context);
template<typename U, typename V>
void
handle_add_edge_with_property
(int source, int tag,
const pair_with_property<U, V, edge_property_type>& msg,
trigger_receive_context);
template<typename U, typename V>
boost::parallel::detail::untracked_pair<edge_descriptor, bool>
handle_add_edge_with_reply_and_property
(int source, int tag,
const pair_with_property<U, V, edge_property_type>& msg,
trigger_receive_context);
/// The process group for this distributed data structure
process_group_type process_group_;
/// The distribution we will use to map names to processors
distribution_type distribution_;
};
/// Helper macro containing the template parameters of named_graph
#define BGL_NAMED_GRAPH_PARAMS \
typename Graph, typename Vertex, typename Edge, typename Config
/// Helper macro containing the named_graph<...> instantiation
#define BGL_NAMED_GRAPH \
named_graph<Graph, Vertex, Edge, Config>
/**
* Data structure returned from add_vertex that will "lazily" add the
* vertex, either when it is converted to a @c vertex_descriptor or
* when the most recent copy has been destroyed.
*/
template<BGL_NAMED_GRAPH_PARAMS>
struct BGL_NAMED_GRAPH::lazy_add_vertex
{
/// Construct a new lazyily-added vertex
lazy_add_vertex(named_graph& self, const vertex_name_type& name)
: self(self), name(name), committed(false) { }
/// Transfer responsibility for adding the vertex from the source of
/// the copy to the newly-constructed opbject.
lazy_add_vertex(const lazy_add_vertex& other)
: self(other.self), name(other.name), committed(other.committed)
{
other.committed = true;
}
/// If the vertex has not been added yet, add it
~lazy_add_vertex();
/// Add the vertex and return its descriptor. This conversion can
/// only occur once, and only when this object is responsible for
/// creating the vertex.
operator vertex_descriptor() const { return commit(); }
/// Add the vertex and return its descriptor. This can only be
/// called once, and only when this object is responsible for
/// creating the vertex.
vertex_descriptor commit() const;
protected:
named_graph& self;
vertex_name_type name;
mutable bool committed;
};
template<BGL_NAMED_GRAPH_PARAMS>
BGL_NAMED_GRAPH::lazy_add_vertex::~lazy_add_vertex()
{
typedef typename BGL_NAMED_GRAPH::process_id_type process_id_type;
/// If this vertex has already been created or will be created by
/// someone else, or if someone threw an exception, we will not
/// create the vertex now.
if (committed || std::uncaught_exception())
return;
committed = true;
process_id_type owner = self.named_distribution()(name);
if (owner == process_id(self.process_group()))
/// Add the vertex locally
add_vertex(self.derived().base().vertex_constructor(name), self.derived());
else
/// Ask the owner of the vertex to add a vertex with this name
send(self.process_group(), owner, msg_add_vertex_name, name);
}
template<BGL_NAMED_GRAPH_PARAMS>
typename BGL_NAMED_GRAPH::vertex_descriptor
BGL_NAMED_GRAPH::lazy_add_vertex::commit() const
{
typedef typename BGL_NAMED_GRAPH::process_id_type process_id_type;
BOOST_ASSERT (!committed);
committed = true;
process_id_type owner = self.named_distribution()(name);
if (owner == process_id(self.process_group()))
/// Add the vertex locally
return add_vertex(self.derived().base().vertex_constructor(name),
self.derived());
else {
/// Ask the owner of the vertex to add a vertex with this name
vertex_descriptor result;
send_oob_with_reply(self.process_group(), owner,
msg_add_vertex_name_with_reply, name, result);
return result;
}
}
/**
* Data structure returned from add_edge that will "lazily" add the
* edge, either when it is converted to a @c
* pair<edge_descriptor,bool> or when the most recent copy has been
* destroyed.
*/
template<BGL_NAMED_GRAPH_PARAMS>
struct BGL_NAMED_GRAPH::lazy_add_edge
{
/// The graph's edge descriptor
typedef typename graph_traits<Graph>::edge_descriptor edge_descriptor;
/// Add an edge for the edge (u, v) based on vertex names
lazy_add_edge(BGL_NAMED_GRAPH& self,
const vertex_name_type& u_name,
const vertex_name_type& v_name)
: self(self), u(u_name), v(v_name), committed(false) { }
/// Add an edge for the edge (u, v) based on a vertex descriptor and name
lazy_add_edge(BGL_NAMED_GRAPH& self,
vertex_descriptor u,
const vertex_name_type& v_name)
: self(self), u(u), v(v_name), committed(false) { }
/// Add an edge for the edge (u, v) based on a vertex name and descriptor
lazy_add_edge(BGL_NAMED_GRAPH& self,
const vertex_name_type& u_name,
vertex_descriptor v)
: self(self), u(u_name), v(v), committed(false) { }
/// Add an edge for the edge (u, v) based on vertex descriptors
lazy_add_edge(BGL_NAMED_GRAPH& self,
vertex_descriptor u,
vertex_descriptor v)
: self(self), u(u), v(v), committed(false) { }
/// Copy a lazy_add_edge structure, which transfers responsibility
/// for adding the edge to the newly-constructed object.
lazy_add_edge(const lazy_add_edge& other)
: self(other.self), u(other.u), v(other.v), committed(other.committed)
{
other.committed = true;
}
/// If the edge has not yet been added, add the edge but don't wait
/// for a reply.
~lazy_add_edge();
/// Returns commit().
operator std::pair<edge_descriptor, bool>() const { return commit(); }
// Add the edge. This operation will block if a remote edge is
// being added.
std::pair<edge_descriptor, bool> commit() const;
protected:
BGL_NAMED_GRAPH& self;
mutable variant<vertex_descriptor, vertex_name_type> u;
mutable variant<vertex_descriptor, vertex_name_type> v;
mutable bool committed;
private:
// No copy-assignment semantics
void operator=(lazy_add_edge&);
};
template<BGL_NAMED_GRAPH_PARAMS>
BGL_NAMED_GRAPH::lazy_add_edge::~lazy_add_edge()
{
using boost::parallel::detail::make_untracked_pair;
/// If this edge has already been created or will be created by
/// someone else, or if someone threw an exception, we will not
/// create the edge now.
if (committed || std::uncaught_exception())
return;
committed = true;
if (vertex_name_type* v_name = boost::get<vertex_name_type>(&v)) {
// We haven't resolved the target vertex to a descriptor yet, so
// it must not be local. Send a message to the owner of the target
// of the edge. If the owner of the target does not happen to own
// the source, it will resolve the target to a vertex descriptor
// and pass the message along to the owner of the source.
if (vertex_name_type* u_name = boost::get<vertex_name_type>(&u))
send(self.process_group(), self.distribution_(*v_name),
BGL_NAMED_GRAPH::msg_add_edge_name_name,
make_untracked_pair(*u_name, *v_name));
else
send(self.process_group(), self.distribution_(*v_name),
BGL_NAMED_GRAPH::msg_add_edge_vertex_name,
make_untracked_pair(boost::get<vertex_descriptor>(u), *v_name));
} else {
if (vertex_name_type* u_name = boost::get<vertex_name_type>(&u))
// We haven't resolved the source vertex to a descriptor yet, so
// it must not be local. Send a message to the owner of the
// source vertex requesting the edge addition.
send(self.process_group(), self.distribution_(*u_name),
BGL_NAMED_GRAPH::msg_add_edge_name_vertex,
make_untracked_pair(*u_name, boost::get<vertex_descriptor>(v)));
else
// We have descriptors for both of the vertices, either of which
// may be remote or local. Tell the owner of the source vertex
// to add the edge (it may be us!).
add_edge(boost::get<vertex_descriptor>(u),
boost::get<vertex_descriptor>(v),
self.derived());
}
}
template<BGL_NAMED_GRAPH_PARAMS>
std::pair<typename graph_traits<Graph>::edge_descriptor, bool>
BGL_NAMED_GRAPH::lazy_add_edge::commit() const
{
typedef typename BGL_NAMED_GRAPH::process_id_type process_id_type;
using boost::parallel::detail::make_untracked_pair;
BOOST_ASSERT(!committed);
committed = true;
/// The result we will return, if we are sending a message to
/// request that someone else add the edge.
boost::parallel::detail::untracked_pair<edge_descriptor, bool> result;
/// The owner of the vertex "u"
process_id_type u_owner;
process_id_type rank = process_id(self.process_group());
if (const vertex_name_type* u_name = boost::get<vertex_name_type>(&u)) {
/// We haven't resolved the source vertex to a descriptor yet, so
/// it must not be local.
u_owner = self.named_distribution()(*u_name);
/// Send a message to the remote vertex requesting that it add the
/// edge. The message differs depending on whether we have a
/// vertex name or a vertex descriptor for the target.
if (const vertex_name_type* v_name = boost::get<vertex_name_type>(&v))
send_oob_with_reply(self.process_group(), u_owner,
BGL_NAMED_GRAPH::msg_add_edge_name_name_with_reply,
make_untracked_pair(*u_name, *v_name), result);
else
send_oob_with_reply(self.process_group(), u_owner,
BGL_NAMED_GRAPH::msg_add_edge_name_vertex_with_reply,
make_untracked_pair(*u_name,
boost::get<vertex_descriptor>(v)),
result);
} else {
/// We have resolved the source vertex to a descriptor, which may
/// either be local or remote.
u_owner
= get(vertex_owner, self.derived(),
boost::get<vertex_descriptor>(u));
if (u_owner == rank) {
/// The source is local. If we need to, resolve the target vertex.
if (const vertex_name_type* v_name = boost::get<vertex_name_type>(&v))
v = add_vertex(*v_name, self.derived());
/// Add the edge using vertex descriptors
return add_edge(boost::get<vertex_descriptor>(u),
boost::get<vertex_descriptor>(v),
self.derived());
} else {
/// The source is remote. Just send a message to its owner
/// requesting that the owner add the new edge, either directly
/// or via the derived class's add_edge function.
if (const vertex_name_type* v_name = boost::get<vertex_name_type>(&v))
send_oob_with_reply
(self.process_group(), u_owner,
BGL_NAMED_GRAPH::msg_add_edge_vertex_name_with_reply,
make_untracked_pair(boost::get<vertex_descriptor>(u), *v_name),
result);
else
return add_edge(boost::get<vertex_descriptor>(u),
boost::get<vertex_descriptor>(v),
self.derived());
}
}
// If we get here, the edge has been added remotely and "result"
// contains the result of that edge addition.
return result;
}
/**
* Data structure returned from add_edge that will "lazily" add the
* edge with a property, either when it is converted to a @c
* pair<edge_descriptor,bool> or when the most recent copy has been
* destroyed.
*/
template<BGL_NAMED_GRAPH_PARAMS>
struct BGL_NAMED_GRAPH::lazy_add_edge_with_property
{
/// The graph's edge descriptor
typedef typename graph_traits<Graph>::edge_descriptor edge_descriptor;
/// The Edge property type for our graph
typedef typename Config::edge_property_type edge_property_type;
/// Add an edge for the edge (u, v) based on vertex names
lazy_add_edge_with_property(BGL_NAMED_GRAPH& self,
const vertex_name_type& u_name,
const vertex_name_type& v_name,
const edge_property_type& property)
: self(self), u(u_name), v(v_name), property(property), committed(false)
{
}
/// Add an edge for the edge (u, v) based on a vertex descriptor and name
lazy_add_edge_with_property(BGL_NAMED_GRAPH& self,
vertex_descriptor u,
const vertex_name_type& v_name,
const edge_property_type& property)
: self(self), u(u), v(v_name), property(property), committed(false) { }
/// Add an edge for the edge (u, v) based on a vertex name and descriptor
lazy_add_edge_with_property(BGL_NAMED_GRAPH& self,
const vertex_name_type& u_name,
vertex_descriptor v,
const edge_property_type& property)
: self(self), u(u_name), v(v), property(property), committed(false) { }
/// Add an edge for the edge (u, v) based on vertex descriptors
lazy_add_edge_with_property(BGL_NAMED_GRAPH& self,
vertex_descriptor u,
vertex_descriptor v,
const edge_property_type& property)
: self(self), u(u), v(v), property(property), committed(false) { }
/// Copy a lazy_add_edge_with_property structure, which transfers
/// responsibility for adding the edge to the newly-constructed
/// object.
lazy_add_edge_with_property(const lazy_add_edge_with_property& other)
: self(other.self), u(other.u), v(other.v), property(other.property),
committed(other.committed)
{
other.committed = true;
}
/// If the edge has not yet been added, add the edge but don't wait
/// for a reply.
~lazy_add_edge_with_property();
/// Returns commit().
operator std::pair<edge_descriptor, bool>() const { return commit(); }
// Add the edge. This operation will block if a remote edge is
// being added.
std::pair<edge_descriptor, bool> commit() const;
protected:
BGL_NAMED_GRAPH& self;
mutable variant<vertex_descriptor, vertex_name_type> u;
mutable variant<vertex_descriptor, vertex_name_type> v;
edge_property_type property;
mutable bool committed;
private:
// No copy-assignment semantics
void operator=(lazy_add_edge_with_property&);
};
template<BGL_NAMED_GRAPH_PARAMS>
BGL_NAMED_GRAPH::lazy_add_edge_with_property::~lazy_add_edge_with_property()
{
using boost::detail::parallel::make_pair_with_property;
/// If this edge has already been created or will be created by
/// someone else, or if someone threw an exception, we will not
/// create the edge now.
if (committed || std::uncaught_exception())
return;
committed = true;
if (vertex_name_type* v_name = boost::get<vertex_name_type>(&v)) {
// We haven't resolved the target vertex to a descriptor yet, so
// it must not be local. Send a message to the owner of the target
// of the edge. If the owner of the target does not happen to own
// the source, it will resolve the target to a vertex descriptor
// and pass the message along to the owner of the source.
if (vertex_name_type* u_name = boost::get<vertex_name_type>(&u))
send(self.process_group(), self.distribution_(*v_name),
BGL_NAMED_GRAPH::msg_add_edge_name_name_with_property,
make_pair_with_property(*u_name, *v_name, property));
else
send(self.process_group(), self.distribution_(*v_name),
BGL_NAMED_GRAPH::msg_add_edge_vertex_name_with_property,
make_pair_with_property(boost::get<vertex_descriptor>(u), *v_name,
property));
} else {
if (vertex_name_type* u_name = boost::get<vertex_name_type>(&u))
// We haven't resolved the source vertex to a descriptor yet, so
// it must not be local. Send a message to the owner of the
// source vertex requesting the edge addition.
send(self.process_group(), self.distribution_(*u_name),
BGL_NAMED_GRAPH::msg_add_edge_name_vertex_with_property,
make_pair_with_property(*u_name, boost::get<vertex_descriptor>(v),
property));
else
// We have descriptors for both of the vertices, either of which
// may be remote or local. Tell the owner of the source vertex
// to add the edge (it may be us!).
add_edge(boost::get<vertex_descriptor>(u),
boost::get<vertex_descriptor>(v),
property,
self.derived());
}
}
template<BGL_NAMED_GRAPH_PARAMS>
std::pair<typename graph_traits<Graph>::edge_descriptor, bool>
BGL_NAMED_GRAPH::lazy_add_edge_with_property::commit() const
{
using boost::detail::parallel::make_pair_with_property;
typedef typename BGL_NAMED_GRAPH::process_id_type process_id_type;
BOOST_ASSERT(!committed);
committed = true;
/// The result we will return, if we are sending a message to
/// request that someone else add the edge.
boost::parallel::detail::untracked_pair<edge_descriptor, bool> result;
/// The owner of the vertex "u"
process_id_type u_owner;
process_id_type rank = process_id(self.process_group());
if (const vertex_name_type* u_name = boost::get<vertex_name_type>(&u)) {
/// We haven't resolved the source vertex to a descriptor yet, so
/// it must not be local.
u_owner = self.named_distribution()(*u_name);
/// Send a message to the remote vertex requesting that it add the
/// edge. The message differs depending on whether we have a
/// vertex name or a vertex descriptor for the target.
if (const vertex_name_type* v_name = boost::get<vertex_name_type>(&v))
send_oob_with_reply
(self.process_group(), u_owner,
BGL_NAMED_GRAPH::msg_add_edge_name_name_with_reply_and_property,
make_pair_with_property(*u_name, *v_name, property),
result);
else
send_oob_with_reply
(self.process_group(), u_owner,
BGL_NAMED_GRAPH::msg_add_edge_name_vertex_with_reply_and_property,
make_pair_with_property(*u_name,
boost::get<vertex_descriptor>(v),
property),
result);
} else {
/// We have resolved the source vertex to a descriptor, which may
/// either be local or remote.
u_owner
= get(vertex_owner, self.derived(),
boost::get<vertex_descriptor>(u));
if (u_owner == rank) {
/// The source is local. If we need to, resolve the target vertex.
if (const vertex_name_type* v_name = boost::get<vertex_name_type>(&v))
v = add_vertex(*v_name, self.derived());
/// Add the edge using vertex descriptors
return add_edge(boost::get<vertex_descriptor>(u),
boost::get<vertex_descriptor>(v),
property,
self.derived());
} else {
/// The source is remote. Just send a message to its owner
/// requesting that the owner add the new edge, either directly
/// or via the derived class's add_edge function.
if (const vertex_name_type* v_name = boost::get<vertex_name_type>(&v))
send_oob_with_reply
(self.process_group(), u_owner,
BGL_NAMED_GRAPH::msg_add_edge_vertex_name_with_reply_and_property,
make_pair_with_property(boost::get<vertex_descriptor>(u), *v_name,
property),
result);
else
return add_edge(boost::get<vertex_descriptor>(u),
boost::get<vertex_descriptor>(v),
property,
self.derived());
}
}
// If we get here, the edge has been added remotely and "result"
// contains the result of that edge addition.
return result;
}
/// Construct the named_graph with a particular process group
template<BGL_NAMED_GRAPH_PARAMS>
BGL_NAMED_GRAPH::named_graph(const process_group_type& pg)
: process_group_(pg, boost::parallel::attach_distributed_object()),
distribution_(pg)
{
setup_triggers();
}
/// Construct the named_graph mixin with a particular process group
/// and distribution function
template<BGL_NAMED_GRAPH_PARAMS>
BGL_NAMED_GRAPH::named_graph(const process_group_type& pg,
const base_distribution_type& distribution)
: process_group_(pg, boost::parallel::attach_distributed_object()),
distribution_(pg, distribution)
{
setup_triggers();
}
template<BGL_NAMED_GRAPH_PARAMS>
void
BGL_NAMED_GRAPH::setup_triggers()
{
using boost::graph::parallel::simple_trigger;
simple_trigger(process_group_, msg_add_vertex_name, this,
&named_graph::handle_add_vertex_name);
simple_trigger(process_group_, msg_add_vertex_name_with_reply, this,
&named_graph::handle_add_vertex_name_with_reply);
simple_trigger(process_group_, msg_find_vertex, this,
&named_graph::handle_find_vertex);
simple_trigger(process_group_, msg_add_edge_name_name, this,
&named_graph::template handle_add_edge<vertex_name_type,
vertex_name_type>);
simple_trigger(process_group_, msg_add_edge_name_name_with_reply, this,
&named_graph::template handle_add_edge_with_reply
<vertex_name_type, vertex_name_type>);
simple_trigger(process_group_, msg_add_edge_name_vertex, this,
&named_graph::template handle_add_edge<vertex_name_type,
vertex_descriptor>);
simple_trigger(process_group_, msg_add_edge_name_vertex_with_reply, this,
&named_graph::template handle_add_edge_with_reply
<vertex_name_type, vertex_descriptor>);
simple_trigger(process_group_, msg_add_edge_vertex_name, this,
&named_graph::template handle_add_edge<vertex_descriptor,
vertex_name_type>);
simple_trigger(process_group_, msg_add_edge_vertex_name_with_reply, this,
&named_graph::template handle_add_edge_with_reply
<vertex_descriptor, vertex_name_type>);
simple_trigger(process_group_, msg_add_edge_name_name_with_property, this,
&named_graph::
template handle_add_edge_with_property<vertex_name_type,
vertex_name_type>);
simple_trigger(process_group_,
msg_add_edge_name_name_with_reply_and_property, this,
&named_graph::template handle_add_edge_with_reply_and_property
<vertex_name_type, vertex_name_type>);
simple_trigger(process_group_, msg_add_edge_name_vertex_with_property, this,
&named_graph::
template handle_add_edge_with_property<vertex_name_type,
vertex_descriptor>);
simple_trigger(process_group_,
msg_add_edge_name_vertex_with_reply_and_property, this,
&named_graph::template handle_add_edge_with_reply_and_property
<vertex_name_type, vertex_descriptor>);
simple_trigger(process_group_, msg_add_edge_vertex_name_with_property, this,
&named_graph::
template handle_add_edge_with_property<vertex_descriptor,
vertex_name_type>);
simple_trigger(process_group_,
msg_add_edge_vertex_name_with_reply_and_property, this,
&named_graph::template handle_add_edge_with_reply_and_property
<vertex_descriptor, vertex_name_type>);
}
/// Retrieve the vertex associated with the given name
template<BGL_NAMED_GRAPH_PARAMS>
optional<Vertex>
find_vertex(typename BGL_NAMED_GRAPH::vertex_name_type const& name,
const BGL_NAMED_GRAPH& g)
{
typedef typename Graph::local_vertex_descriptor local_vertex_descriptor;
typedef typename graph_traits<Graph>::vertex_descriptor vertex_descriptor;
// Determine the owner of this name
typename BGL_NAMED_GRAPH::process_id_type owner
= g.named_distribution()(name);
if (owner == process_id(g.process_group())) {
// The vertex is local, so search for a mapping here
optional<local_vertex_descriptor> result
= find_vertex(name, g.derived().base());
if (result)
return Vertex(owner, *result);
else
return optional<Vertex>();
}
else {
// Ask the ownering process for the name of this vertex
boost::parallel::detail::untracked_pair<vertex_descriptor, bool> result;
send_oob_with_reply(g.process_group(), owner,
BGL_NAMED_GRAPH::msg_find_vertex, name, result);
if (result.second)
return result.first;
else
return optional<Vertex>();
}
}
/// meta-function helping in figuring out if the given VertextProerty belongs to
/// a named graph
template<typename VertexProperty>
struct not_is_named_graph
: is_same<typename internal_vertex_name<VertexProperty>::type, void>
{};
/// Retrieve the vertex associated with the given name
template<typename Graph>
typename Graph::named_graph_type::lazy_add_vertex
add_vertex(typename Graph::vertex_name_type const& name,
Graph& g,
typename disable_if<
not_is_named_graph<typename Graph::vertex_property_type>,
void*>::type = 0)
{
return typename Graph::named_graph_type::lazy_add_vertex(g, name);
}
/// Add an edge using vertex names to refer to the vertices
template<BGL_NAMED_GRAPH_PARAMS>
typename BGL_NAMED_GRAPH::lazy_add_edge
add_edge(typename BGL_NAMED_GRAPH::vertex_name_type const& u_name,
typename BGL_NAMED_GRAPH::vertex_name_type const& v_name,
BGL_NAMED_GRAPH& g)
{
typedef typename BGL_NAMED_GRAPH::lazy_add_edge lazy_add_edge;
typedef typename BGL_NAMED_GRAPH::process_id_type process_id_type;
process_id_type rank = process_id(g.process_group());
process_id_type u_owner = g.named_distribution()(u_name);
process_id_type v_owner = g.named_distribution()(v_name);
// Resolve local vertex names before building the "lazy" edge
// addition structure.
if (u_owner == rank && v_owner == rank)
return lazy_add_edge(g, add_vertex(u_name, g), add_vertex(v_name, g));
else if (u_owner == rank && v_owner != rank)
return lazy_add_edge(g, add_vertex(u_name, g), v_name);
else if (u_owner != rank && v_owner == rank)
return lazy_add_edge(g, u_name, add_vertex(v_name, g));
else
return lazy_add_edge(g, u_name, v_name);
}
template<BGL_NAMED_GRAPH_PARAMS>
typename BGL_NAMED_GRAPH::lazy_add_edge
add_edge(typename BGL_NAMED_GRAPH::vertex_name_type const& u_name,
typename BGL_NAMED_GRAPH::vertex_descriptor const& v,
BGL_NAMED_GRAPH& g)
{
// Resolve local vertex names before building the "lazy" edge
// addition structure.
typedef typename BGL_NAMED_GRAPH::lazy_add_edge lazy_add_edge;
if (g.named_distribution()(u_name) == process_id(g.process_group()))
return lazy_add_edge(g, add_vertex(u_name, g), v);
else
return lazy_add_edge(g, u_name, v);
}
template<BGL_NAMED_GRAPH_PARAMS>
typename BGL_NAMED_GRAPH::lazy_add_edge
add_edge(typename BGL_NAMED_GRAPH::vertex_descriptor const& u,
typename BGL_NAMED_GRAPH::vertex_name_type const& v_name,
BGL_NAMED_GRAPH& g)
{
// Resolve local vertex names before building the "lazy" edge
// addition structure.
typedef typename BGL_NAMED_GRAPH::lazy_add_edge lazy_add_edge;
if (g.named_distribution()(v_name) == process_id(g.process_group()))
return lazy_add_edge(g, u, add_vertex(v_name, g));
else
return lazy_add_edge(g, u, v_name);
}
/// Add an edge using vertex names to refer to the vertices
template<BGL_NAMED_GRAPH_PARAMS>
typename BGL_NAMED_GRAPH::lazy_add_edge_with_property
add_edge(typename BGL_NAMED_GRAPH::vertex_name_type const& u_name,
typename BGL_NAMED_GRAPH::vertex_name_type const& v_name,
typename Graph::edge_property_type const& property,
BGL_NAMED_GRAPH& g)
{
typedef typename BGL_NAMED_GRAPH::lazy_add_edge_with_property lazy_add_edge;
typedef typename BGL_NAMED_GRAPH::process_id_type process_id_type;
process_id_type rank = process_id(g.process_group());
process_id_type u_owner = g.named_distribution()(u_name);
process_id_type v_owner = g.named_distribution()(v_name);
// Resolve local vertex names before building the "lazy" edge
// addition structure.
if (u_owner == rank && v_owner == rank)
return lazy_add_edge(g, add_vertex(u_name, g), add_vertex(v_name, g),
property);
else if (u_owner == rank && v_owner != rank)
return lazy_add_edge(g, add_vertex(u_name, g), v_name, property);
else if (u_owner != rank && v_owner == rank)
return lazy_add_edge(g, u_name, add_vertex(v_name, g), property);
else
return lazy_add_edge(g, u_name, v_name, property);
}
template<BGL_NAMED_GRAPH_PARAMS>
typename BGL_NAMED_GRAPH::lazy_add_edge_with_property
add_edge(typename BGL_NAMED_GRAPH::vertex_name_type const& u_name,
typename BGL_NAMED_GRAPH::vertex_descriptor const& v,
typename Graph::edge_property_type const& property,
BGL_NAMED_GRAPH& g)
{
// Resolve local vertex names before building the "lazy" edge
// addition structure.
typedef typename BGL_NAMED_GRAPH::lazy_add_edge_with_property lazy_add_edge;
if (g.named_distribution()(u_name) == process_id(g.process_group()))
return lazy_add_edge(g, add_vertex(u_name, g), v, property);
else
return lazy_add_edge(g, u_name, v, property);
}
template<BGL_NAMED_GRAPH_PARAMS>
typename BGL_NAMED_GRAPH::lazy_add_edge_with_property
add_edge(typename BGL_NAMED_GRAPH::vertex_descriptor const& u,
typename BGL_NAMED_GRAPH::vertex_name_type const& v_name,
typename Graph::edge_property_type const& property,
BGL_NAMED_GRAPH& g)
{
// Resolve local vertex names before building the "lazy" edge
// addition structure.
typedef typename BGL_NAMED_GRAPH::lazy_add_edge_with_property lazy_add_edge;
if (g.named_distribution()(v_name) == process_id(g.process_group()))
return lazy_add_edge(g, u, add_vertex(v_name, g), property);
else
return lazy_add_edge(g, u, v_name, property);
}
template<BGL_NAMED_GRAPH_PARAMS>
typename BGL_NAMED_GRAPH::process_id_type
BGL_NAMED_GRAPH::owner_by_property(const vertex_property_type& property)
{
return distribution_(derived().base().extract_name(property));
}
/*******************************************************************
* Message handlers *
*******************************************************************/
template<BGL_NAMED_GRAPH_PARAMS>
void
BGL_NAMED_GRAPH::
handle_add_vertex_name(int /*source*/, int /*tag*/,
const vertex_name_type& msg, trigger_receive_context)
{
add_vertex(msg, derived());
}
template<BGL_NAMED_GRAPH_PARAMS>
typename BGL_NAMED_GRAPH::vertex_descriptor
BGL_NAMED_GRAPH::
handle_add_vertex_name_with_reply(int source, int /*tag*/,
const vertex_name_type& msg,
trigger_receive_context)
{
return add_vertex(msg, derived());
}
template<BGL_NAMED_GRAPH_PARAMS>
boost::parallel::detail::untracked_pair<typename BGL_NAMED_GRAPH::vertex_descriptor, bool>
BGL_NAMED_GRAPH::
handle_find_vertex(int source, int /*tag*/, const vertex_name_type& msg,
trigger_receive_context)
{
using boost::parallel::detail::make_untracked_pair;
optional<vertex_descriptor> v = find_vertex(msg, derived());
if (v)
return make_untracked_pair(*v, true);
else
return make_untracked_pair(graph_traits<Graph>::null_vertex(), false);
}
template<BGL_NAMED_GRAPH_PARAMS>
template<typename U, typename V>
void
BGL_NAMED_GRAPH::
handle_add_edge(int source, int /*tag*/, const boost::parallel::detail::untracked_pair<U, V>& msg,
trigger_receive_context)
{
add_edge(msg.first, msg.second, derived());
}
template<BGL_NAMED_GRAPH_PARAMS>
template<typename U, typename V>
boost::parallel::detail::untracked_pair<typename BGL_NAMED_GRAPH::edge_descriptor, bool>
BGL_NAMED_GRAPH::
handle_add_edge_with_reply(int source, int /*tag*/, const boost::parallel::detail::untracked_pair<U, V>& msg,
trigger_receive_context)
{
std::pair<typename BGL_NAMED_GRAPH::edge_descriptor, bool> p =
add_edge(msg.first, msg.second, derived());
return p;
}
template<BGL_NAMED_GRAPH_PARAMS>
template<typename U, typename V>
void
BGL_NAMED_GRAPH::
handle_add_edge_with_property
(int source, int tag,
const pair_with_property<U, V, edge_property_type>& msg,
trigger_receive_context)
{
add_edge(msg.first, msg.second, msg.get_property(), derived());
}
template<BGL_NAMED_GRAPH_PARAMS>
template<typename U, typename V>
boost::parallel::detail::untracked_pair<typename BGL_NAMED_GRAPH::edge_descriptor, bool>
BGL_NAMED_GRAPH::
handle_add_edge_with_reply_and_property
(int source, int tag,
const pair_with_property<U, V, edge_property_type>& msg,
trigger_receive_context)
{
std:: pair<typename BGL_NAMED_GRAPH::edge_descriptor, bool> p =
add_edge(msg.first, msg.second, msg.get_property(), derived());
return p;
}
#undef BGL_NAMED_GRAPH
#undef BGL_NAMED_GRAPH_PARAMS
/*******************************************************************
* Maybe named graph mixin *
*******************************************************************/
/**
* A graph mixin that can provide a mapping from names to vertices,
* and use that mapping to simplify creation and manipulation of
* graphs.
*/
template<typename Graph, typename Vertex, typename Edge, typename Config,
typename ExtractName
= typename internal_vertex_name<typename Config::vertex_property_type>::type>
struct maybe_named_graph
: public named_graph<Graph, Vertex, Edge, Config>
{
private:
typedef named_graph<Graph, Vertex, Edge, Config> inherited;
typedef typename Config::process_group_type process_group_type;
public:
/// The type used to distribute named vertices in the graph
typedef typename Config::distribution_type distribution_type;
typedef typename Config::base_distribution_type base_distribution_type;
explicit maybe_named_graph(const process_group_type& pg) : inherited(pg) { }
maybe_named_graph(const process_group_type& pg,
const base_distribution_type& distribution)
: inherited(pg, distribution) { }
distribution_type& distribution() { return this->distribution_; }
const distribution_type& distribution() const { return this->distribution_; }
};
/**
* A graph mixin that can provide a mapping from names to vertices,
* and use that mapping to simplify creation and manipulation of
* graphs. This partial specialization turns off this functionality
* when the @c VertexProperty does not have an internal vertex name.
*/
template<typename Graph, typename Vertex, typename Edge, typename Config>
struct maybe_named_graph<Graph, Vertex, Edge, Config, void>
{
private:
typedef typename Config::process_group_type process_group_type;
typedef typename Config::vertex_property_type vertex_property_type;
public:
typedef typename process_group_type::process_id_type process_id_type;
/// The type used to distribute named vertices in the graph
typedef typename Config::distribution_type distribution_type;
typedef typename Config::base_distribution_type base_distribution_type;
explicit maybe_named_graph(const process_group_type&) { }
maybe_named_graph(const process_group_type& pg,
const base_distribution_type& distribution)
: distribution_(pg, distribution) { }
/// Notify the named_graph that we have added the given vertex. This
/// is a no-op.
void added_vertex(Vertex) { }
/// Notify the named_graph that we are removing the given
/// vertex. This is a no-op.
template <typename VertexIterStability>
void removing_vertex(Vertex, VertexIterStability) { }
/// Notify the named_graph that we are clearing the graph
void clearing_graph() { }
/// Retrieve the owner of a given vertex based on the properties
/// associated with that vertex. This operation just returns the
/// number of the local processor, adding all vertices locally.
process_id_type owner_by_property(const vertex_property_type&)
{
return process_id(pg);
}
distribution_type& distribution() { return distribution_; }
const distribution_type& distribution() const { return distribution_; }
protected:
/// The process group of the graph
process_group_type pg;
/// The distribution used for the graph
distribution_type distribution_;
};
} } } // end namespace boost::graph::distributed
#endif // BOOST_GRAPH_DISTRIBUTED_NAMED_GRAPH_HPP
|