26 #ifndef GALOIS_GRAPHS_MORPHGRAPH_H 
   27 #define GALOIS_GRAPHS_MORPHGRAPH_H 
   32 #include <type_traits> 
   35 #include <boost/container/small_vector.hpp> 
   36 #include <boost/functional.hpp> 
   37 #include <boost/iterator/transform_iterator.hpp> 
   38 #include <boost/iterator/filter_iterator.hpp> 
   39 #include <boost/container/small_vector.hpp> 
   42 #include "galois/config.h" 
   62 template <
typename NTy, 
typename ETy, 
bool DirectedButNotInOut>
 
   65 template <
typename NTy, 
typename ETy>
 
   66 struct UEdgeInfoBase<NTy, ETy, true> {
 
   67   typedef ETy& reference;
 
   76   inline const NTy* first()
 const {
 
   80   inline ETy* second() { 
return &Ea; }
 
   81   inline const ETy* second()
 const { 
return &Ea; }
 
   83   template <
typename... Args>
 
   84   UEdgeInfoBase(NTy* n, ETy*, 
bool, Args&&... args)
 
   85       : N(n), Ea(std::forward<Args>(args)...) {}
 
   87   template <
typename... Args>
 
   88   UEdgeInfoBase(NTy* n, ETy& v, 
bool, Args&&...) : N(n) {
 
   92   static size_t sizeOfSecond() { 
return sizeof(ETy); }
 
   93   bool isInEdge()
 const { 
return false; }
 
   96 template <
typename NTy, 
typename ETy>
 
   97 struct UEdgeInfoBase<NTy, ETy, false> {
 
   98   typedef ETy& reference;
 
  103   inline NTy* first() {
 
  105     return (NTy*)((uintptr_t)N & ~1);
 
  107   inline const NTy* first()
 const {
 
  109     return (NTy*)((uintptr_t)N & ~1);
 
  111   inline ETy* second() { 
return Ea; }
 
  112   inline const ETy* second()
 const { 
return Ea; }
 
  113   template <
typename... Args>
 
  114   UEdgeInfoBase(NTy* n, ETy* v, 
bool f, Args&&...)
 
  115       : N((NTy*)((uintptr_t)n | f)), Ea(v) {}
 
  116   static size_t sizeOfSecond() { 
return sizeof(ETy); }
 
  117   bool isInEdge()
 const { 
return (uintptr_t)N & 1; }
 
  120 template <
typename NTy>
 
  121 struct UEdgeInfoBase<NTy, void, true> {
 
  122   typedef char& reference;
 
  125   inline NTy* first() { 
return N; }
 
  126   inline const NTy* first()
 const { 
return N; }
 
  127   inline char* second()
 const { 
return static_cast<char*
>(NULL); }
 
  128   inline char* addr()
 const { 
return second(); }
 
  129   template <
typename... Args>
 
  130   UEdgeInfoBase(NTy* n, 
void*, 
bool, Args&&...) : N(n) {}
 
  131   static size_t sizeOfSecond() { 
return 0; }
 
  132   bool isInEdge()
 const { 
return false; }
 
  135 template <
typename NTy>
 
  136 struct UEdgeInfoBase<NTy, void, false> {
 
  137   typedef char& reference;
 
  140   inline NTy* first() { 
return (NTy*)((uintptr_t)N & ~1); }
 
  141   inline const NTy* first()
 const { 
return (NTy*)((uintptr_t)N & ~1); }
 
  142   inline char* second()
 const { 
return static_cast<char*
>(NULL); }
 
  143   inline char* addr()
 const { 
return second(); }
 
  144   template <
typename... Args>
 
  145   UEdgeInfoBase(NTy* n, 
void*, 
bool f, Args&&...)
 
  146       : N((NTy*)((uintptr_t)n | f)) {}
 
  147   static size_t sizeOfSecond() { 
return 0; }
 
  148   bool isInEdge()
 const { 
return (uintptr_t)N & 1; }
 
  156 template <
typename ETy, 
bool DirectedNotInOut>
 
  159   template <
typename... Args>
 
  160   ETy* mkEdge(Args&&... args) {
 
  161     return &mem.
emplace(std::forward<Args>(args)...);
 
  163   void delEdge(ETy*) {}
 
  164   bool mustDel()
 const { 
return false; }
 
  167 template <
typename ETy>
 
  168 struct EdgeFactory<ETy, true> {
 
  169   template <
typename... Args>
 
  170   ETy* mkEdge(Args&&...) {
 
  173   void delEdge(ETy*) {}
 
  174   bool mustDel()
 const { 
return false; }
 
  178 struct EdgeFactory<void, false> {
 
  179   template <
typename... Args>
 
  180   void* mkEdge(Args&&...) {
 
  181     return static_cast<void*
>(NULL);
 
  183   void delEdge(
void*) {}
 
  184   bool mustDel()
 const { 
return false; }
 
  245 template <
typename NodeTy, 
typename EdgeTy, 
bool Directional,
 
  246           bool InOut = 
false, 
bool HasNoLockable = 
false,
 
  247           bool SortedNeighbors = 
false, 
typename FileEdgeTy = EdgeTy>
 
  254   template <
bool _has_no_lockable>
 
  258                             _has_no_lockable, SortedNeighbors, FileEdgeTy>;
 
  264   template <
typename _node_data>
 
  268                             HasNoLockable, SortedNeighbors, FileEdgeTy>;
 
  274   template <
typename _edge_data>
 
  278                             HasNoLockable, SortedNeighbors, FileEdgeTy>;
 
  284   template <
typename _file_edge_data>
 
  287     using type = 
MorphGraph<NodeTy, EdgeTy, Directional, InOut, HasNoLockable,
 
  288                             SortedNeighbors, _file_edge_data>;
 
  294   template <
bool _directional>
 
  297     using type = 
MorphGraph<NodeTy, EdgeTy, _directional, InOut, HasNoLockable,
 
  298                             SortedNeighbors, FileEdgeTy>;
 
  304   template <
bool _sorted_neighbors>
 
  307     using type = 
MorphGraph<NodeTy, EdgeTy, Directional, InOut, HasNoLockable,
 
  308                             _sorted_neighbors, FileEdgeTy>;
 
  315   template <
typename T>
 
  316   struct first_eq_and_valid {
 
  318     first_eq_and_valid(T& n) : N2(n) {}
 
  319     template <
typename T2>
 
  321       return ii.first() == N2 && ii.first() && ii.first()->active;
 
  325   struct first_not_valid {
 
  326     template <
typename T2>
 
  328       return !ii.first() || !ii.first()->active;
 
  332   template <
typename T>
 
  334     template <
typename T2>
 
  335     bool operator()(
const T& N2, 
const T2& ii)
 const {
 
  336       assert(ii.first() && 
"UNEXPECTED: invalid item in edgelist");
 
  337       return N2 < ii.first();
 
  339     template <
typename T2>
 
  340     bool operator()(
const T2& ii, 
const T& N2)
 const {
 
  341       assert(ii.first() && 
"UNEXPECTED: invalid item in edgelist");
 
  342       return ii.first() < N2;
 
  349       : 
public internal::NodeInfoBaseTypes<NodeTy, !HasNoLockable> {
 
  352         internal::UEdgeInfoBase<gNode, EdgeTy, Directional & !InOut>;
 
  356     using EdgesTy = boost::container::small_vector<
 
  359     using iterator = 
typename EdgesTy::iterator;
 
  362   class gNode : 
public internal::NodeInfoBase<NodeTy, !HasNoLockable>,
 
  365     friend class MorphGraph;
 
  367     using NodeInfo = internal::NodeInfoBase<NodeTy, !HasNoLockable>;
 
  369     using iterator = 
typename gNode::iterator;
 
  371     using EdgeInfo = 
typename gNode::EdgeInfo;
 
  374     typename gNodeTypes::EdgesTy 
edges;
 
  387       if (SortedNeighbors) {
 
  402     void erase(gNode* N, 
bool inEdge = 
false) {
 
  411     iterator find(gNode* N, 
bool inEdge = 
false) {
 
  414       if (SortedNeighbors) {
 
  415         assert(std::is_sorted(
edges.begin(), 
edges.end(),
 
  416                               [=](
const EdgeInfo& e1, 
const EdgeInfo& e2) {
 
  417                                 return e1.first() < e2.first();
 
  420             std::lower_bound(
edges.begin(), 
edges.end(), N, first_lt<gNode*>());
 
  425       first_eq_and_valid<gNode*> checker(N);
 
  427       while (ii != ei && ii->isInEdge() != inEdge) {
 
  438       edges.resize(size, EdgeInfo(
new gNode(), 0));
 
  444     template <
typename... Args>
 
  445     iterator createEdge(gNode* N, EdgeTy* v, 
bool inEdge, Args&&... args) {
 
  447       if (SortedNeighbors) {
 
  451             std::upper_bound(
edges.begin(), 
edges.end(), N, first_lt<gNode*>());
 
  456       return edges.insert(ii,
 
  457                           EdgeInfo(N, v, inEdge, std::forward<Args>(args)...));
 
  464     template <
typename... Args>
 
  465     iterator createEdgeWithReuse(gNode* N, EdgeTy* v, 
bool inEdge,
 
  469       if (SortedNeighbors) {
 
  472             std::lower_bound(
edges.begin(), 
edges.end(), N, first_lt<gNode*>());
 
  473         ei = std::upper_bound(ii, 
edges.end(), N, first_lt<gNode*>());
 
  482         *ii = EdgeInfo(N, v, inEdge, std::forward<Args>(args)...);
 
  485       return edges.insert(ei,
 
  486                           EdgeInfo(N, v, inEdge, std::forward<Args>(args)...));
 
  489     template <
bool _A1 = HasNoLockable>
 
  494     template <
bool _A1 = HasNoLockable>
 
  498     template <
typename... Args>
 
  499     gNode(Args&&... args)
 
  500         : NodeInfo(std::forward<Args>(args)...), active(false) {}
 
  509   internal::EdgeFactory<EdgeTy, Directional && !InOut> edgesF;
 
  512   struct is_node : 
public std::unary_function<gNode&, bool> {
 
  513     bool operator()(
const gNode& g)
 const { 
return g.active; }
 
  516       : 
public std::unary_function<typename gNodeTypes::EdgeInfo&, bool> {
 
  517     bool operator()(
typename gNodeTypes::EdgeInfo& e)
 const {
 
  518       return e.first()->active;
 
  522       : 
public std::unary_function<typename gNodeTypes::EdgeInfo&, bool> {
 
  523     bool operator()(
typename gNodeTypes::EdgeInfo& e)
 const {
 
  524       return e.first()->active && e.isInEdge();
 
  528       : 
public std::unary_function<typename gNodeTypes::EdgeInfo&, bool> {
 
  529     bool operator()(
typename gNodeTypes::EdgeInfo& e)
 const {
 
  530       return e.first()->active && !e.isInEdge();
 
  533   struct makeGraphNode : 
public std::unary_function<gNode&, gNode*> {
 
  534     gNode* 
operator()(gNode& data)
 const { 
return &data; }
 
  548       typename boost::filter_iterator<is_out_edge,
 
  549                                       typename gNodeTypes::iterator>;
 
  552       typename boost::filter_iterator<is_in_edge,
 
  553                                       typename gNodeTypes::iterator>;
 
  560   using iterator = boost::transform_iterator<
 
  562       boost::filter_iterator<is_node, typename NodeListTy::iterator>>;
 
  593       typename std::conditional<DirectedNotInOut, LargeArray<GraphNode>,
 
  598   template <
typename... Args>
 
  605     typename gNode::iterator ii = src->find(dst);
 
  607     if (ii == src->end()) {
 
  608       if (Directional && !InOut) {
 
  609         ii = src->createEdgeWithReuse(dst, 0, 
false,
 
  610                                       std::forward<Args>(args)...);
 
  613         EdgeTy* e = edgesF.mkEdge(std::forward<Args>(args)...);
 
  614         ii        = dst->createEdgeWithReuse(src, e, Directional ? 
true : 
false,
 
  615                                       std::forward<Args>(args)...);
 
  616         ii        = src->createEdgeWithReuse(dst, e, 
false,
 
  617                                       std::forward<Args>(args)...);
 
  620     return boost::make_filter_iterator(is_out_edge(), ii, src->end());
 
  623   template <
typename... Args>
 
  630     typename gNode::iterator ii = src->end();
 
  632     if (ii == src->end()) {
 
  633       if (Directional && !InOut) {
 
  634         ii = src->createEdge(dst, 0, 
false, std::forward<Args>(args)...);
 
  637         EdgeTy* e = edgesF.mkEdge(std::forward<Args>(args)...);
 
  638         ii        = dst->createEdge(src, e, Directional ? 
true : 
false,
 
  639                              std::forward<Args>(args)...);
 
  640         ii        = src->createEdge(dst, e, 
false, std::forward<Args>(args)...);
 
  643     return boost::make_filter_iterator(is_out_edge(), ii, src->end());
 
  650   template <
typename... Args>
 
  657     typename gNode::iterator ii = src->end();
 
  658     if (ii == src->end()) {
 
  660       EdgeTy* e = edgesF.mkEdge(std::forward<Args>(args)...);
 
  661       ii        = src->createEdge(dst, e, 
false, std::forward<Args>(args)...);
 
  672   template <
typename... Args>
 
  679     typename gNode::iterator ii = dst->end();
 
  680     if (ii == dst->end()) {
 
  682       ii = dst->createEdge(src, e, Directional ? 
true : 
false,
 
  683                            std::forward<Args>(args)...);
 
  687   template <bool _A1 = LargeArray<EdgeTy>::has_value,
 
  688             bool _A2 = LargeArray<FileEdgeTy>::has_value>
 
  692                         typename std::enable_if<!_A1 || _A2>::type* = 0) {
 
  694     typedef LargeArray<EdgeTy> ED;
 
  697                            graph.getEdgeData<FEDV>(nn));
 
  703   template <bool _A1 = LargeArray<EdgeTy>::has_value,
 
  704             bool _A2 = LargeArray<FileEdgeTy>::has_value>
 
  708                         typename std::enable_if<_A1 && !_A2>::type* = 0) {
 
  713   void constructInEdgeValue(FileGraph&, EdgeTy* e, 
GraphNode src,
 
  727   template <
typename... Args>
 
  729     gNode* N  = &(nodes.
emplace(std::forward<Args>(args)...));
 
  789     src->resizeEdges(size);
 
  801     return createEdgeWithReuse(src, dst, mflag);
 
  806   template <
typename... Args>
 
  809     return createEdge(src, dst, mflag, std::forward<Args>(args)...);
 
  818     if (Directional && !InOut) {
 
  819       src->erase(dst.base());
 
  821       dst->first()->acquire(mflag);
 
  824           src, Directional ? 
true : 
false); 
 
  825       src->erase(dst.base());
 
  835     typename gNodeTypes::iterator ii = src->find(dst), ei = src->end();
 
  836     is_out_edge edge_predicate;
 
  837     if (ii != ei && edge_predicate(*ii)) {
 
  840       if (!edge_predicate(*ii))
 
  846     return boost::make_filter_iterator(edge_predicate, ii, ei);
 
  857     assert(std::is_sorted(src->begin(), src->end(),
 
  858                           [=](
const typename gNode::EdgeInfo& e1,
 
  859                               const typename gNode::EdgeInfo& e2) {
 
  860                             return e1.first() < e2.first();
 
  863     auto ei = src->end();
 
  867         std::lower_bound(src->begin(), src->end(), dst, first_lt<gNode*>());
 
  869     first_eq_and_valid<gNode*> checker(dst);
 
  872     while (ii != ei && ii->isInEdge()) {
 
  878     is_out_edge edge_predicate;
 
  881       if (!edge_predicate(*ii)) {
 
  885     return boost::make_filter_iterator(edge_predicate, ii, ei);
 
  890   template <
bool _Undirected = !Directional>
 
  893                            typename std::enable_if<_Undirected>::type* = 0) {
 
  901   template <
bool _DirectedInOut = (Directional && InOut)>
 
  905              typename std::enable_if<_DirectedInOut>::type* = 0) {
 
  909     typename gNodeTypes::iterator ii = src->find(dst, 
true), ei = src->end();
 
  910     is_in_edge edge_predicate;
 
  911     if (ii != ei && edge_predicate(*ii)) {
 
  914       if (!edge_predicate(*ii))
 
  919     return boost::make_filter_iterator(edge_predicate, ii, ei);
 
  932     assert(ii->first()->active);
 
  934     ii->first()->acquire(mflag);
 
  935     return *ii->second();
 
  944     assert(ii->first()->active);
 
  946     ii->first()->acquire(mflag);
 
  947     return *ii->second();
 
  952     assert(ii->first()->active);
 
  958     assert(ii->first()->active);
 
  966     typedef typename gNode::EdgeInfo EdgeInfo;
 
  968               [=](
const EdgeInfo& e1, 
const EdgeInfo& e2) {
 
  969                 return e1.first() < e2.first();
 
  989       for (
typename gNode::iterator ii = N->begin(), ee = N->end(); ii != ee;
 
  991         if (ii->first()->active && !ii->isInEdge())
 
  992           ii->first()->acquire(mflag);
 
  995     return boost::make_filter_iterator(is_out_edge(), N->begin(), N->end());
 
  999   template <
bool _Undirected = !Directional>
 
 1002                 typename std::enable_if<!_Undirected>::type* = 0) {
 
 1007       for (
typename gNode::iterator ii = N->begin(), ee = N->end(); ii != ee;
 
 1009         if (ii->first()->active && ii->isInEdge())
 
 1010           ii->first()->acquire(mflag);
 
 1013     return boost::make_filter_iterator(is_in_edge(), N->begin(), N->end());
 
 1018   template <
bool _Undirected = !Directional>
 
 1021                               typename std::enable_if<_Undirected>::type* = 0) {
 
 1033     return boost::make_filter_iterator(is_out_edge(), N->end(), N->end());
 
 1037   template <
bool _Undirected = !Directional>
 
 1041               typename std::enable_if<!_Undirected>::type* = 0) {
 
 1046     return boost::make_filter_iterator(is_in_edge(), N->end(), N->end());
 
 1050   template <
bool _Undirected = !Directional>
 
 1053                             typename std::enable_if<_Undirected>::type* = 0) {
 
 1060     return internal::make_no_deref_range(
edge_begin(N, mflag),
 
 1065   template <
bool _Undirected = !Directional>
 
 1068            typename std::enable_if<!_Undirected>::type* = 0) {
 
 1069     return internal::make_no_deref_range(
in_edge_begin(N, mflag),
 
 1075   template <
bool _Undirected = !Directional>
 
 1078            typename std::enable_if<_Undirected>::type* = 0) {
 
 1079     return edges(N, mflag);
 
 1086   internal::EdgesIterator<MorphGraph>
 
 1088     return internal::EdgesIterator<MorphGraph>(*
this, N, mflag);
 
 1095     return boost::make_transform_iterator(
 
 1096         boost::make_filter_iterator(is_node(), nodes.
begin(), nodes.
end()),
 
 1102     return boost::make_transform_iterator(
 
 1103         boost::make_filter_iterator(is_node(), nodes.
end(), nodes.
end()),
 
 1112     return boost::make_transform_iterator(
 
 1113         boost::make_filter_iterator(is_node(), nodes.
local_begin(),
 
 1120     return boost::make_transform_iterator(
 
 1121         boost::make_filter_iterator(is_node(), nodes.
local_end(),
 
 1143     size_t numNodes = graph.
size();
 
 1144     aux.nodes.allocateInterleaved(numNodes);
 
 1159                  .divideByNode(
sizeof(gNode), 
sizeof(
typename gNode::EdgeInfo),
 
 1181                  .divideByNode(
sizeof(gNode), 
sizeof(
typename gNode::EdgeInfo),
 
 1184     auto& map = aux.inNghs.get();
 
 1188                                     en = graph.edge_end(*ii);
 
 1190         auto dstID = graph.getEdgeDst(nn);
 
 1191         auto src = aux.nodes[*ii], dst = aux.nodes[dstID];
 
 1192         auto e = constructOutEdgeValue(graph, nn, src, dst);
 
 1193         if (!Directional || InOut) {
 
 1194           map[dstID].push_back({src, e});
 
 1213     if (!Directional || InOut) {
 
 1215                    .divideByNode(
sizeof(gNode),
 
 1216                                  sizeof(
typename gNode::EdgeInfo), tid, total)
 
 1219       for (
size_t i = 0; i < aux.inNghs.numRows(); ++i) {
 
 1220         const auto& map = aux.inNghs.get(i);
 
 1221         auto ii         = map.lower_bound(*(r.first));  
 
 1222         auto ei         = map.lower_bound(*(r.second)); 
 
 1223         for (; ii != ei; ++ii) {
 
 1224           auto dst = aux.nodes[ii->first];
 
 1225           for (
const auto& ie : ii->second) {
 
 1226             constructInEdgeValue(graph, ie.second, ie.first, dst);
 
 1241     size_t numNodes = graph.
size();
 
 1242     aux.allocateInterleaved(numNodes);
 
 1246                      [&](
size_t index) { aux.constructAt(index); });
 
 1260   template <
bool V = DirectedNotInOut>
 
 1265                  .
divideByNode(
sizeof(gNode), 
sizeof(
typename gNode::EdgeInfo),
 
 1269       auto& auxNode = aux[*ii].get();
 
 1285   template <
bool V = DirectedNotInOut>
 
 1290                  .
divideByNode(
sizeof(gNode), 
sizeof(
typename gNode::EdgeInfo),
 
 1310   template <
bool V = DirectedNotInOut>
 
 1315                  .
divideByNode(
sizeof(gNode), 
sizeof(
typename gNode::EdgeInfo),
 
 1323         auto src     = aux[*ii].get().n;
 
 1324         auto& dstAux = aux[graph.
getEdgeDst(nn)].get();
 
 1325         auto e       = constructOutEdgeValue(graph, nn, src, dstAux.n);
 
 1327         dstAux.inNghs.push_back({src, e});
 
 1328         dstAux.lock.unlock();
 
 1344   template <
bool V = DirectedNotInOut>
 
 1349                  .
divideByNode(
sizeof(gNode), 
sizeof(
typename gNode::EdgeInfo),
 
 1357         constructOutEdgeValue(graph, nn, aux[*ii], aux[graph.
getEdgeDst(nn)]);
 
 1372   template <
bool V = DirectedNotInOut>
 
 1377                  .
divideByNode(
sizeof(gNode), 
sizeof(
typename gNode::EdgeInfo),
 
 1382       auto& auxNode = aux[*ii].get();
 
 1383       for (
auto ie : auxNode.inNghs) {
 
 1384         constructInEdgeValue(graph, ie.second, ie.first, auxNode.n);
 
 1391   template <
bool V = DirectedNotInOut>
 
typename std::conditional< DirectedNotInOut, LargeArray< GraphNode >, LargeArray< AuxNodePadded >>::type ReadGraphAuxData
Large array that contains auxiliary data for each node (AuxNodes) 
Definition: MorphGraph.h:594
std::enable_if_t< V > constructOutEdgesFrom(FileGraph &graph, unsigned tid, unsigned total, const ReadGraphAuxData &aux)
Constructs the MorphGraph edges given a FileGraph to construct it from and already created nodes...
Definition: MorphGraph.h:1345
static constexpr const bool DirectedNotInOut
True if a node is both directional and not storing both in and out edges. 
Definition: MorphGraph.h:590
void removeEdge(GraphNode src, edge_iterator dst, galois::MethodFlag mflag=MethodFlag::WRITE)
Removes an edge from the graph. 
Definition: MorphGraph.h:813
typename gNodeTypes::EdgeInfo::reference edge_data_reference
Reference to edge data. 
Definition: MorphGraph.h:556
void resizeEdges(GraphNode src, size_t size, galois::MethodFlag mflag=MethodFlag::WRITE)
Resize the edges of the node. 
Definition: MorphGraph.h:784
in_edge_iterator in_edge_begin(GraphNode N, galois::MethodFlag mflag=MethodFlag::WRITE, typename std::enable_if<!_Undirected >::type *=0)
Returns an iterator to the in-neighbors of a node. 
Definition: MorphGraph.h:1001
reference emplace(Args &&...args)
Thread safe bag insertion. 
Definition: Bag.h:260
unsigned int size()
Returns the number of nodes in the graph. 
Definition: MorphGraph.h:1129
size_t sizeOfEdgeData() const 
Returns the size of edge data. 
Definition: MorphGraph.h:1132
Definition: CacheLineStorage.h:32
edge_iterator edge_begin(GraphNode N)
Returns the index to the beginning of global node N's outgoing edges in the outgoing edges array...
Definition: FileGraph.cpp:641
Contains FileGraph and FileGraphWriter class declarations. 
std::enable_if_t< V > constructInEdgesFrom(FileGraph &, unsigned, unsigned, ReadGraphAuxData &)
If a directed graph and no in-edges exist (i.e. 
Definition: MorphGraph.h:1392
iterator local_iterator
local iterator over nodes 
Definition: MorphGraph.h:1108
iterator begin()
Definition: Bag.h:238
size_t size() const 
Returns the number of nodes in the (sub)graph. 
Definition: FileGraph.h:545
std::enable_if_t<!V > constructOutEdgesFrom(FileGraph &graph, unsigned tid, unsigned total, ReadGraphAuxData &aux)
Constructs the MorphGraph edges given a FileGraph to construct it from and already created nodes...
Definition: MorphGraph.h:1311
edge_iterator findEdge(GraphNode src, GraphNode dst, galois::MethodFlag mflag=MethodFlag::WRITE)
Finds if an edge between src and dst exists. 
Definition: MorphGraph.h:830
boost::counting_iterator< uint64_t > iterator
uint64 boost counting iterator 
Definition: FileGraph.h:408
void sortAllEdgesByDst(MethodFlag mflag=MethodFlag::WRITE)
Sort all edges by destination. 
Definition: MorphGraph.h:974
typename gNodeTypes::reference node_data_reference
Reference to node data. 
Definition: MorphGraph.h:558
in_edge_iterator findInEdge(GraphNode src, GraphNode dst, galois::MethodFlag mflag=MethodFlag::WRITE, typename std::enable_if< _DirectedInOut >::type *=0)
Find if an incoming edge between src and dst exists for directed in-out graphs. 
Definition: MorphGraph.h:903
GraphNode getEdgeDst(edge_iterator it)
Gets the destination of some edge. 
Definition: FileGraph.cpp:669
in_edge_iterator in_edge_end(GraphNode N, galois::MethodFlag GALOIS_UNUSED(mflag)=MethodFlag::WRITE, typename std::enable_if<!_Undirected >::type *=0)
Returns the end of an in-neighbor edge iterator. 
Definition: MorphGraph.h:1039
GraphNode n
single graph node wrapped by this struct 
Definition: MorphGraph.h:581
boost::counting_iterator< uint64_t > edge_iterator
Edge iterators (boost iterator) 
Definition: FileGraph.h:248
Definition: Iterable.h:36
local_iterator local_begin()
Definition: Bag.h:243
uint64_t GraphNode
type of a node 
Definition: FileGraph.h:60
bool shouldLock(const galois::MethodFlag g)
Helper function to decide if the conflict detection lock should be taken. 
Definition: libgalois/include/galois/runtime/Context.h:189
node_data_reference getData(const GraphNode &n, galois::MethodFlag mflag=MethodFlag::WRITE) const 
Gets the node data for a node. 
Definition: MorphGraph.h:746
A graph that can have new nodes and edges added to it. 
Definition: MorphGraph.h:248
edge_data_reference getEdgeData(edge_iterator ii, galois::MethodFlag mflag=MethodFlag::UNPROTECTED) const 
Returns the edge data associated with the edge. 
Definition: MorphGraph.h:930
local_iterator local_end()
Return the end of local range of nodes. 
Definition: MorphGraph.h:1119
runtime::iterable< NoDerefIterator< in_edge_iterator > > in_edges(GraphNode N, galois::MethodFlag mflag=MethodFlag::WRITE, typename std::enable_if<!_Undirected >::type *=0)
Return a range of in-edges that can be iterated over by C++ for-each. 
Definition: MorphGraph.h:1067
GraphNode getEdgeDst(edge_iterator ii)
Returns the destination of an edge. 
Definition: MorphGraph.h:951
galois::gstl::Vector< std::pair< GraphNode, EdgeTy * > > inNghs
stores in neighbors 
Definition: MorphGraph.h:583
Struct used to define the HasNoLockable template parameter as a type in the struct. 
Definition: MorphGraph.h:255
void sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp)
Definition: ParallelSTL.h:247
edge_iterator edge_end(GraphNode N, galois::MethodFlag GALOIS_UNUSED(mflag)=MethodFlag::WRITE)
Returns the end of the neighbor edge iterator. 
Definition: MorphGraph.h:1027
iterator end()
Definition: Bag.h:239
internal::EdgesIterator< MorphGraph > out_edges(GraphNode N, MethodFlag mflag=MethodFlag::WRITE)
An object with begin() and end() methods to iterate over the outgoing edges of N. ...
Definition: MorphGraph.h:1087
NodeTy node_data_type
Node data type. 
Definition: MorphGraph.h:545
bool containsNode(const GraphNode &n, galois::MethodFlag mflag=MethodFlag::WRITE) const 
Checks if a node is in the graph. 
Definition: MorphGraph.h:756
std::vector< T, Pow2Alloc< T >> Vector
[STL vector using Pow_2_VarSizeAlloc] 
Definition: gstl.h:52
FileEdgeTy file_edge_data_type
Edge data type of file we are loading this graph from. 
Definition: MorphGraph.h:543
edge_iterator findEdgeSortedByDst(GraphNode src, GraphNode dst, galois::MethodFlag mflag=MethodFlag::WRITE)
Find/return edge between src/dst if it exists; assumes that edges are sorted by destination. 
Definition: MorphGraph.h:852
Unordered collection of elements. 
Definition: Bag.h:42
typename boost::filter_iterator< is_out_edge, typename gNodeTypes::iterator > edge_iterator
(Out or Undirected) Edge iterator 
Definition: MorphGraph.h:549
gNode * GraphNode
Graph node handle. 
Definition: MorphGraph.h:539
void addNode(const GraphNode &n, galois::MethodFlag mflag=MethodFlag::WRITE)
Adds a node to the graph. 
Definition: MorphGraph.h:737
iterator end()
Returns the end of the node iterator. Not thread-safe. 
Definition: MorphGraph.h:1101
Definition: runtime/Mem.h:864
typename boost::filter_iterator< is_in_edge, typename gNodeTypes::iterator > in_edge_iterator
In Edge iterator. 
Definition: MorphGraph.h:553
edge_iterator in_edge_begin(GraphNode N, galois::MethodFlag mflag=MethodFlag::WRITE, typename std::enable_if< _Undirected >::type *=0)
Returns an iterator to the in-neighbors of a node; undirected case in which it's the same as a regula...
Definition: MorphGraph.h:1019
edge_data_reference getEdgeData(in_edge_iterator ii, galois::MethodFlag mflag=MethodFlag::UNPROTECTED) const 
Get edge data for an in-edge. 
Definition: MorphGraph.h:942
void acquire(Lockable *lockable, galois::MethodFlag m)
Master function which handles conflict detection used to acquire a lockable thing. 
Definition: libgalois/include/galois/runtime/Context.h:218
Struct used to define if neighbors are sorted or not in the graph. 
Definition: MorphGraph.h:305
Large array of objects with proper specialization for void type and supporting various allocation and...
Definition: LargeArray.h:53
MethodFlag
What should the runtime do when executing a method. 
Definition: MethodFlags.h:34
runtime::iterable< NoDerefIterator< edge_iterator > > edges(GraphNode N, galois::MethodFlag mflag=MethodFlag::WRITE)
Return a range of edges that can be iterated over by C++ for-each. 
Definition: MorphGraph.h:1059
iterator begin()
Returns an iterator to all the nodes in the graph. 
Definition: MorphGraph.h:1094
typename galois::substrate::CacheLineStorage< AuxNode > AuxNodePadded
Padded version of AuxNode. 
Definition: MorphGraph.h:586
std::enable_if_t< V > constructNodesFrom(FileGraph &graph, unsigned tid, unsigned total, ReadGraphAuxData &aux)
Constructs the MorphGraph nodes given a FileGraph to construct it from. 
Definition: MorphGraph.h:1286
void operator()(void)
Definition: Executor_ParaMeter.h:417
Struct used to define directionality of the graph. 
Definition: MorphGraph.h:295
void do_all(const RangeFunc &rangeMaker, FunctionTy &&fn, const Args &...args)
Standard do-all loop. 
Definition: Loops.h:71
Struct used to define the type of node data in the graph. 
Definition: MorphGraph.h:265
GraphNode getEdgeDst(in_edge_iterator ii)
Returns the destination of an in-edge. 
Definition: MorphGraph.h:957
EdgeTy edge_data_type
Edge data type. 
Definition: MorphGraph.h:541
galois::substrate::SimpleLock lock
lock for wrapped graph node 
Definition: MorphGraph.h:579
SimpleLock is a spinlock. 
Definition: SimpleLock.h:36
GraphRange divideByNode(size_t nodeSize, size_t edgeSize, size_t id, size_t total)
Given a division and a total number of divisions, return a range for that particular division to work...
Definition: FileGraph.cpp:480
edge_iterator edge_end(GraphNode N)
Returns the index to the end of global node N's outgoing edges in the outgoing edges array...
Definition: FileGraph.cpp:655
edge_iterator in_edge_end(GraphNode N, galois::MethodFlag mflag=MethodFlag::WRITE, typename std::enable_if< _Undirected >::type *=0)
Returns the end of an in-neighbor edge iterator, undirected case. 
Definition: MorphGraph.h:1051
Struct used to define the type of file edge data in the graph. 
Definition: MorphGraph.h:285
void allocateFrom(FileGraph &graph, ReadGraphAuxData &aux)
Allocate memory for nodes given a file graph with a particular number of nodes. 
Definition: MorphGraph.h:1240
Definition: PerThreadContainer.h:523
void sortEdgesByDst(GraphNode N, galois::MethodFlag mflag=MethodFlag::WRITE)
Sorts edge of a node by destination. 
Definition: MorphGraph.h:963
Struct used to define the type of edge data in the graph. 
Definition: MorphGraph.h:275
boost::transform_iterator< makeGraphNode, boost::filter_iterator< is_node, typename NodeListTy::iterator >> iterator
Node iterator. 
Definition: MorphGraph.h:562
Graph that mmaps Galois gr files for access. 
Definition: FileGraph.h:57
auto iterate(C &cont)
Definition: Range.h:323
std::enable_if_t<!V > constructInEdgesFrom(FileGraph &graph, unsigned tid, unsigned total, ReadGraphAuxData &aux)
Constructs the MorphGraph in-edges given a FileGraph to construct it from and already created nodes...
Definition: MorphGraph.h:1373
edge_iterator addEdge(GraphNode src, GraphNode dst, galois::MethodFlag mflag=MethodFlag::WRITE)
Adds an edge to graph, replacing existing value if edge already exists. 
Definition: MorphGraph.h:799
edge_iterator addMultiEdge(GraphNode src, GraphNode dst, galois::MethodFlag mflag, Args &&...args)
Adds and initializes an edge to graph but does not check for duplicate edges. 
Definition: MorphGraph.h:807
InputIterator find_if(InputIterator first, InputIterator last, Predicate pred)
Definition: ParallelSTL.h:70
local_iterator local_end()
Definition: Bag.h:246
T value_type
Definition: Executor_ParaMeter.h:111
void removeNode(GraphNode n, galois::MethodFlag mflag=MethodFlag::WRITE)
Removes a node from the graph along with all its outgoing/incoming edges for undirected graphs or out...
Definition: MorphGraph.h:769
GraphNode createNode(Args &&...args)
Creates a new node holding the indicated data. 
Definition: MorphGraph.h:728
edge_iterator findInEdge(GraphNode src, GraphNode dst, galois::MethodFlag mflag=MethodFlag::WRITE, typename std::enable_if< _Undirected >::type *=0)
Find a particular in-edge: note this function activates for the undirected graph case, so it just calls the regular out-edge finding function. 
Definition: MorphGraph.h:891
std::enable_if_t<!V > constructNodesFrom(FileGraph &graph, unsigned tid, unsigned total, ReadGraphAuxData &aux)
Constructs the MorphGraph nodes given a FileGraph to construct it from. 
Definition: MorphGraph.h:1261
local_iterator local_begin()
Return the beginning of local range of nodes. 
Definition: MorphGraph.h:1111
runtime::iterable< NoDerefIterator< edge_iterator > > in_edges(GraphNode N, galois::MethodFlag mflag=MethodFlag::WRITE, typename std::enable_if< _Undirected >::type *=0)
Return a range of in-edges that can be iterated over by C++ for-each Undirected case, equivalent to out-edge iteration. 
Definition: MorphGraph.h:1077
edge_iterator edge_begin(GraphNode N, galois::MethodFlag mflag=MethodFlag::WRITE)
Returns an iterator to the neighbors of a node. 
Definition: MorphGraph.h:983