1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987 |
- #ifndef BOOST_GRAPH_DISTRIBUTED_CSR_HPP
- #define BOOST_GRAPH_DISTRIBUTED_CSR_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/compressed_sparse_row_graph.hpp>
- #include <boost/graph/distributed/selector.hpp>
- #include <boost/mpl/if.hpp>
- #include <boost/type_traits/is_same.hpp>
- #include <boost/graph/distributed/concepts.hpp>
- #include <boost/graph/parallel/properties.hpp>
- #include <boost/graph/parallel/distribution.hpp>
- #include <boost/property_map/parallel/local_property_map.hpp>
- #include <boost/property_map/parallel/distributed_property_map.hpp>
- namespace boost {
- enum distributed_construct_inplace_from_sources_and_targets_t
- {distributed_construct_inplace_from_sources_and_targets};
- static const int processor_bits = 8;
- struct distributed_csr_tag
- : public virtual distributed_graph_tag,
- public virtual distributed_vertex_list_graph_tag,
- public virtual distributed_edge_list_graph_tag,
- public virtual incidence_graph_tag,
- public virtual adjacency_graph_tag {};
- template<typename VertexProperty, typename EdgeProperty,
- typename GraphProperty, typename ProcessGroup, typename InVertex,
- typename InDistribution, typename InEdgeIndex>
- class compressed_sparse_row_graph<
- directedS, VertexProperty, EdgeProperty, GraphProperty,
- distributedS<ProcessGroup, InVertex, InDistribution>,
- InEdgeIndex>
- {
- typedef compressed_sparse_row_graph self_type;
- private:
-
- typedef typename mpl::if_<is_same<InVertex, defaultS>,
- std::size_t,
- InVertex>::type Vertex;
-
- typedef typename mpl::if_<is_same<InEdgeIndex,
- distributedS<ProcessGroup, InVertex,
- InDistribution> >,
- Vertex,
- InEdgeIndex>::type EdgeIndex;
- public:
-
- typedef compressed_sparse_row_graph<directedS, VertexProperty, EdgeProperty,
- GraphProperty, Vertex, EdgeIndex>
- base_type;
-
-
- typedef Vertex vertex_descriptor;
- typedef typename graph_traits<base_type>::edge_descriptor edge_descriptor;
- typedef directed_tag directed_category;
- typedef allow_parallel_edge_tag edge_parallel_category;
- typedef distributed_csr_tag traversal_category;
- static vertex_descriptor null_vertex();
-
-
- typedef Vertex vertices_size_type;
- class vertex_iterator;
-
-
- typedef EdgeIndex edges_size_type;
- class edge_iterator;
-
-
- typedef typename graph_traits<base_type>::out_edge_iterator
- out_edge_iterator;
- typedef typename graph_traits<base_type>::degree_size_type
- degree_size_type;
-
-
- typedef typename graph_traits<base_type>::adjacency_iterator
- adjacency_iterator;
-
-
- typedef void in_edge_iterator;
-
-
- typedef ProcessGroup process_group_type;
- typedef boost::parallel::variant_distribution<process_group_type, Vertex>
- distribution_type;
-
-
-
-
- typedef no_property vertex_property_type;
- typedef no_property edge_property_type;
- typedef no_property graph_property_type;
- typedef typename mpl::if_<is_void<VertexProperty>,
- void****,
- VertexProperty>::type vertex_bundled;
- typedef typename mpl::if_<is_void<EdgeProperty>,
- void****,
- EdgeProperty>::type edge_bundled;
- typedef typename mpl::if_<is_void<GraphProperty>,
- void****,
- GraphProperty>::type graph_bundled;
-
-
- typedef typename ProcessGroup::process_id_type process_id_type;
-
-
- compressed_sparse_row_graph(const ProcessGroup& pg = ProcessGroup())
- : m_process_group(pg), m_distribution(parallel::block(pg, 0)) {}
- compressed_sparse_row_graph(const GraphProperty& prop,
- const ProcessGroup& pg = ProcessGroup())
- : m_process_group(pg), m_distribution(parallel::block(pg, 0)) {}
- compressed_sparse_row_graph(vertices_size_type numverts,
- const ProcessGroup& pg = ProcessGroup())
- : m_process_group(pg), m_distribution(parallel::block(pg, 0)),
- m_base(numverts)
- {}
- compressed_sparse_row_graph(vertices_size_type numverts,
- const GraphProperty& prop,
- const ProcessGroup& pg = ProcessGroup())
- : m_process_group(pg), m_distribution(parallel::block(pg, 0)),
- m_base(numverts)
- {}
- template <typename Distribution>
- compressed_sparse_row_graph(vertices_size_type numverts,
- const ProcessGroup& pg,
- const Distribution& dist)
- : m_process_group(pg), m_distribution(dist), m_base(numverts) {}
- template <typename Distribution>
- compressed_sparse_row_graph(vertices_size_type numverts,
- const GraphProperty& prop,
- const ProcessGroup& pg,
- const Distribution& dist)
- : m_process_group(pg), m_distribution(dist), m_base(numverts) {}
- template <typename InputIterator>
- compressed_sparse_row_graph(edges_are_unsorted_t,
- InputIterator edge_begin, InputIterator edge_end,
- vertices_size_type numverts,
- const ProcessGroup& pg = ProcessGroup(),
- const GraphProperty& prop = GraphProperty());
- template <typename InputIterator, typename Distribution>
- compressed_sparse_row_graph(edges_are_unsorted_t,
- InputIterator edge_begin, InputIterator edge_end,
- vertices_size_type numverts,
- const ProcessGroup& pg,
- const Distribution& dist,
- const GraphProperty& prop = GraphProperty());
- template <typename InputIterator, typename EdgePropertyIterator>
- compressed_sparse_row_graph(edges_are_unsorted_t,
- InputIterator edge_begin, InputIterator edge_end,
- EdgePropertyIterator ep_iter,
- vertices_size_type numverts,
- const ProcessGroup& pg = ProcessGroup(),
- const GraphProperty& prop = GraphProperty());
- template <typename InputIterator, typename EdgePropertyIterator,
- typename Distribution>
- compressed_sparse_row_graph(edges_are_unsorted_t,
- InputIterator edge_begin, InputIterator edge_end,
- EdgePropertyIterator ep_iter,
- vertices_size_type numverts,
- const ProcessGroup& pg,
- const Distribution& dist,
- const GraphProperty& prop = GraphProperty());
- template <typename InputIterator>
- compressed_sparse_row_graph(edges_are_sorted_t,
- InputIterator edge_begin, InputIterator edge_end,
- vertices_size_type numverts,
- edges_size_type numedges = 0,
- const ProcessGroup& pg = ProcessGroup(),
- const GraphProperty& prop = GraphProperty());
- template <typename InputIterator, typename Distribution>
- compressed_sparse_row_graph(edges_are_sorted_t,
- InputIterator edge_begin, InputIterator edge_end,
- vertices_size_type numverts,
- const ProcessGroup& pg,
- const Distribution& dist,
- const GraphProperty& prop = GraphProperty());
- template <typename InputIterator, typename EdgePropertyIterator>
- compressed_sparse_row_graph(edges_are_sorted_t,
- InputIterator edge_begin, InputIterator edge_end,
- EdgePropertyIterator ep_iter,
- vertices_size_type numverts,
- edges_size_type numedges = 0,
- const ProcessGroup& pg = ProcessGroup(),
- const GraphProperty& prop = GraphProperty());
- template <typename InputIterator, typename EdgePropertyIterator,
- typename Distribution>
- compressed_sparse_row_graph(edges_are_sorted_t,
- InputIterator edge_begin, InputIterator edge_end,
- EdgePropertyIterator ep_iter,
- vertices_size_type numverts,
- const ProcessGroup& pg,
- const Distribution& dist,
- const GraphProperty& prop = GraphProperty());
- template <typename MultiPassInputIterator>
- compressed_sparse_row_graph(edges_are_unsorted_multi_pass_t,
- MultiPassInputIterator edge_begin,
- MultiPassInputIterator edge_end,
- vertices_size_type numverts,
- const ProcessGroup& pg = ProcessGroup(),
- const GraphProperty& prop = GraphProperty());
- template <typename MultiPassInputIterator, typename Distribution>
- compressed_sparse_row_graph(edges_are_unsorted_multi_pass_t,
- MultiPassInputIterator edge_begin,
- MultiPassInputIterator edge_end,
- vertices_size_type numverts,
- const ProcessGroup& pg,
- const Distribution& dist,
- const GraphProperty& prop = GraphProperty());
- template <typename MultiPassInputIterator, typename EdgePropertyIterator>
- compressed_sparse_row_graph(edges_are_unsorted_multi_pass_t,
- MultiPassInputIterator edge_begin,
- MultiPassInputIterator edge_end,
- EdgePropertyIterator ep_iter,
- vertices_size_type numverts,
- const ProcessGroup& pg = ProcessGroup(),
- const GraphProperty& prop = GraphProperty());
- template <typename MultiPassInputIterator, typename EdgePropertyIterator,
- typename Distribution>
- compressed_sparse_row_graph(edges_are_unsorted_multi_pass_t,
- MultiPassInputIterator edge_begin,
- MultiPassInputIterator edge_end,
- EdgePropertyIterator ep_iter,
- vertices_size_type numverts,
- const ProcessGroup& pg,
- const Distribution& dist,
- const GraphProperty& prop = GraphProperty());
- template <typename Source>
- compressed_sparse_row_graph(distributed_construct_inplace_from_sources_and_targets_t,
- std::vector<Source>& sources,
- std::vector<vertex_descriptor>& targets,
- vertices_size_type numverts,
- const ProcessGroup& pg = ProcessGroup(),
- const GraphProperty& prop = GraphProperty());
- template <typename Distribution, typename Source>
- compressed_sparse_row_graph(distributed_construct_inplace_from_sources_and_targets_t,
- std::vector<Source>& sources,
- std::vector<vertex_descriptor>& targets,
- vertices_size_type numverts,
- const ProcessGroup& pg,
- const Distribution& dist,
- const GraphProperty& prop = GraphProperty());
- template <typename Source>
- compressed_sparse_row_graph(distributed_construct_inplace_from_sources_and_targets_t,
- std::vector<Source>& sources,
- std::vector<vertex_descriptor>& targets,
- std::vector<edge_bundled>& edge_props,
- vertices_size_type numverts,
- const ProcessGroup& pg = ProcessGroup(),
- const GraphProperty& prop = GraphProperty());
- template <typename Distribution, typename Source>
- compressed_sparse_row_graph(distributed_construct_inplace_from_sources_and_targets_t,
- std::vector<Source>& sources,
- std::vector<vertex_descriptor>& targets,
- std::vector<edge_bundled>& edge_props,
- vertices_size_type numverts,
- const ProcessGroup& pg,
- const Distribution& dist,
- const GraphProperty& prop = GraphProperty());
- template<typename InputIterator>
- compressed_sparse_row_graph(InputIterator edge_begin, InputIterator edge_end,
- vertices_size_type numverts,
- const ProcessGroup& pg = ProcessGroup(),
- const GraphProperty& prop = GraphProperty());
- template<typename InputIterator, typename EdgePropertyIterator>
- compressed_sparse_row_graph(InputIterator edge_begin, InputIterator edge_end,
- EdgePropertyIterator ep_iter,
- vertices_size_type numverts,
- const ProcessGroup& pg = ProcessGroup(),
- const GraphProperty& prop = GraphProperty());
- template<typename InputIterator, typename Distribution>
- compressed_sparse_row_graph(InputIterator edge_begin, InputIterator edge_end,
- vertices_size_type numverts,
- const ProcessGroup& pg,
- const Distribution& dist,
- const GraphProperty& prop = GraphProperty());
- template<typename InputIterator, typename EdgePropertyIterator,
- typename Distribution>
- compressed_sparse_row_graph(InputIterator edge_begin, InputIterator edge_end,
- EdgePropertyIterator ep_iter,
- vertices_size_type numverts,
- const ProcessGroup& pg,
- const Distribution& dist,
- const GraphProperty& prop = GraphProperty());
- base_type& base() { return m_base; }
- const base_type& base() const { return m_base; }
- process_group_type process_group() const { return m_process_group.base(); }
- distribution_type& distribution() { return m_distribution; }
- const distribution_type& distribution() const { return m_distribution; }
-
- vertex_bundled& operator[](vertex_descriptor v)
- {
- return get(vertex_bundle, *this, v);
- }
- const vertex_bundled& operator[](vertex_descriptor v) const
- {
- return get(vertex_bundle, *this, v);
- }
- edge_bundled& operator[](edge_descriptor e)
- {
- return get(edge_bundle, *this, e);
- }
- const edge_bundled& operator[](edge_descriptor e) const
- {
- return get(edge_bundle, *this, e);
- }
-
- vertex_descriptor
- make_vertex_descriptor(process_id_type p, vertex_descriptor v) const
- {
- vertex_descriptor vertex_local_index_bits =
- sizeof(vertex_descriptor) * CHAR_BIT - processor_bits;
- return v | ((vertex_descriptor)p << vertex_local_index_bits);
- }
-
- vertex_descriptor local_to_global_vertex(vertex_descriptor v) const
- {
- return make_vertex_descriptor(process_id(m_process_group), v);
- }
-
- vertex_descriptor add_vertex()
- {
- typename graph_traits<base_type>::vertex_descriptor v
- = boost::add_vertex(m_base);
- return make_vertex_descriptor(process_id(m_process_group), v);
- }
- vertex_descriptor add_vertex(const vertex_bundled& p)
- {
- typename graph_traits<base_type>::vertex_descriptor v
- = boost::add_vertex(m_base, p);
- return make_vertex_descriptor(process_id(m_process_group), v);
- }
- vertex_descriptor add_vertices(vertices_size_type count)
- {
- typename graph_traits<base_type>::vertex_descriptor v
- = boost::add_vertices(count, m_base);
- return make_vertex_descriptor(process_id(m_process_group), v);
- }
- template <typename InputIterator>
- void
- add_edges(InputIterator first, InputIterator last)
- { boost::add_edges_global(first, last, get(vertex_local, *this), m_base); }
- template <typename InputIterator, typename EdgePropertyIterator>
- void
- add_edges(InputIterator first, InputIterator last,
- EdgePropertyIterator ep_iter,
- EdgePropertyIterator ep_iter_end)
- { boost::add_edges_global(first, last, ep_iter, ep_iter_end,
- get(vertex_local, *this), m_base); }
- template <typename InputIterator>
- void
- add_edges_sorted(InputIterator first, InputIterator last)
- { boost::add_edges_sorted_global(first, last,
- get(vertex_local, *this), m_base); }
- template <typename InputIterator, typename EdgePropertyIterator>
- void
- add_edges_sorted(InputIterator first_sorted, InputIterator last_sorted,
- EdgePropertyIterator ep_iter_sorted)
- { boost::add_edges_sorted_global(first_sorted, last_sorted, ep_iter_sorted,
- get(vertex_local, *this), m_base); }
- protected:
- ProcessGroup m_process_group;
- distribution_type m_distribution;
- base_type m_base;
- };
- #define BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS \
- typename VertexProperty, typename EdgeProperty, \
- typename GraphProperty, typename ProcessGroup, typename InVertex, \
- typename InDistribution, typename InEdgeIndex
- #define BOOST_DISTRIB_CSR_GRAPH_TYPE \
- compressed_sparse_row_graph< \
- directedS, VertexProperty, EdgeProperty, GraphProperty, \
- distributedS<ProcessGroup, InVertex, InDistribution>, \
- InEdgeIndex>
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor
- BOOST_DISTRIB_CSR_GRAPH_TYPE::null_vertex()
- {
- return graph_traits<base_type>::null_vertex();
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor
- source(typename BOOST_DISTRIB_CSR_GRAPH_TYPE::edge_descriptor e,
- const BOOST_DISTRIB_CSR_GRAPH_TYPE&)
- { return e.src; }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor
- target(typename BOOST_DISTRIB_CSR_GRAPH_TYPE::edge_descriptor e,
- const BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- { return target(e, g.base()); }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline std::pair<typename BOOST_DISTRIB_CSR_GRAPH_TYPE::out_edge_iterator,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::out_edge_iterator>
- out_edges(typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor u,
- const BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- {
- typedef typename BOOST_DISTRIB_CSR_GRAPH_TYPE::edges_size_type
- edges_size_type;
- typedef typename BOOST_DISTRIB_CSR_GRAPH_TYPE::edge_descriptor ed;
- typedef typename BOOST_DISTRIB_CSR_GRAPH_TYPE::out_edge_iterator it;
- edges_size_type u_local = get(vertex_local, g, u);
- edges_size_type u_row_start = g.base().m_forward.m_rowstart[u_local];
- edges_size_type next_row_start = g.base().m_forward.m_rowstart[u_local + 1];
- return std::make_pair(it(ed(u, u_row_start)),
- it(ed(u, (std::max)(u_row_start, next_row_start))));
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline typename BOOST_DISTRIB_CSR_GRAPH_TYPE::degree_size_type
- out_degree(typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor u,
- const BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- {
- return out_degree(get(vertex_local, g, u), g.base());
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- void synchronize(const BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- {
- synchronize(g.process_group());
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- ProcessGroup
- process_group(const BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- { return g.process_group(); }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline std::pair<typename BOOST_DISTRIB_CSR_GRAPH_TYPE::adjacency_iterator,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::adjacency_iterator>
- adjacent_vertices(typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor u,
- const BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- {
- return adjacent_vertices(get(vertex_local, g, u), g.base());
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- class BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_iterator
- : public iterator_adaptor<vertex_iterator,
- counting_iterator<Vertex>,
- Vertex,
- random_access_traversal_tag,
- Vertex>
- {
- typedef iterator_adaptor<vertex_iterator,
- counting_iterator<Vertex>,
- Vertex,
- random_access_traversal_tag,
- Vertex> inherited;
- public:
- vertex_iterator() {}
- explicit vertex_iterator(Vertex v, const self_type* graph)
- : inherited(counting_iterator<Vertex>(v)), graph(graph) { }
- Vertex dereference() const
- {
- return graph->local_to_global_vertex(*(this->base_reference()));
- }
- friend class iterator_core_access;
- private:
- const self_type* graph;
- };
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline typename BOOST_DISTRIB_CSR_GRAPH_TYPE::degree_size_type
- num_vertices(const BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- {
- return num_vertices(g.base());
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline std::pair<typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_iterator,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_iterator>
- vertices(const BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- {
- typedef typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_iterator
- vertex_iterator;
- return std::make_pair(vertex_iterator(0, &g),
- vertex_iterator(num_vertices(g), &g));
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- class BOOST_DISTRIB_CSR_GRAPH_TYPE::edge_iterator
- {
- public:
- typedef std::forward_iterator_tag iterator_category;
- typedef edge_descriptor value_type;
- typedef const edge_descriptor* pointer;
- typedef edge_descriptor reference;
- typedef typename int_t<CHAR_BIT * sizeof(EdgeIndex)>::fast difference_type;
- edge_iterator() : graph(0), current_edge(), end_of_this_vertex(0) {}
- edge_iterator(const compressed_sparse_row_graph& graph,
- edge_descriptor current_edge,
- EdgeIndex end_of_this_vertex)
- : graph(&graph), local_src(current_edge.src), current_edge(current_edge),
- end_of_this_vertex(end_of_this_vertex)
- {
-
- current_edge.src = graph.local_to_global_vertex(current_edge.src);
- }
-
- reference operator*() const { return current_edge; }
- pointer operator->() const { return ¤t_edge; }
- bool operator==(const edge_iterator& o) const {
- return current_edge == o.current_edge;
- }
- bool operator!=(const edge_iterator& o) const {
- return current_edge != o.current_edge;
- }
- edge_iterator& operator++()
- {
- ++current_edge.idx;
- while (current_edge.idx == end_of_this_vertex && local_src < num_vertices(*graph)-1) {
- ++local_src;
- current_edge.src = graph->local_to_global_vertex(local_src);
- end_of_this_vertex = graph->base().m_forward.m_rowstart[local_src + 1];
- }
- return *this;
- }
- edge_iterator operator++(int) {
- edge_iterator temp = *this;
- ++*this;
- return temp;
- }
- private:
- const compressed_sparse_row_graph* graph;
- EdgeIndex local_src;
- edge_descriptor current_edge;
- EdgeIndex end_of_this_vertex;
- };
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline typename BOOST_DISTRIB_CSR_GRAPH_TYPE::edges_size_type
- num_edges(const BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- {
- return g.base().m_forward.m_column.size();
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- std::pair<typename BOOST_DISTRIB_CSR_GRAPH_TYPE::edge_iterator,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::edge_iterator>
- edges(const BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- {
- typedef typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor Vertex;
- typedef typename BOOST_DISTRIB_CSR_GRAPH_TYPE::edge_iterator ei;
- typedef typename BOOST_DISTRIB_CSR_GRAPH_TYPE::edge_descriptor edgedesc;
- if (g.base().m_forward.m_rowstart.size() == 1 ||
- g.base().m_forward.m_column.empty()) {
- return std::make_pair(ei(), ei());
- } else {
-
- Vertex src = 0;
- while (g.base().m_forward.m_rowstart[src + 1] == 0) ++src;
- return std::make_pair(ei(g, edgedesc(src, 0), g.base().m_forward.m_rowstart[src + 1]),
- ei(g, edgedesc(num_vertices(g), g.base().m_forward.m_column.size()), 0));
- }
- }
- template <typename OwnerMap, typename ProcessId>
- struct local_vertex {
- local_vertex(OwnerMap owner, ProcessId id)
- : owner(owner), id(id) {}
- template <typename Vertex>
- bool operator()(Vertex x)
- { return get(owner, x) == id; }
- template <typename Vertex>
- bool operator()(Vertex x) const
- { return get(owner, x) == id; }
- private:
- OwnerMap owner;
- ProcessId id;
- };
- template <typename OwnerMap, typename ProcessId>
- struct local_edge {
- local_edge(OwnerMap owner, ProcessId id)
- : owner(owner), id(id) {}
- template <typename Vertex>
- bool operator()(std::pair<Vertex, Vertex>& x)
- { return get(owner, x.first) == id; }
- template <typename Vertex>
- bool operator()(const std::pair<Vertex, Vertex>& x) const
- { return get(owner, x.first) == id; }
- private:
- OwnerMap owner;
- ProcessId id;
- };
- template<typename IndexIterator, typename Graph>
- class index_to_vertex_iterator {
-
- public:
- typedef std::input_iterator_tag iterator_category;
- typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
- typedef std::pair<Vertex, Vertex> value_type;
- typedef const value_type& reference;
- typedef const value_type* pointer;
- typedef void difference_type;
- index_to_vertex_iterator(IndexIterator index,
- const Graph& g)
- : index(index), g(g), current(to_edge(*index)) {}
- reference operator*() { current = to_edge(*index); return current; }
- pointer operator->() { current = to_edge(*index); return ¤t; }
- index_to_vertex_iterator& operator++()
- {
- ++index;
- return *this;
- }
- index_to_vertex_iterator operator++(int)
- {
- index_to_vertex_iterator temp(*this);
- ++(*this);
- return temp;
- }
- bool operator==(const index_to_vertex_iterator& other) const
- { return index == other.index; }
-
- bool operator!=(const index_to_vertex_iterator& other) const
- { return !(*this == other); }
- private:
- value_type to_edge(const typename std::iterator_traits<IndexIterator>::value_type& x)
- { return std::make_pair(vertex(x.first, g), vertex(x.second, g)); }
- IndexIterator index;
- const Graph& g;
- value_type current;
- };
- template <typename Distribution, typename Graph>
- struct index_to_vertex_func {
- typedef typename boost::graph_traits<Graph>::vertex_descriptor vertex_descriptor;
- typedef typename boost::graph_traits<Graph>::vertices_size_type vertices_size_type;
- typedef std::pair<vertex_descriptor, vertex_descriptor> result_type;
- typedef std::pair<vertices_size_type, vertices_size_type> base_iterator_type;
- index_to_vertex_func(const Distribution& dist, const Graph& g)
- : dist(dist), g(g) {}
- result_type operator()(const base_iterator_type& p) const
- {
- return std::make_pair(vertex(p.first, g), vertex(p.second, g));
- }
- private:
- const Distribution& dist;
- const Graph& g;
- };
- template <typename IndexIterator, typename Distribution, typename Graph>
- boost::transform_iterator<index_to_vertex_func<Distribution, Graph>, IndexIterator>
- make_index_to_vertex_iterator(IndexIterator it, const Distribution& dist,
- const Graph& g) {
- return boost::make_transform_iterator(
- it, index_to_vertex_func<Distribution, Graph>(dist, g));
- }
- template<typename ProcessID, typename Key> class csr_vertex_owner_map;
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- template<typename InputIterator>
- BOOST_DISTRIB_CSR_GRAPH_TYPE::
- compressed_sparse_row_graph(edges_are_unsorted_t,
- InputIterator edge_begin, InputIterator edge_end,
- vertices_size_type numverts,
- const ProcessGroup& pg,
- const GraphProperty& prop)
- : m_process_group(pg),
- m_distribution(parallel::block(m_process_group, numverts)),
- m_base(edges_are_unsorted_global,
- index_to_vertex_iterator<InputIterator, BOOST_DISTRIB_CSR_GRAPH_TYPE>(edge_begin, *this),
- index_to_vertex_iterator<InputIterator, BOOST_DISTRIB_CSR_GRAPH_TYPE>(edge_end, *this),
- m_distribution.block_size(process_id(m_process_group), numverts),
- get(vertex_local, *this),
- local_vertex<csr_vertex_owner_map<process_id_type, vertex_descriptor>,
- process_id_type> (get(vertex_owner, *this), process_id(pg)),
- prop)
- { }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- template <typename InputIterator, typename Distribution>
- BOOST_DISTRIB_CSR_GRAPH_TYPE::
- compressed_sparse_row_graph(edges_are_unsorted_t,
- InputIterator edge_begin, InputIterator edge_end,
- vertices_size_type numverts,
- const ProcessGroup& pg,
- const Distribution& dist,
- const GraphProperty& prop)
- : m_process_group(pg),
- m_distribution(dist),
- m_base(edges_are_unsorted_global,
- index_to_vertex_iterator<InputIterator, BOOST_DISTRIB_CSR_GRAPH_TYPE>(edge_begin, *this),
- index_to_vertex_iterator<InputIterator, BOOST_DISTRIB_CSR_GRAPH_TYPE>(edge_end, *this),
- m_distribution.block_size(process_id(m_process_group), numverts),
- get(vertex_local, *this),
- local_vertex<csr_vertex_owner_map<process_id_type, vertex_descriptor>,
- process_id_type> (get(vertex_owner, *this), process_id(pg)),
- prop)
- { }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- template<typename InputIterator, typename EdgePropertyIterator>
- BOOST_DISTRIB_CSR_GRAPH_TYPE::
- compressed_sparse_row_graph(edges_are_unsorted_t,
- InputIterator edge_begin, InputIterator edge_end,
- EdgePropertyIterator ep_iter,
- vertices_size_type numverts,
- const ProcessGroup& pg,
- const GraphProperty& prop)
- : m_process_group(pg),
- m_distribution(parallel::block(m_process_group, numverts)),
- m_base(edges_are_unsorted_global,
- index_to_vertex_iterator<InputIterator, BOOST_DISTRIB_CSR_GRAPH_TYPE>(edge_begin, *this),
- index_to_vertex_iterator<InputIterator, BOOST_DISTRIB_CSR_GRAPH_TYPE>(edge_end, *this),
- ep_iter,
- m_distribution.block_size(process_id(m_process_group), numverts),
- get(vertex_local, *this),
- local_vertex<csr_vertex_owner_map<process_id_type, vertex_descriptor>,
- process_id_type> (get(vertex_owner, *this), process_id(pg)),
- prop)
- { }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- template <typename InputIterator, typename EdgePropertyIterator,
- typename Distribution>
- BOOST_DISTRIB_CSR_GRAPH_TYPE::
- compressed_sparse_row_graph(edges_are_unsorted_t,
- InputIterator edge_begin, InputIterator edge_end,
- EdgePropertyIterator ep_iter,
- vertices_size_type numverts,
- const ProcessGroup& pg,
- const Distribution& dist,
- const GraphProperty& prop)
- : m_process_group(pg),
- m_distribution(dist),
- m_base(edges_are_unsorted_global,
- index_to_vertex_iterator<InputIterator, BOOST_DISTRIB_CSR_GRAPH_TYPE>(edge_begin, *this),
- index_to_vertex_iterator<InputIterator, BOOST_DISTRIB_CSR_GRAPH_TYPE>(edge_end, *this),
- ep_iter,
- m_distribution.block_size(process_id(m_process_group), numverts),
- get(vertex_local, *this),
- local_vertex<csr_vertex_owner_map<process_id_type, vertex_descriptor>,
- process_id_type> (get(vertex_owner, *this), process_id(pg)),
- prop)
- { }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- template<typename InputIterator>
- BOOST_DISTRIB_CSR_GRAPH_TYPE::
- compressed_sparse_row_graph(edges_are_sorted_t,
- InputIterator edge_begin, InputIterator edge_end,
- vertices_size_type numverts,
- edges_size_type numedges,
- const ProcessGroup& pg,
- const GraphProperty& prop)
- : m_process_group(pg),
- m_distribution(parallel::block(m_process_group, numverts)),
- m_base(edges_are_sorted_global,
- index_to_vertex_iterator<InputIterator, BOOST_DISTRIB_CSR_GRAPH_TYPE>(edge_begin, *this),
- index_to_vertex_iterator<InputIterator, BOOST_DISTRIB_CSR_GRAPH_TYPE>(edge_end, *this),
- get(vertex_local, *this),
- local_vertex<csr_vertex_owner_map<process_id_type, vertex_descriptor>,
- process_id_type> (get(vertex_owner, *this), process_id(pg)),
- m_distribution.block_size(process_id(m_process_group), numverts),
- prop)
- { }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- template <typename InputIterator, typename Distribution>
- BOOST_DISTRIB_CSR_GRAPH_TYPE::
- compressed_sparse_row_graph(edges_are_sorted_t,
- InputIterator edge_begin, InputIterator edge_end,
- vertices_size_type numverts,
- const ProcessGroup& pg,
- const Distribution& dist,
- const GraphProperty& prop)
- : m_process_group(pg),
- m_distribution(dist),
- m_base(edges_are_sorted_global,
- index_to_vertex_iterator<InputIterator, BOOST_DISTRIB_CSR_GRAPH_TYPE>(edge_begin, *this),
- index_to_vertex_iterator<InputIterator, BOOST_DISTRIB_CSR_GRAPH_TYPE>(edge_end, *this),
- get(vertex_local, *this),
- local_vertex<csr_vertex_owner_map<process_id_type, vertex_descriptor>,
- process_id_type> (get(vertex_owner, *this), process_id(pg)),
- m_distribution.block_size(process_id(m_process_group), numverts),
- prop)
- { }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- template<typename InputIterator, typename EdgePropertyIterator>
- BOOST_DISTRIB_CSR_GRAPH_TYPE::
- compressed_sparse_row_graph(edges_are_sorted_t,
- InputIterator edge_begin, InputIterator edge_end,
- EdgePropertyIterator ep_iter,
- vertices_size_type numverts,
- edges_size_type numedges,
- const ProcessGroup& pg,
- const GraphProperty& prop)
- : m_process_group(pg),
- m_distribution(parallel::block(m_process_group, numverts)),
- m_base(edges_are_sorted_global,
- index_to_vertex_iterator<InputIterator, BOOST_DISTRIB_CSR_GRAPH_TYPE>(edge_begin, *this),
- index_to_vertex_iterator<InputIterator, BOOST_DISTRIB_CSR_GRAPH_TYPE>(edge_end, *this),
- ep_iter,
- get(vertex_local, *this),
- local_vertex<csr_vertex_owner_map<process_id_type, vertex_descriptor>,
- process_id_type> (get(vertex_owner, *this), process_id(pg)),
- m_distribution.block_size(process_id(m_process_group), numverts),
- prop)
- { }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- template<typename InputIterator, typename EdgePropertyIterator,
- typename Distribution>
- BOOST_DISTRIB_CSR_GRAPH_TYPE::
- compressed_sparse_row_graph(edges_are_sorted_t,
- InputIterator edge_begin, InputIterator edge_end,
- EdgePropertyIterator ep_iter,
- vertices_size_type numverts,
- const ProcessGroup& pg,
- const Distribution& dist,
- const GraphProperty& prop)
- : m_process_group(pg),
- m_distribution(dist),
- m_base(edges_are_sorted_global,
- index_to_vertex_iterator<InputIterator, BOOST_DISTRIB_CSR_GRAPH_TYPE>(edge_begin, *this),
- index_to_vertex_iterator<InputIterator, BOOST_DISTRIB_CSR_GRAPH_TYPE>(edge_end, *this),
- ep_iter,
- get(vertex_local, *this),
- local_vertex<csr_vertex_owner_map<process_id_type, vertex_descriptor>,
- process_id_type> (get(vertex_owner, *this), process_id(pg)),
- m_distribution.block_size(process_id(m_process_group), numverts),
- prop)
- { }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- template<typename MultiPassInputIterator>
- BOOST_DISTRIB_CSR_GRAPH_TYPE::
- compressed_sparse_row_graph(edges_are_unsorted_multi_pass_t,
- MultiPassInputIterator edge_begin,
- MultiPassInputIterator edge_end,
- vertices_size_type numverts,
- const ProcessGroup& pg,
- const GraphProperty& prop)
- : m_process_group(pg),
- m_distribution(parallel::block(m_process_group, numverts)),
- m_base(edges_are_unsorted_multi_pass_global,
- make_index_to_vertex_iterator(edge_begin, parallel::block(m_process_group, numverts), *this),
- make_index_to_vertex_iterator(edge_end, parallel::block(m_process_group, numverts), *this),
- m_distribution.block_size(process_id(m_process_group), numverts),
- get(vertex_local, *this),
- local_vertex<csr_vertex_owner_map<process_id_type, vertex_descriptor>,
- process_id_type> (get(vertex_owner, *this), process_id(pg)),
- prop)
- { }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- template <typename MultiPassInputIterator, typename Distribution>
- BOOST_DISTRIB_CSR_GRAPH_TYPE::
- compressed_sparse_row_graph(edges_are_unsorted_multi_pass_t,
- MultiPassInputIterator edge_begin,
- MultiPassInputIterator edge_end,
- vertices_size_type numverts,
- const ProcessGroup& pg,
- const Distribution& dist,
- const GraphProperty& prop)
- : m_process_group(pg),
- m_distribution(dist),
- m_base(edges_are_unsorted_multi_pass_global,
- make_index_to_vertex_iterator(edge_begin, parallel::block(m_process_group, numverts), *this),
- make_index_to_vertex_iterator(edge_end, parallel::block(m_process_group, numverts), *this),
- m_distribution.block_size(process_id(m_process_group), numverts),
- get(vertex_local, *this),
- local_vertex<csr_vertex_owner_map<process_id_type, vertex_descriptor>,
- process_id_type> (get(vertex_owner, *this), process_id(pg)),
- prop)
- { }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- template<typename MultiPassInputIterator, typename EdgePropertyIterator>
- BOOST_DISTRIB_CSR_GRAPH_TYPE::
- compressed_sparse_row_graph(edges_are_unsorted_multi_pass_t,
- MultiPassInputIterator edge_begin,
- MultiPassInputIterator edge_end,
- EdgePropertyIterator ep_iter,
- vertices_size_type numverts,
- const ProcessGroup& pg,
- const GraphProperty& prop)
- : m_process_group(pg),
- m_distribution(parallel::block(m_process_group, numverts)),
- m_base(edges_are_unsorted_multi_pass_global,
- make_index_to_vertex_iterator(edge_begin, parallel::block(m_process_group, numverts), *this),
- make_index_to_vertex_iterator(edge_end, parallel::block(m_process_group, numverts), *this),
- ep_iter,
- m_distribution.block_size(process_id(m_process_group), numverts),
- get(vertex_local, *this),
- local_vertex<csr_vertex_owner_map<process_id_type, vertex_descriptor>,
- process_id_type> (get(vertex_owner, *this), process_id(pg)),
- prop)
- { }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- template <typename MultiPassInputIterator, typename EdgePropertyIterator,
- typename Distribution>
- BOOST_DISTRIB_CSR_GRAPH_TYPE::
- compressed_sparse_row_graph(edges_are_unsorted_multi_pass_t,
- MultiPassInputIterator edge_begin,
- MultiPassInputIterator edge_end,
- EdgePropertyIterator ep_iter,
- vertices_size_type numverts,
- const ProcessGroup& pg,
- const Distribution& dist,
- const GraphProperty& prop)
- : m_process_group(pg),
- m_distribution(dist),
- m_base(edges_are_unsorted_multi_pass_global,
- make_index_to_vertex_iterator(edge_begin, parallel::block(m_process_group, numverts), *this),
- make_index_to_vertex_iterator(edge_end, parallel::block(m_process_group, numverts), *this),
- ep_iter,
- m_distribution.block_size(process_id(m_process_group), numverts),
- get(vertex_local, *this),
- local_vertex<csr_vertex_owner_map<process_id_type, vertex_descriptor>,
- process_id_type> (get(vertex_owner, *this), process_id(pg)),
- prop)
- { }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- template<typename Source>
- BOOST_DISTRIB_CSR_GRAPH_TYPE::
- compressed_sparse_row_graph(distributed_construct_inplace_from_sources_and_targets_t,
- std::vector<Source>& sources,
- std::vector<vertex_descriptor>& targets,
- vertices_size_type numverts,
- const ProcessGroup& pg,
- const GraphProperty& prop)
- : m_process_group(pg),
- m_distribution(parallel::block(m_process_group, numverts)),
- m_base(m_distribution.block_size(process_id(m_process_group), numverts))
- {
-
- for (edges_size_type i = 0; i < sources.size(); ++i) {
- sources[i] = m_distribution.local(sources[i]);
- targets[i] = make_vertex_descriptor(m_distribution(targets[i]),
- m_distribution.local(targets[i]));
- }
- m_base.assign_sources_and_targets_global(
- sources, targets, m_distribution.block_size(process_id(m_process_group), numverts),
- identity_property_map());
-
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- template <typename Distribution, typename Source>
- BOOST_DISTRIB_CSR_GRAPH_TYPE::
- compressed_sparse_row_graph(distributed_construct_inplace_from_sources_and_targets_t,
- std::vector<Source>& sources,
- std::vector<vertex_descriptor>& targets,
- vertices_size_type numverts,
- const ProcessGroup& pg,
- const Distribution& dist,
- const GraphProperty& prop)
- : m_process_group(pg),
- m_distribution(dist),
- m_base(m_distribution.block_size(process_id(m_process_group), numverts))
- {
-
- for (edges_size_type i = 0; i < sources.size(); ++i) {
- sources[i] = m_distribution.local(sources[i]);
- targets[i] = make_vertex_descriptor(m_distribution(targets[i]),
- m_distribution.local(targets[i]));
- }
- m_base.assign_sources_and_targets_global(
- sources, targets, m_distribution.block_size(process_id(m_process_group), numverts),
- identity_property_map());
-
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- template<typename Source>
- BOOST_DISTRIB_CSR_GRAPH_TYPE::
- compressed_sparse_row_graph(distributed_construct_inplace_from_sources_and_targets_t,
- std::vector<Source>& sources,
- std::vector<vertex_descriptor>& targets,
- std::vector<edge_bundled>& edge_props,
- vertices_size_type numverts,
- const ProcessGroup& pg,
- const GraphProperty& prop)
- : m_process_group(pg),
- m_distribution(parallel::block(m_process_group, numverts)),
- m_base(m_distribution.block_size(process_id(m_process_group), numverts))
- {
-
- for (edges_size_type i = 0; i < sources.size(); ++i) {
- sources[i] = m_distribution.local(sources[i]);
- targets[i] = make_vertex_descriptor(m_distribution(targets[i]),
- m_distribution.local(targets[i]));
- }
- m_base.assign_sources_and_targets_global(
- sources, targets, edge_props,
- m_distribution.block_size(process_id(m_process_group), numverts),
- identity_property_map());
-
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- template <typename Distribution, typename Source>
- BOOST_DISTRIB_CSR_GRAPH_TYPE::
- compressed_sparse_row_graph(distributed_construct_inplace_from_sources_and_targets_t,
- std::vector<Source>& sources,
- std::vector<vertex_descriptor>& targets,
- std::vector<edge_bundled>& edge_props,
- vertices_size_type numverts,
- const ProcessGroup& pg,
- const Distribution& dist,
- const GraphProperty& prop)
- : m_process_group(pg),
- m_distribution(dist),
- m_base(m_distribution.block_size(process_id(m_process_group), numverts))
- {
-
- for (edges_size_type i = 0; i < sources.size(); ++i) {
- sources[i] = m_distribution.local(sources[i]);
- targets[i] = make_vertex_descriptor(m_distribution(targets[i]),
- m_distribution.local(targets[i]));
- }
- m_base.assign_sources_and_targets_global(
- sources, targets, edge_props,
- m_distribution.block_size(process_id(m_process_group), numverts),
- identity_property_map());
-
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- template<typename InputIterator>
- BOOST_DISTRIB_CSR_GRAPH_TYPE::
- compressed_sparse_row_graph(InputIterator edge_begin, InputIterator edge_end,
- vertices_size_type numverts,
- const ProcessGroup& pg,
- const GraphProperty& prop)
- : m_process_group(pg),
- m_distribution(parallel::block(m_process_group, numverts)),
- m_base(edges_are_unsorted_global,
- index_to_vertex_iterator<InputIterator, BOOST_DISTRIB_CSR_GRAPH_TYPE>(edge_begin, *this),
- index_to_vertex_iterator<InputIterator, BOOST_DISTRIB_CSR_GRAPH_TYPE>(edge_end, *this),
- m_distribution.block_size(process_id(m_process_group), numverts),
- get(vertex_local, *this),
- local_vertex<csr_vertex_owner_map<process_id_type, vertex_descriptor>,
- process_id_type> (get(vertex_owner, *this), process_id(pg)),
- prop)
-
- {
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- template<typename InputIterator, typename EdgePropertyIterator>
- BOOST_DISTRIB_CSR_GRAPH_TYPE::
- compressed_sparse_row_graph(InputIterator edge_begin, InputIterator edge_end,
- EdgePropertyIterator ep_iter,
- vertices_size_type numverts,
- const ProcessGroup& pg,
- const GraphProperty& prop)
- : m_process_group(pg),
- m_distribution(parallel::block(m_process_group, numverts)),
- m_base(edges_are_unsorted_global,
- index_to_vertex_iterator<InputIterator, BOOST_DISTRIB_CSR_GRAPH_TYPE>(edge_begin, *this),
- index_to_vertex_iterator<InputIterator, BOOST_DISTRIB_CSR_GRAPH_TYPE>(edge_end, *this),
- ep_iter,
- m_distribution.block_size(process_id(m_process_group), numverts),
- get(vertex_local, *this),
- local_vertex<csr_vertex_owner_map<process_id_type, vertex_descriptor>,
- process_id_type> (get(vertex_owner, *this), process_id(pg)),
- prop)
- {
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- template<typename InputIterator, typename Distribution>
- BOOST_DISTRIB_CSR_GRAPH_TYPE::
- compressed_sparse_row_graph(InputIterator edge_begin, InputIterator edge_end,
- vertices_size_type numverts,
- const ProcessGroup& pg,
- const Distribution& dist,
- const GraphProperty& prop)
- : m_process_group(pg),
- m_distribution(dist),
- m_base(edges_are_unsorted_global,
- index_to_vertex_iterator<InputIterator, BOOST_DISTRIB_CSR_GRAPH_TYPE>(edge_begin, *this),
- index_to_vertex_iterator<InputIterator, BOOST_DISTRIB_CSR_GRAPH_TYPE>(edge_end, *this),
- m_distribution.block_size(process_id(m_process_group), numverts),
- get(vertex_local, *this),
- local_vertex<csr_vertex_owner_map<process_id_type, vertex_descriptor>,
- process_id_type> (get(vertex_owner, *this), process_id(pg)),
- prop)
- {
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- template<typename InputIterator, typename EdgePropertyIterator,
- typename Distribution>
- BOOST_DISTRIB_CSR_GRAPH_TYPE::
- compressed_sparse_row_graph(InputIterator edge_begin, InputIterator edge_end,
- EdgePropertyIterator ep_iter,
- vertices_size_type numverts,
- const ProcessGroup& pg,
- const Distribution& dist,
- const GraphProperty& prop)
- : m_process_group(pg),
- m_distribution(dist),
- m_base(edges_are_unsorted_global,
- index_to_vertex_iterator<InputIterator, BOOST_DISTRIB_CSR_GRAPH_TYPE>(edge_begin, *this),
- index_to_vertex_iterator<InputIterator, BOOST_DISTRIB_CSR_GRAPH_TYPE>(edge_end, *this),
- m_distribution.block_size(process_id(m_process_group), numverts),
- get(vertex_local, *this),
- local_vertex<csr_vertex_owner_map<process_id_type, vertex_descriptor>,
- process_id_type> (get(vertex_owner, *this), process_id(pg)),
- prop)
- {
- }
- template<typename ProcessID, typename Key>
- class csr_vertex_global_map
- {
- public:
-
-
- typedef std::pair<ProcessID, Key> value_type;
- typedef value_type reference;
- typedef Key key_type;
- typedef readable_property_map_tag category;
- };
- template<typename ProcessID, typename Key>
- inline std::pair<ProcessID, Key>
- get(csr_vertex_global_map<ProcessID, Key>,
- typename csr_vertex_global_map<ProcessID, Key>::key_type k)
- {
- const int local_index_bits = sizeof(Key) * CHAR_BIT - processor_bits;
- const Key local_index_mask = Key(-1) >> processor_bits;
- return std::pair<ProcessID, Key>(k >> local_index_bits,
- k & local_index_mask);
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- class property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, vertex_global_t>
- {
- public:
- typedef csr_vertex_global_map<
- typename ProcessGroup::process_id_type,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor> type;
- typedef type const_type;
- };
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline
- typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, vertex_global_t>::type
- get(vertex_global_t, BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- {
- typedef typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, vertex_global_t>
- ::type result_type;
- return result_type();
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline
- std::pair<typename ProcessGroup::process_id_type,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor>
- get(vertex_global_t, BOOST_DISTRIB_CSR_GRAPH_TYPE& g,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor k)
- {
- return get(vertex_global,
- const_cast<const BOOST_DISTRIB_CSR_GRAPH_TYPE&>(g),
- k);
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline
- typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, vertex_global_t>::const_type
- get(vertex_global_t, const BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- {
- typedef typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, vertex_global_t>
- ::const_type result_type;
- return result_type();
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline
- std::pair<typename ProcessGroup::process_id_type,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor>
- get(vertex_global_t, const BOOST_DISTRIB_CSR_GRAPH_TYPE& g,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor k)
- {
- typedef typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor
- vertex_descriptor;
- typedef std::pair<typename ProcessGroup::process_id_type, vertex_descriptor>
- result_type;
- const int local_index_bits =
- sizeof(vertex_descriptor) * CHAR_BIT - processor_bits;
- const vertex_descriptor local_index_mask =
- vertex_descriptor(-1) >> processor_bits;
- return result_type(k >> local_index_bits, k & local_index_mask);
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor
- vertex(typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertices_size_type i,
- const BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- {
- return g.make_vertex_descriptor(g.distribution()(i),
- g.distribution().local(i));
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline std::pair<typename BOOST_DISTRIB_CSR_GRAPH_TYPE::out_edge_iterator,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::out_edge_iterator>
- edge_range(typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor i,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor j,
- const BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- {
- typedef typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor Vertex;
- typedef typename BOOST_DISTRIB_CSR_GRAPH_TYPE::edges_size_type EdgeIndex;
- typedef typename std::vector<Vertex>::const_iterator adj_iter;
- typedef typename BOOST_DISTRIB_CSR_GRAPH_TYPE::out_edge_iterator out_edge_iter;
- typedef typename BOOST_DISTRIB_CSR_GRAPH_TYPE::edge_descriptor edge_desc;
- std::pair<adj_iter, adj_iter> raw_adjacencies = adjacent_vertices(i, g);
- std::pair<adj_iter, adj_iter> adjacencies =
- std::equal_range(raw_adjacencies.first, raw_adjacencies.second, j);
- EdgeIndex idx_begin = adjacencies.first - g.base().m_forward.m_column.begin();
- EdgeIndex idx_end = adjacencies.second - g.base().m_forward.m_column.begin();
- return std::make_pair(out_edge_iter(edge_desc(i, idx_begin)),
- out_edge_iter(edge_desc(i, idx_end)));
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline std::pair<typename BOOST_DISTRIB_CSR_GRAPH_TYPE::edge_descriptor, bool>
- edge(typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor i,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor j,
- const BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- {
- typedef typename BOOST_DISTRIB_CSR_GRAPH_TYPE::out_edge_iterator out_edge_iter;
- std::pair<out_edge_iter, out_edge_iter> range = edge_range(i, j, g);
- if (range.first == range.second)
- return std::make_pair(typename BOOST_DISTRIB_CSR_GRAPH_TYPE::edge_descriptor(),
- false);
- else
- return std::make_pair(*range.first, true);
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS, typename Property>
- class property_map<const BOOST_DISTRIB_CSR_GRAPH_TYPE, Property>
- {
- public:
- typedef typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, Property>
- ::const_type type;
- typedef type const_type;
- };
- #if 0
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor
- add_vertex(BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- { return g.add_vertex(); }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor
- add_vertex(const typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_bundled& p,
- BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- { return g.add_vertex(p); }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor
- add_vertices(typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertices_size_type count,
- BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- { return g.add_vertices(count); }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS, typename InputIterator>
- void
- add_edges(InputIterator first, InputIterator last,
- BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- { g.add_edges(first, last); }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS, typename InputIterator,
- typename EdgePropertyIterator>
- void
- add_edges(InputIterator first, InputIterator last,
- EdgePropertyIterator ep_iter,
- EdgePropertyIterator ep_iter_end,
- BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- { return g.add_edges(first, last, ep_iter, ep_iter_end); }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS, typename InputIterator>
- void
- add_edges_sorted(InputIterator first, InputIterator last,
- BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- { return g.add_edges_sorted(first, last); }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS, typename InputIterator,
- typename EdgePropertyIterator>
- void
- add_edges_sorted(InputIterator first_sorted, InputIterator last_sorted,
- EdgePropertyIterator ep_iter_sorted,
- BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- { g.add_edges_sorted(first_sorted, last_sorted, ep_iter_sorted); }
- #endif
- template<typename ProcessID, typename Key>
- class csr_vertex_owner_map
- {
- public:
-
-
- typedef ProcessID value_type;
- typedef value_type reference;
- typedef Key key_type;
- typedef readable_property_map_tag category;
- };
- template<typename ProcessID, typename Key>
- inline ProcessID
- get(csr_vertex_owner_map<ProcessID, Key> pm,
- typename csr_vertex_owner_map<ProcessID, Key>::key_type k)
- {
- const int local_index_bits = sizeof(Key) * CHAR_BIT - processor_bits;
- return k >> local_index_bits;
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- class property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, vertex_owner_t>
- {
- public:
- typedef csr_vertex_owner_map<
- typename ProcessGroup::process_id_type,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor> type;
- typedef type const_type;
- };
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline
- typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, vertex_owner_t>::type
- get(vertex_owner_t, BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- {
- typedef typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, vertex_owner_t>
- ::type result_type;
- return result_type();
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline typename ProcessGroup::process_id_type
- get(vertex_owner_t, BOOST_DISTRIB_CSR_GRAPH_TYPE& g,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor k)
- {
- return get(vertex_owner,
- const_cast<const BOOST_DISTRIB_CSR_GRAPH_TYPE&>(g),
- k);
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline
- typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, vertex_owner_t>::const_type
- get(vertex_owner_t, const BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- {
- typedef typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, vertex_owner_t>
- ::const_type result_type;
- return result_type();
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline typename ProcessGroup::process_id_type
- get(vertex_owner_t, const BOOST_DISTRIB_CSR_GRAPH_TYPE& g,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor k)
- {
- typedef typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor
- vertex_descriptor;
- const int local_index_bits =
- sizeof(vertex_descriptor) * CHAR_BIT - processor_bits;
- return k >> local_index_bits;
- }
- template<typename Key>
- class csr_vertex_local_map
- {
- public:
-
-
- typedef Key value_type;
- typedef value_type reference;
- typedef Key key_type;
- typedef readable_property_map_tag category;
- };
- template<typename Key>
- inline Key
- get(csr_vertex_local_map<Key> pm,
- typename csr_vertex_local_map<Key>::key_type k)
- {
- const Key local_index_mask = Key(-1) >> processor_bits;
- return k & local_index_mask;
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- class property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, vertex_local_t>
- {
- public:
- typedef csr_vertex_local_map<
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor> type;
- typedef type const_type;
- };
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline
- typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, vertex_local_t>::type
- get(vertex_local_t, BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- {
- typedef typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, vertex_local_t>
- ::type result_type;
- return result_type();
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor
- get(vertex_local_t, BOOST_DISTRIB_CSR_GRAPH_TYPE& g,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor k)
- {
- return get(vertex_local,
- const_cast<const BOOST_DISTRIB_CSR_GRAPH_TYPE&>(g),
- k);
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline
- typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, vertex_local_t>::const_type
- get(vertex_local_t, const BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- {
- typedef typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, vertex_local_t>
- ::const_type result_type;
- return result_type();
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor
- get(vertex_local_t, const BOOST_DISTRIB_CSR_GRAPH_TYPE& g,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor k)
- {
- typedef typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor
- vertex_descriptor;
- const vertex_descriptor local_index_mask =
- vertex_descriptor(-1) >> processor_bits;
- return k & local_index_mask;
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- class property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, vertex_index_t>
- {
- typedef typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE,
- vertex_global_t>::const_type
- global_map;
- typedef typename BOOST_DISTRIB_CSR_GRAPH_TYPE::process_group_type
- process_group_type;
- typedef property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, vertex_local_t> local;
- public:
- typedef local_property_map<process_group_type,
- global_map,
- typename local::type> type;
- typedef local_property_map<process_group_type,
- global_map,
- typename local::const_type> const_type;
- };
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline
- typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, vertex_index_t>::type
- get(vertex_index_t, BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- {
- typedef typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, vertex_index_t>
- ::type result_type;
- return result_type(g.process_group(), get(vertex_global, g),
- get(vertex_local, g));
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertices_size_type
- get(vertex_index_t, BOOST_DISTRIB_CSR_GRAPH_TYPE& g,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor k)
- {
- return get(vertex_local, g, k);
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline
- typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, vertex_index_t>::const_type
- get(vertex_index_t, const BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- {
- typedef typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, vertex_index_t>
- ::const_type result_type;
- return result_type(g.process_group(), get(vertex_global, g),
- get(vertex_local, g));
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertices_size_type
- get(vertex_index_t, const BOOST_DISTRIB_CSR_GRAPH_TYPE& g,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor k)
- {
- return get(vertex_local, g, k);
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- class property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, vertex_local_index_t>
- : public property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, vertex_local_t> { };
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline
- typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, vertex_local_index_t>::type
- get(vertex_local_index_t, BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- {
- return get(vertex_local, g);
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertices_size_type
- get(vertex_local_index_t, BOOST_DISTRIB_CSR_GRAPH_TYPE& g,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor k)
- {
- return get(vertex_local, g, k);
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline
- typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, vertex_local_index_t>::const_type
- get(vertex_local_index_t, const BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- {
- return get(vertex_local, g);
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertices_size_type
- get(vertex_local_index_t, const BOOST_DISTRIB_CSR_GRAPH_TYPE& g,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor k)
- {
- return get(vertex_local, g, k);
- }
- template<typename ProcessID, typename Vertex, typename EdgeIndex>
- class csr_edge_global_map
- {
- public:
-
-
- typedef detail::csr_edge_descriptor<Vertex, EdgeIndex> key_type;
- typedef std::pair<ProcessID, detail::csr_edge_descriptor<Vertex, EdgeIndex> > value_type;
- typedef value_type reference;
- typedef readable_property_map_tag category;
- };
- template<typename ProcessID, typename Vertex, typename EdgeIndex>
- inline std::pair<ProcessID, detail::csr_edge_descriptor<Vertex, EdgeIndex> >
- get(csr_edge_global_map<ProcessID, Vertex, EdgeIndex> pm,
- typename csr_edge_global_map<ProcessID, Vertex, EdgeIndex>::key_type k)
- {
- const int local_index_bits = sizeof(Vertex) * CHAR_BIT - processor_bits;
- const Vertex local_index_mask = Vertex(-1) >> processor_bits;
- return std::pair<ProcessID, detail::csr_edge_descriptor<Vertex, EdgeIndex> >
- ((k.src >> local_index_bits),
- detail::csr_edge_descriptor<Vertex, EdgeIndex>(k.src & local_index_mask, k.idx));
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- class property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, edge_global_t>
- {
- public:
- typedef csr_edge_global_map<
- typename ProcessGroup::process_id_type,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::edges_size_type> type;
- typedef type const_type;
- };
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline
- typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, edge_global_t>::type
- get(edge_global_t, BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- {
- typedef typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, edge_global_t>
- ::type result_type;
- return result_type();
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline
- std::pair<typename ProcessGroup::process_id_type,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::base_type::edge_descriptor>
- get(edge_global_t, BOOST_DISTRIB_CSR_GRAPH_TYPE& g,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::edge_descriptor k)
- {
- return get(edge_global,
- const_cast<const BOOST_DISTRIB_CSR_GRAPH_TYPE&>(g),
- k);
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline
- typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, edge_global_t>::const_type
- get(edge_global_t, const BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- {
- typedef typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, edge_global_t>
- ::const_type result_type;
- return result_type();
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline
- std::pair<typename ProcessGroup::process_id_type,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::base_type::edge_descriptor>
- get(edge_global_t, const BOOST_DISTRIB_CSR_GRAPH_TYPE& g,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::edge_descriptor k)
- {
- typedef typename BOOST_DISTRIB_CSR_GRAPH_TYPE::vertex_descriptor
- vertex_descriptor;
- const int local_index_bits =
- sizeof(vertex_descriptor) * CHAR_BIT - processor_bits;
- const typename BOOST_DISTRIB_CSR_GRAPH_TYPE::edges_size_type local_index_mask =
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::edges_size_type(-1) >> processor_bits;
-
- typedef std::pair<typename ProcessGroup::process_id_type,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::base_type::edge_descriptor>
- result_type;
- return result_type(k.src >> local_index_bits,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::base_type::edge_descriptor
- (k.src & local_index_mask, k.idx));
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- class property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, edge_index_t>
- {
- typedef typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, edge_global_t>
- ::type global_map;
- public:
- typedef local_property_map<
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::process_group_type,
- global_map,
- typename property_map<typename BOOST_DISTRIB_CSR_GRAPH_TYPE::base_type, edge_index_t>::type
- > type;
- typedef type const_type;
- };
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline
- typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, edge_index_t>::type
- get(edge_index_t, BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- {
- typedef typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, edge_index_t>
- ::type result_type;
- return result_type(g.process_group(), get(edge_global, g),
- get(edge_index, g.base()));
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline typename BOOST_DISTRIB_CSR_GRAPH_TYPE::edges_size_type
- get(edge_index_t, BOOST_DISTRIB_CSR_GRAPH_TYPE& g,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::edge_descriptor k)
- {
- return k.idx;
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline
- typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, edge_index_t>::const_type
- get(edge_index_t, const BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- {
- typedef typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, edge_index_t>
- ::const_type result_type;
- return result_type(g.process_group(), get(edge_global, g),
- get(edge_index, g.base()));
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS>
- inline typename BOOST_DISTRIB_CSR_GRAPH_TYPE::edges_size_type
- get(edge_index_t, const BOOST_DISTRIB_CSR_GRAPH_TYPE& g,
- typename BOOST_DISTRIB_CSR_GRAPH_TYPE::edge_descriptor k)
- {
- return k.idx;
- }
- template <BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS, typename Tag>
- class property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, Tag> {
- typedef BOOST_DISTRIB_CSR_GRAPH_TYPE graph_type;
- typedef typename graph_type::process_group_type process_group_type;
- typedef typename graph_type::base_type base_graph_type;
- typedef typename property_map<base_graph_type, Tag>::type
- local_pmap;
- typedef typename property_map<base_graph_type, Tag>::const_type
- local_const_pmap;
- typedef graph_traits<graph_type> traits;
- typedef typename graph_traits<base_graph_type>::vertex_descriptor local_vertex;
- typedef typename property_traits<local_pmap>::key_type local_key_type;
- typedef typename property_traits<local_pmap>::value_type value_type;
- typedef typename property_map<graph_type, vertex_global_t>::const_type
- vertex_global_map;
- typedef typename property_map<graph_type, edge_global_t>::const_type
- edge_global_map;
- typedef typename mpl::if_<is_same<typename detail::property_kind_from_graph<base_graph_type, Tag>::type,
- vertex_property_tag>,
- vertex_global_map, edge_global_map>::type
- global_map;
- public:
- typedef ::boost::parallel::distributed_property_map<
- process_group_type, global_map, local_pmap> type;
- typedef ::boost::parallel::distributed_property_map<
- process_group_type, global_map, local_const_pmap> const_type;
- };
- template <BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS, typename Tag>
- typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, Tag>::type
- get(Tag tag, BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- {
- typedef BOOST_DISTRIB_CSR_GRAPH_TYPE Graph;
- typedef typename property_map<Graph, Tag>::type result_type;
- typedef typename property_traits<result_type>::value_type value_type;
- typedef typename property_reduce<Tag>::template apply<value_type>
- reduce;
- typedef typename mpl::if_<is_same<typename detail::property_kind_from_graph<Graph, Tag>::type,
- vertex_property_tag>,
- vertex_global_t, edge_global_t>::type
- global_map_t;
- return result_type(g.process_group(), get(global_map_t(), g),
- get(tag, g.base()), reduce());
- }
- template<BOOST_DISTRIB_CSR_GRAPH_TEMPLATE_PARMS, typename Tag>
- typename property_map<BOOST_DISTRIB_CSR_GRAPH_TYPE, Tag>::const_type
- get(Tag tag, const BOOST_DISTRIB_CSR_GRAPH_TYPE& g)
- {
- typedef BOOST_DISTRIB_CSR_GRAPH_TYPE Graph;
- typedef typename property_map<Graph, Tag>::const_type result_type;
- typedef typename property_traits<result_type>::value_type value_type;
- typedef typename property_reduce<Tag>::template apply<value_type>
- reduce;
- typedef typename property_traits<result_type>::key_type descriptor;
- typedef typename graph_traits<Graph>::vertex_descriptor vertex_descriptor;
- typedef typename mpl::if_<is_same<descriptor, vertex_descriptor>,
- vertex_global_t, edge_global_t>::type
- global_map_t;
- return result_type(g.process_group(), get(global_map_t(), g),
- get(tag, g.base()), reduce());
- }
- namespace mpi {
- template<typename Vertex, typename EdgeIndex>
- struct is_mpi_datatype<boost::detail::csr_edge_descriptor<Vertex, EdgeIndex> >
- : mpl::true_ { };
- }
- namespace serialization {
- template<typename Vertex, typename EdgeIndex>
- struct is_bitwise_serializable<boost::detail::csr_edge_descriptor<Vertex, EdgeIndex> >
- : mpl::true_ { };
- template<typename Vertex, typename EdgeIndex>
- struct implementation_level<boost::detail::csr_edge_descriptor<Vertex, EdgeIndex> >
- : mpl::int_<object_serializable> {} ;
- template<typename Vertex, typename EdgeIndex>
- struct tracking_level<boost::detail::csr_edge_descriptor<Vertex, EdgeIndex> >
- : mpl::int_<track_never> {} ;
- }
- }
- #endif
|