20 #ifndef GALOIS_GRAPHS_LC_INOUT_GRAPH_H
21 #define GALOIS_GRAPHS_LC_INOUT_GRAPH_H
23 #include <boost/iterator/iterator_facade.hpp>
24 #include <boost/fusion/include/vector.hpp>
25 #include <boost/fusion/include/at_c.hpp>
27 #include "galois/config.h"
38 template <
typename GraphTy>
41 template <
typename _node_data>
48 template <
typename _edge_data>
60 typedef typename GraphTy ::template with_id<true>::type Super;
62 typename GraphTy ::template with_id<true>::type ::template
with_node_data<
63 void>::type ::template with_no_lockable<true>::type InGraph;
67 typename InGraph::GraphNode inGraphNode(
typename Super::GraphNode n) {
71 void createAsymmetric() { asymmetric =
true; }
91 :
public boost::iterator_facade<in_edge_iterator, void*,
92 std::random_access_iterator_tag, void*> {
96 typedef typename InGraph::edge_iterator Iterator1;
97 typedef boost::fusion::vector<Iterator0, Iterator1> Iterators;
105 ++boost::fusion::at_c<0>(its);
107 ++boost::fusion::at_c<1>(its);
110 void advance(
unsigned n) {
112 boost::fusion::at_c<0>(its) += n;
114 boost::fusion::at_c<1>(its) += n;
121 return boost::fusion::at_c<0>(its) == boost::fusion::at_c<0>(o.its);
123 return boost::fusion::at_c<1>(its) == boost::fusion::at_c<1>(o.its);
127 typename in_edge_iterator::difference_type
130 return boost::fusion::at_c<0>(lhs.its) - boost::fusion::at_c<0>(its);
132 return boost::fusion::at_c<1>(lhs.its) - boost::fusion::at_c<1>(its);
135 void* dereference()
const {
return 0; }
140 boost::fusion::at_c<0>(its) = it;
143 boost::fusion::at_c<1>(its) = it;
154 return this->getEdgeData(boost::fusion::at_c<0>(ni.its));
156 return inGraph.getEdgeData(boost::fusion::at_c<1>(ni.its));
162 return this->getEdgeDst(boost::fusion::at_c<0>(ni.its));
165 inGraph.getId(inGraph.getEdgeDst(boost::fusion::at_c<1>(ni.its))));
171 this->acquireNode(N, mflag);
174 for (
edge_iterator ii = this->raw_begin(N), ei = this->raw_end(N);
176 this->acquireNode(this->getEdgeDst(ii), mflag);
182 for (
typename InGraph::edge_iterator
183 ii = inGraph.raw_begin(inGraphNode(N)),
184 ei = inGraph.raw_end(inGraphNode(N));
186 this->acquireNode(
nodeFromId(inGraph.getId(inGraph.getEdgeDst(ii))),
196 this->acquireNode(N, mflag);
204 internal::InEdgesIterator<LC_InOut_Graph>
206 return internal::InEdgesIterator<LC_InOut_Graph>(*
this, N, mflag);
213 template <
typename CompTy>
216 const CompTy& comp = std::less<typename GraphTy::edge_data_type>(),
218 this->acquireNode(N, mflag);
220 std::sort(this->edge_sort_begin(N), this->edge_sort_end(N),
221 internal::EdgeSortCompWrapper<
225 std::sort(inGraph.edge_sort_begin(inGraphNode(N)),
226 inGraph.edge_sort_end(inGraphNode(N)),
227 internal::EdgeSortCompWrapper<
237 template <
typename CompTy>
240 this->acquireNode(N, mflag);
242 std::sort(this->edge_sort_begin(N), this->edge_sort_end(N), comp);
244 std::sort(inGraph.edge_sort_begin(inGraphNode(N)),
245 inGraph.edge_sort_end(inGraphNode(N)), comp);
253 this->acquireNode(N, mflag);
256 std::sort(this->edge_sort_begin(N), this->edge_sort_end(N),
257 [=](
const EdgeSortVal& e1,
const EdgeSortVal& e2) {
258 return e1.dst < e2.dst;
264 std::sort(inGraph.edge_sort_begin(inGraphNode(N)),
265 inGraph.edge_sort_end(inGraphNode(N)),
266 [=](
const InEdgeSortVal& e1,
const InEdgeSortVal& e2) {
267 return e1.dst < e2.dst;
void sortInEdges(GraphNode N, const CompTy &comp, MethodFlag mflag=MethodFlag::WRITE)
Sorts incoming edges of a node.
Definition: LC_InOut_Graph.h:238
LC_InOut_Graph< typename GraphTy::template with_node_data< _node_data >::type > type
Definition: LC_InOut_Graph.h:45
read_lc_inout_graph_tag read_tag
Definition: LC_InOut_Graph.h:87
size_t idFromNode(GraphNode N)
Definition: LC_InOut_Graph.h:282
Super::const_iterator const_iterator
Definition: LC_InOut_Graph.h:84
void sortInEdgesByEdgeData(GraphNode N, const CompTy &comp=std::less< typename GraphTy::edge_data_type >(), MethodFlag mflag=MethodFlag::WRITE)
Sorts incoming edges of a node.
Definition: LC_InOut_Graph.h:214
void sortAllInEdgesByDst(MethodFlag mflag=MethodFlag::WRITE)
Sorts incoming edges of all nodes.
Definition: LC_InOut_Graph.h:275
Definition: LC_InOut_Graph.h:90
InGraph in_graph_type
Definition: LC_InOut_Graph.h:75
LC_InOut_Graph< typename GraphTy::template with_edge_data< _edge_data >::type > type
Definition: LC_InOut_Graph.h:52
Super::edge_data_type edge_data_type
Definition: LC_InOut_Graph.h:78
void sortInEdgesByDst(GraphNode N, MethodFlag mflag=MethodFlag::WRITE)
Sorts incoming edges of a node.
Definition: LC_InOut_Graph.h:252
friend class boost::iterator_core_access
Definition: LC_InOut_Graph.h:93
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
internal::InEdgesIterator< LC_InOut_Graph > in_edges(GraphNode N, MethodFlag mflag=MethodFlag::WRITE)
Definition: LC_InOut_Graph.h:205
void sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp)
Definition: ParallelSTL.h:247
Modify a LC_Graph to have in and out edges.
Definition: LC_InOut_Graph.h:39
LC_InOut_Graph()
Definition: LC_InOut_Graph.h:147
Proxy object for internal EdgeSortReference.
Definition: Details.h:56
in_edge_iterator(Iterator1 it, int)
Definition: LC_InOut_Graph.h:142
Definition: LC_InOut_Graph.h:49
MethodFlag
What should the runtime do when executing a method.
Definition: MethodFlags.h:34
Super::node_data_type node_data_type
Definition: LC_InOut_Graph.h:79
in_edge_iterator in_edge_begin(GraphNode N, MethodFlag mflag=MethodFlag::WRITE)
Definition: LC_InOut_Graph.h:169
Super::edge_iterator edge_iterator
Definition: LC_InOut_Graph.h:82
void do_all(const RangeFunc &rangeMaker, FunctionTy &&fn, const Args &...args)
Standard do-all loop.
Definition: Loops.h:71
Super::local_iterator local_iterator
Definition: LC_InOut_Graph.h:85
GraphNode getInEdgeDst(in_edge_iterator ni)
Definition: LC_InOut_Graph.h:160
unsigned int node_data_type
Definition: EdgeHostDecls.h:34
Super::file_edge_data_type file_edge_data_type
Definition: LC_InOut_Graph.h:77
in_edge_iterator in_edge_end(GraphNode N, MethodFlag mflag=MethodFlag::WRITE)
Definition: LC_InOut_Graph.h:194
friend void readGraphDispatch(G &, read_lc_inout_graph_tag, const std::string &, const std::string &)
Super::edge_data_reference edge_data_reference
Definition: LC_InOut_Graph.h:80
Super::const_local_iterator const_local_iterator
Definition: LC_InOut_Graph.h:86
in_edge_iterator(Iterator0 it)
Definition: LC_InOut_Graph.h:139
in_edge_iterator()
Definition: LC_InOut_Graph.h:138
auto iterate(C &cont)
Definition: Range.h:323
Super out_graph_type
Definition: LC_InOut_Graph.h:74
Super::GraphNode GraphNode
Definition: LC_InOut_Graph.h:76
unsigned edge_data_type
Definition: EdgeHostDecls.h:35
edge_data_reference getInEdgeData(in_edge_iterator ni, MethodFlag GALOIS_UNUSED(mflag)=MethodFlag::UNPROTECTED)
Definition: LC_InOut_Graph.h:150
Super::iterator iterator
Definition: LC_InOut_Graph.h:83
GraphNode nodeFromId(size_t N)
Definition: LC_InOut_Graph.h:284
Super::node_data_reference node_data_reference
Definition: LC_InOut_Graph.h:81
Definition: LC_InOut_Graph.h:42