26 #ifndef GALOIS_GRAPHS_MORPHHYPERGRAPH_H
27 #define GALOIS_GRAPHS_MORPHHYPERGRAPH_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>
41 #include "galois/config.h"
61 template <
typename NTy,
typename ETy,
bool DirectedButNotInOut>
64 template <
typename NTy,
typename ETy>
65 struct UEdgeInfoBase<NTy, ETy, true> {
66 typedef ETy& reference;
75 inline NTy* first()
const {
79 inline ETy* second() {
return &Ea; }
80 inline const ETy* second()
const {
return &Ea; }
82 template <
typename... Args>
83 UEdgeInfoBase(NTy* n, ETy*,
bool, Args&&... args)
84 : N(n), Ea(std::forward<Args>(args)...) {}
86 template <
typename... Args>
87 UEdgeInfoBase(NTy* n, ETy& v,
bool, Args&&...) : N(n) {
91 static size_t sizeOfSecond() {
return sizeof(ETy); }
92 bool isInEdge()
const {
return false; }
95 template <
typename NTy,
typename ETy>
96 struct UEdgeInfoBase<NTy, ETy, false> {
97 typedef ETy& reference;
102 inline NTy* first() {
104 return (NTy*)((uintptr_t)N & ~1);
106 inline NTy* first()
const {
108 return (NTy*)((uintptr_t)N & ~1);
110 inline ETy* second() {
return Ea; }
111 inline const ETy* second()
const {
return Ea; }
112 template <
typename... Args>
113 UEdgeInfoBase(NTy* n, ETy* v,
bool f, Args&&...)
114 : N((NTy*)((uintptr_t)n | f)), Ea(v) {}
115 static size_t sizeOfSecond() {
return sizeof(ETy); }
116 bool isInEdge()
const {
return (uintptr_t)N & 1; }
119 template <
typename NTy>
120 struct UEdgeInfoBase<NTy, void, true> {
121 typedef char& reference;
124 inline NTy* first() {
return N; }
125 inline NTy* first()
const {
return N; }
126 inline char* second()
const {
return static_cast<char*
>(NULL); }
127 inline char* addr()
const {
return second(); }
128 template <
typename... Args>
129 UEdgeInfoBase(NTy* n,
void*,
bool, Args&&...) : N(n) {}
130 static size_t sizeOfSecond() {
return 0; }
131 bool isInEdge()
const {
return false; }
134 template <
typename NTy>
135 struct UEdgeInfoBase<NTy, void, false> {
136 typedef char& reference;
139 inline NTy* first() {
return (NTy*)((uintptr_t)N & ~1); }
140 inline NTy* first()
const {
return (NTy*)((uintptr_t)N & ~1); }
141 inline char* second()
const {
return static_cast<char*
>(NULL); }
142 inline char* addr()
const {
return second(); }
143 template <
typename... Args>
144 UEdgeInfoBase(NTy* n,
void*,
bool f, Args&&...)
145 : N((NTy*)((uintptr_t)n | f)) {}
146 static size_t sizeOfSecond() {
return 0; }
147 bool isInEdge()
const {
return (uintptr_t)N & 1; }
155 template <
typename ETy,
bool DirectedNotInOut>
158 template <
typename... Args>
159 ETy* mkEdge(Args&&... args) {
160 return &mem.
emplace(std::forward<Args>(args)...);
162 void delEdge(ETy*) {}
163 bool mustDel()
const {
return false; }
166 template <
typename ETy>
167 struct EdgeFactory<ETy, true> {
168 template <
typename... Args>
169 ETy* mkEdge(Args&&...) {
172 void delEdge(ETy*) {}
173 bool mustDel()
const {
return false; }
177 struct EdgeFactory<void, false> {
178 template <
typename... Args>
179 void* mkEdge(Args&&...) {
180 return static_cast<void*
>(NULL);
182 void delEdge(
void*) {}
183 bool mustDel()
const {
return false; }
244 template <
typename NodeTy,
typename EdgeTy,
bool Directional,
245 bool InOut =
false,
bool HasNoLockable =
false,
246 bool SortedNeighbors =
false,
typename FileEdgeTy = EdgeTy>
253 template <
bool _has_no_lockable>
257 _has_no_lockable, SortedNeighbors, FileEdgeTy>;
263 template <
typename _node_data>
267 HasNoLockable, SortedNeighbors, FileEdgeTy>;
273 template <
typename _edge_data>
277 HasNoLockable, SortedNeighbors, FileEdgeTy>;
283 template <
typename _file_edge_data>
288 SortedNeighbors, _file_edge_data>;
294 template <
bool _directional>
298 HasNoLockable, SortedNeighbors, FileEdgeTy>;
304 template <
bool _sorted_neighbors>
308 HasNoLockable, _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 MorphHyperGraph;
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>
499 template <
typename... Args>
500 gNode(Args&&... args)
501 : NodeInfo(std::forward<Args>(args)...), active(false) {}
513 internal::EdgeFactory<EdgeTy, Directional && !InOut> edgesF;
516 struct is_node :
public std::unary_function<gNode&, bool> {
517 bool operator()(
const gNode& g)
const {
return g.active; }
520 :
public std::unary_function<typename gNodeTypes::EdgeInfo&, bool> {
521 bool operator()(
typename gNodeTypes::EdgeInfo& e)
const {
522 return e.first()->active;
526 :
public std::unary_function<typename gNodeTypes::EdgeInfo&, bool> {
527 bool operator()(
typename gNodeTypes::EdgeInfo& e)
const {
528 return e.first()->active && e.isInEdge();
532 :
public std::unary_function<typename gNodeTypes::EdgeInfo&, bool> {
533 bool operator()(
typename gNodeTypes::EdgeInfo& e)
const {
534 return e.first()->active && !e.isInEdge();
537 struct makeGraphNode :
public std::unary_function<gNode&, gNode*> {
538 gNode*
operator()(gNode& data)
const {
return &data; }
552 typename boost::filter_iterator<is_out_edge,
553 typename gNodeTypes::iterator>;
556 typename boost::filter_iterator<is_in_edge,
557 typename gNodeTypes::iterator>;
564 using iterator = boost::transform_iterator<
566 boost::filter_iterator<is_node, typename NodeListTy::iterator>>;
604 typename std::conditional<DirectedNotInOut, LargeArray<GraphNode>,
609 template <
typename... Args>
616 typename gNode::iterator ii = src->find(dst);
618 if (ii == src->end()) {
619 if (Directional && !InOut) {
620 ii = src->createEdgeWithReuse(dst, 0,
false,
621 std::forward<Args>(args)...);
624 EdgeTy* e = edgesF.mkEdge(std::forward<Args>(args)...);
625 ii = dst->createEdgeWithReuse(src, e, Directional ?
true :
false,
626 std::forward<Args>(args)...);
627 ii = src->createEdgeWithReuse(dst, e,
false,
628 std::forward<Args>(args)...);
631 return boost::make_filter_iterator(is_out_edge(), ii, src->end());
634 template <
typename... Args>
641 typename gNode::iterator ii = src->end();
643 if (ii == src->end()) {
644 if (Directional && !InOut) {
645 ii = src->createEdge(dst, 0,
false, std::forward<Args>(args)...);
648 EdgeTy* e = edgesF.mkEdge(std::forward<Args>(args)...);
649 ii = dst->createEdge(src, e, Directional ?
true :
false,
650 std::forward<Args>(args)...);
651 ii = src->createEdge(dst, e,
false, std::forward<Args>(args)...);
654 return boost::make_filter_iterator(is_out_edge(), ii, src->end());
661 template <
typename... Args>
668 typename gNode::iterator ii = src->end();
669 if (ii == src->end()) {
671 EdgeTy* e = edgesF.mkEdge(std::forward<Args>(args)...);
672 ii = src->createEdge(dst, e,
false, std::forward<Args>(args)...);
683 template <
typename... Args>
690 typename gNode::iterator ii = dst->end();
691 if (ii == dst->end()) {
693 ii = dst->createEdge(src, e, Directional ?
true :
false,
694 std::forward<Args>(args)...);
698 template <bool _A1 = LargeArray<EdgeTy>::has_value,
699 bool _A2 = LargeArray<FileEdgeTy>::has_value>
703 typename std::enable_if<!_A1 || _A2>::type* = 0) {
705 typedef LargeArray<EdgeTy> ED;
708 graph.getEdgeData<FEDV>(nn));
714 template <bool _A1 = LargeArray<EdgeTy>::has_value,
715 bool _A2 = LargeArray<FileEdgeTy>::has_value>
719 typename std::enable_if<_A1 && !_A2>::type* = 0) {
724 void constructInEdgeValue(FileGraph&, EdgeTy* e,
GraphNode src,
738 template <
typename... Args>
740 gNode* N = &(nodes.
emplace(std::forward<Args>(args)...));
800 src->resizeEdges(size);
812 return createEdgeWithReuse(src, dst, mflag);
817 template <
typename... Args>
820 return createEdge(src, dst, mflag, std::forward<Args>(args)...);
829 if (Directional && !InOut) {
830 src->erase(dst.base());
832 dst->first()->acquire(mflag);
835 src, Directional ?
true :
false);
836 src->erase(dst.base());
846 typename gNodeTypes::iterator ii = src->find(dst), ei = src->end();
847 is_out_edge edge_predicate;
848 if (ii != ei && edge_predicate(*ii)) {
851 if (!edge_predicate(*ii))
857 return boost::make_filter_iterator(edge_predicate, ii, ei);
868 assert(std::is_sorted(src->begin(), src->end(),
869 [=](
const typename gNode::EdgeInfo& e1,
870 const typename gNode::EdgeInfo& e2) {
871 return e1.first() < e2.first();
874 auto ei = src->end();
878 std::lower_bound(src->begin(), src->end(), dst, first_lt<gNode*>());
880 first_eq_and_valid<gNode*> checker(dst);
883 while (ii != ei && ii->isInEdge()) {
889 is_out_edge edge_predicate;
892 if (!edge_predicate(*ii)) {
896 return boost::make_filter_iterator(edge_predicate, ii, ei);
901 template <
bool _Undirected = !Directional>
904 typename std::enable_if<_Undirected>::type* = 0) {
912 template <
bool _DirectedInOut = (Directional && InOut)>
916 typename std::enable_if<_DirectedInOut>::type* = 0) {
920 typename gNodeTypes::iterator ii = src->find(dst,
true), ei = src->end();
921 is_in_edge edge_predicate;
922 if (ii != ei && edge_predicate(*ii)) {
925 if (!edge_predicate(*ii))
930 return boost::make_filter_iterator(edge_predicate, ii, ei);
943 assert(ii->first()->active);
945 ii->first()->acquire(mflag);
946 return *ii->second();
955 assert(ii->first()->active);
957 ii->first()->acquire(mflag);
958 return *ii->second();
963 assert(ii->first()->active);
969 assert(ii->first()->active);
977 typedef typename gNode::EdgeInfo EdgeInfo;
979 [=](
const EdgeInfo& e1,
const EdgeInfo& e2) {
980 return e1.first() < e2.first();
995 typedef typename gNode::EdgeInfo EdgeInfo;
997 [=](
const EdgeInfo& e1,
const EdgeInfo& e2) {
1016 for (
typename gNode::iterator ii = N->begin(), ee = N->end(); ii != ee;
1018 if (ii->first()->active && !ii->isInEdge())
1019 ii->first()->acquire(mflag);
1022 return boost::make_filter_iterator(is_out_edge(), N->begin(), N->end());
1026 template <
bool _Undirected = !Directional>
1029 typename std::enable_if<!_Undirected>::type* = 0) {
1034 for (
typename gNode::iterator ii = N->begin(), ee = N->end(); ii != ee;
1036 if (ii->first()->active && ii->isInEdge())
1037 ii->first()->acquire(mflag);
1040 return boost::make_filter_iterator(is_in_edge(), N->begin(), N->end());
1045 template <
bool _Undirected = !Directional>
1048 typename std::enable_if<_Undirected>::type* = 0) {
1060 return boost::make_filter_iterator(is_out_edge(), N->end(), N->end());
1064 template <
bool _Undirected = !Directional>
1068 typename std::enable_if<!_Undirected>::type* = 0) {
1073 return boost::make_filter_iterator(is_in_edge(), N->end(), N->end());
1077 template <
bool _Undirected = !Directional>
1080 typename std::enable_if<_Undirected>::type* = 0) {
1087 return internal::make_no_deref_range(
edge_begin(N, mflag),
1092 template <
bool _Undirected = !Directional>
1095 typename std::enable_if<!_Undirected>::type* = 0) {
1096 return internal::make_no_deref_range(
in_edge_begin(N, mflag),
1102 template <
bool _Undirected = !Directional>
1105 typename std::enable_if<_Undirected>::type* = 0) {
1106 return edges(N, mflag);
1113 internal::EdgesIterator<MorphHyperGraph>
1115 return internal::EdgesIterator<MorphHyperGraph>(*
this, N, mflag);
1122 return boost::make_transform_iterator(
1123 boost::make_filter_iterator(is_node(), nodes.
begin(), nodes.
end()),
1129 return boost::make_transform_iterator(
1130 boost::make_filter_iterator(is_node(), nodes.
end(), nodes.
end()),
1139 return boost::make_transform_iterator(
1140 boost::make_filter_iterator(is_node(), nodes.
local_begin(),
1147 return boost::make_transform_iterator(
1148 boost::make_filter_iterator(is_node(), nodes.
local_end(),
1170 size_t numNodes = graph.
size();
1171 aux.nodes.allocateInterleaved(numNodes);
1186 .divideByNode(
sizeof(gNode),
sizeof(
typename gNode::EdgeInfo),
1208 .divideByNode(
sizeof(gNode),
sizeof(
typename gNode::EdgeInfo),
1211 auto& map = aux.inNghs.get();
1215 en = graph.edge_end(*ii);
1217 auto dstID = graph.getEdgeDst(nn);
1218 auto src = aux.nodes[*ii], dst = aux.nodes[dstID];
1219 auto e = constructOutEdgeValue(graph, nn, src, dst);
1220 if (!Directional || InOut) {
1221 map[dstID].push_back({src, e});
1240 if (!Directional || InOut) {
1242 .divideByNode(
sizeof(gNode),
1243 sizeof(
typename gNode::EdgeInfo), tid, total)
1246 for (
size_t i = 0; i < aux.inNghs.numRows(); ++i) {
1247 const auto& map = aux.inNghs.get(i);
1248 auto ii = map.lower_bound(*(r.first));
1249 auto ei = map.lower_bound(*(r.second));
1250 for (; ii != ei; ++ii) {
1251 auto dst = aux.nodes[ii->first];
1252 for (
const auto& ie : ii->second) {
1253 constructInEdgeValue(graph, ie.second, ie.first, dst);
1268 size_t numNodes = graph.
size();
1269 aux.allocateInterleaved(numNodes);
1273 [&](
size_t index) { aux.constructAt(index); });
1287 template <
bool V = DirectedNotInOut>
1292 .
divideByNode(
sizeof(gNode),
sizeof(
typename gNode::EdgeInfo),
1296 auto& auxNode = aux[*ii].get();
1312 template <
bool V = DirectedNotInOut>
1317 .
divideByNode(
sizeof(gNode),
sizeof(
typename gNode::EdgeInfo),
1337 template <
bool V = DirectedNotInOut>
1342 .
divideByNode(
sizeof(gNode),
sizeof(
typename gNode::EdgeInfo),
1350 auto src = aux[*ii].get().n;
1351 auto& dstAux = aux[graph.
getEdgeDst(nn)].get();
1352 auto e = constructOutEdgeValue(graph, nn, src, dstAux.n);
1354 dstAux.inNghs.push_back({src, e});
1355 dstAux.lock.unlock();
1371 template <
bool V = DirectedNotInOut>
1376 .
divideByNode(
sizeof(gNode),
sizeof(
typename gNode::EdgeInfo),
1384 constructOutEdgeValue(graph, nn, aux[*ii], aux[graph.
getEdgeDst(nn)]);
1399 template <
bool V = DirectedNotInOut>
1404 .
divideByNode(
sizeof(gNode),
sizeof(
typename gNode::EdgeInfo),
1409 auto& auxNode = aux[*ii].get();
1410 for (
auto ie : auxNode.inNghs) {
1411 constructInEdgeValue(graph, ie.second, ie.first, auxNode.n);
1418 template <
bool V = DirectedNotInOut>
1426 for (
auto it :
edges(H)) {
1429 neighbors.push_back(n);
1438 for (
auto it :
edges(N)) {
1440 for (
auto h :
edges(hedge)) {
1443 neighbors.push_back(hneighbor);
1452 for (
auto net :
edges(N)) {
1462 for (
auto net :
edges(N)) {
1464 cells.push_back(hedge);
1476 for (
auto n :
edges(N)) {
1478 for (
auto c :
edges(C)) {
1487 std::vector<GraphNode> nets;
1488 for (
auto n :
edges(N)) {
void addNode(const GraphNode &n, galois::MethodFlag mflag=MethodFlag::WRITE)
Adds a node to the graph.
Definition: MorphHyperGraph.h:748
internal::EdgesIterator< MorphHyperGraph > out_edges(GraphNode N, MethodFlag mflag=MethodFlag::WRITE)
An object with begin() and end() methods to iterate over the outgoing edges of N. ...
Definition: MorphHyperGraph.h:1114
galois::substrate::SimpleLock lock
lock for wrapped graph node
Definition: MorphHyperGraph.h:590
gstl::Vector< int > maxgain
Definition: MorphHyperGraph.h:573
std::enable_if_t< V > constructInEdgesFrom(FileGraph &, unsigned, unsigned, ReadGraphAuxData &)
If a directed graph and no in-edges exist (i.e.
Definition: MorphHyperGraph.h:1419
node_data_reference getData(const GraphNode &n, galois::MethodFlag mflag=MethodFlag::WRITE) const
Gets the node data for a node.
Definition: MorphHyperGraph.h:757
gNode * GraphNode
Graph node handle.
Definition: MorphHyperGraph.h:543
reference emplace(Args &&...args)
Thread safe bag insertion.
Definition: Bag.h:260
gstl::Vector< GraphNode > getNets(GraphNode N)
Definition: MorphHyperGraph.h:1450
GraphNode getEdgeDst(edge_iterator ii)
Returns the destination of an edge.
Definition: MorphHyperGraph.h:962
void sortCellDegree(MethodFlag mflag=MethodFlag::WRITE)
Definition: MorphHyperGraph.h:1004
Struct used to define if neighbors are sorted or not in the graph.
Definition: MorphHyperGraph.h:305
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.
iterator local_iterator
local iterator over nodes
Definition: MorphHyperGraph.h:1135
void sortAllEdgesByDst(MethodFlag mflag=MethodFlag::WRITE)
Sort all edges by destination.
Definition: MorphHyperGraph.h:985
iterator begin()
Definition: Bag.h:238
size_t size() const
Returns the number of nodes in the (sub)graph.
Definition: FileGraph.h:545
gstl::Vector< GraphNode > getCells(GraphNode N)
Definition: MorphHyperGraph.h:1460
void addCell(GraphNode n)
Definition: MorphHyperGraph.h:1470
typename gNodeTypes::EdgeInfo::reference edge_data_reference
Reference to edge data.
Definition: MorphHyperGraph.h:560
boost::counting_iterator< uint64_t > iterator
uint64 boost counting iterator
Definition: FileGraph.h:408
Struct used to define the HasNoLockable template parameter as a type in the struct.
Definition: MorphHyperGraph.h:254
Struct used to define the type of edge data in the graph.
Definition: MorphHyperGraph.h:274
typename boost::filter_iterator< is_in_edge, typename gNodeTypes::iterator > in_edge_iterator
In Edge iterator.
Definition: MorphHyperGraph.h:557
void sortEdgesByDeg(GraphNode N, galois::MethodFlag mflag=MethodFlag::WRITE)
Definition: MorphHyperGraph.h:992
GraphNode getEdgeDst(edge_iterator it)
Gets the destination of some edge.
Definition: FileGraph.cpp:669
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: MorphHyperGraph.h:1313
edge_data_reference getEdgeData(in_edge_iterator ii, galois::MethodFlag mflag=MethodFlag::UNPROTECTED) const
Get edge data for an in-edge.
Definition: MorphHyperGraph.h:953
typename std::conditional< DirectedNotInOut, LargeArray< GraphNode >, LargeArray< AuxNodePadded >>::type ReadGraphAuxData
Large array that contains auxiliary data for each node (AuxNodes)
Definition: MorphHyperGraph.h:605
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: MorphHyperGraph.h:1066
GraphNode createNode(Args &&...args)
Creates a new node holding the indicated data.
Definition: MorphHyperGraph.h:739
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
GraphNode getneighbornet(GraphNode N, GraphNode C)
Definition: MorphHyperGraph.h:1475
A graph that can have new nodes and edges added to it.
Definition: MorphHyperGraph.h:247
Bnodes & getNets()
Definition: MorphHyperGraph.h:1473
uint64_t GraphNode
type of a node
Definition: FileGraph.h:60
edge_iterator edge_end(GraphNode N, galois::MethodFlag GALOIS_UNUSED(mflag)=MethodFlag::WRITE)
Returns the end of the neighbor edge iterator.
Definition: MorphHyperGraph.h:1054
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: MorphHyperGraph.h:1338
local_iterator local_begin()
Return the beginning of local range of nodes.
Definition: MorphHyperGraph.h:1138
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
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: MorphHyperGraph.h:780
gstl::Vector< GraphNode > getneighbor(GraphNode N, GraphNode H)
Definition: MorphHyperGraph.h:1422
void sortEdgesByDst(GraphNode N, galois::MethodFlag mflag=MethodFlag::WRITE)
Sorts edge of a node by destination.
Definition: MorphHyperGraph.h:974
iterator begin()
Returns an iterator to all the nodes in the graph.
Definition: MorphHyperGraph.h:1121
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: MorphHyperGraph.h:1028
std::vector< GraphNode > getallneighbornets(GraphNode N)
Definition: MorphHyperGraph.h:1486
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: MorphHyperGraph.h:1372
galois::gstl::Vector< std::pair< GraphNode, EdgeTy * > > inNghs
stores in neighbors
Definition: MorphHyperGraph.h:594
void resizeEdges(GraphNode src, size_t size, galois::MethodFlag mflag=MethodFlag::WRITE)
Resize the edges of the node.
Definition: MorphHyperGraph.h:795
void sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp)
Definition: ParallelSTL.h:247
FileEdgeTy file_edge_data_type
Edge data type of file we are loading this graph from.
Definition: MorphHyperGraph.h:547
gstl::Vector< GraphNode > getallneighbor(GraphNode N)
Definition: MorphHyperGraph.h:1435
iterator end()
Definition: Bag.h:239
edge_data_reference getEdgeData(edge_iterator ii, galois::MethodFlag mflag=MethodFlag::UNPROTECTED) const
Returns the edge data associated with the edge.
Definition: MorphHyperGraph.h:941
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: MorphHyperGraph.h:863
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: MorphHyperGraph.h:818
boost::transform_iterator< makeGraphNode, boost::filter_iterator< is_node, typename NodeListTy::iterator >> iterator
Node iterator.
Definition: MorphHyperGraph.h:566
Struct used to define the type of node data in the graph.
Definition: MorphHyperGraph.h:264
std::vector< T, Pow2Alloc< T >> Vector
[STL vector using Pow_2_VarSizeAlloc]
Definition: gstl.h:52
Struct used to define the type of file edge data in the graph.
Definition: MorphHyperGraph.h:284
Bnodes & cellList()
Definition: MorphHyperGraph.h:1471
Unordered collection of elements.
Definition: Bag.h:42
int total_area
Definition: MorphHyperGraph.h:570
Definition: runtime/Mem.h:864
iterator end()
Returns the end of the node iterator. Not thread-safe.
Definition: MorphHyperGraph.h:1128
local_iterator local_end()
Return the end of local range of nodes.
Definition: MorphHyperGraph.h:1146
void removeEdge(GraphNode src, edge_iterator dst, galois::MethodFlag mflag=MethodFlag::WRITE)
Removes an edge from the graph.
Definition: MorphHyperGraph.h:824
gstl::Vector< GraphNode > locked_cells
Definition: MorphHyperGraph.h:568
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
edge_iterator edge_begin(GraphNode N, galois::MethodFlag mflag=MethodFlag::WRITE)
Returns an iterator to the neighbors of a node.
Definition: MorphHyperGraph.h:1010
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
gstl::Vector< int > balance
Definition: MorphHyperGraph.h:574
unsigned int size()
Returns the number of nodes in the graph.
Definition: MorphHyperGraph.h:1156
typename galois::substrate::CacheLineStorage< AuxNode > AuxNodePadded
Padded version of AuxNode.
Definition: MorphHyperGraph.h:597
void operator()(void)
Definition: Executor_ParaMeter.h:417
size_t sizeOfEdgeData() const
Returns the size of edge data.
Definition: MorphHyperGraph.h:1159
void do_all(const RangeFunc &rangeMaker, FunctionTy &&fn, const Args &...args)
Standard do-all loop.
Definition: Loops.h:71
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: MorphHyperGraph.h:1104
EdgeTy edge_data_type
Edge data type.
Definition: MorphHyperGraph.h:545
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: MorphHyperGraph.h:1078
int max_cell_area
Definition: MorphHyperGraph.h:569
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: MorphHyperGraph.h:1288
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 addEdge(GraphNode src, GraphNode dst, galois::MethodFlag mflag=MethodFlag::WRITE)
Adds an edge to graph, replacing existing value if edge already exists.
Definition: MorphHyperGraph.h:810
void addHyperedge(GraphNode n)
Definition: MorphHyperGraph.h:1469
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
reference push_back(ItemTy &&val)
Thread safe bag insertion.
Definition: Bag.h:298
GraphNode getEdgeDst(in_edge_iterator ii)
Returns the destination of an in-edge.
Definition: MorphHyperGraph.h:968
Definition: PerThreadContainer.h:523
Graph that mmaps Galois gr files for access.
Definition: FileGraph.h:57
auto iterate(C &cont)
Definition: Range.h:323
bool containsNode(const GraphNode &n, galois::MethodFlag mflag=MethodFlag::WRITE) const
Checks if a node is in the graph.
Definition: MorphHyperGraph.h:767
InputIterator find_if(InputIterator first, InputIterator last, Predicate pred)
Definition: ParallelSTL.h:70
static constexpr const bool DirectedNotInOut
True if a node is both directional and not storing both in and out edges.
Definition: MorphHyperGraph.h:601
std::list< int > freeCells
Definition: MorphHyperGraph.h:571
Struct used to define directionality of the graph.
Definition: MorphHyperGraph.h:295
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: MorphHyperGraph.h:914
local_iterator local_end()
Definition: Bag.h:246
T value_type
Definition: Executor_ParaMeter.h:111
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: MorphHyperGraph.h:1086
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: MorphHyperGraph.h:1046
GraphNode n
single graph node wrapped by this struct
Definition: MorphHyperGraph.h:592
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: MorphHyperGraph.h:1094
typename gNodeTypes::reference node_data_reference
Reference to node data.
Definition: MorphHyperGraph.h:562
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: MorphHyperGraph.h:1400
typename boost::filter_iterator< is_out_edge, typename gNodeTypes::iterator > edge_iterator
(Out or Undirected) Edge iterator
Definition: MorphHyperGraph.h:553
edge_iterator findEdge(GraphNode src, GraphNode dst, galois::MethodFlag mflag=MethodFlag::WRITE)
Finds if an edge between src and dst exists.
Definition: MorphHyperGraph.h:841
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: MorphHyperGraph.h:902
NodeTy node_data_type
Node data type.
Definition: MorphHyperGraph.h:549
void allocateFrom(FileGraph &graph, ReadGraphAuxData &aux)
Allocate memory for nodes given a file graph with a particular number of nodes.
Definition: MorphHyperGraph.h:1267