Galois
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FileGraph.h
Go to the documentation of this file.
1 /*
2  * This file belongs to the Galois project, a C++ library for exploiting
3  * parallelism. The code is being released under the terms of the 3-Clause BSD
4  * License (a copy is located in LICENSE.txt at the top-level directory).
5  *
6  * Copyright (C) 2018, The University of Texas at Austin. All rights reserved.
7  * UNIVERSITY EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES CONCERNING THIS
8  * SOFTWARE AND DOCUMENTATION, INCLUDING ANY WARRANTIES OF MERCHANTABILITY,
9  * FITNESS FOR ANY PARTICULAR PURPOSE, NON-INFRINGEMENT AND WARRANTIES OF
10  * PERFORMANCE, AND ANY WARRANTY THAT MIGHT OTHERWISE ARISE FROM COURSE OF
11  * DEALING OR USAGE OF TRADE. NO WARRANTY IS EITHER EXPRESS OR IMPLIED WITH
12  * RESPECT TO THE USE OF THE SOFTWARE OR DOCUMENTATION. Under no circumstances
13  * shall University be liable for incidental, special, indirect, direct or
14  * consequential damages or loss of profits, interruption of business, or
15  * related expenses which may arise from use of Software or Documentation,
16  * including but not limited to those resulting from defects in Software and/or
17  * Documentation, or loss or inaccuracy of data of any kind.
18  */
19 
28 #ifndef GALOIS_GRAPHS_FILEGRAPH_H
29 #define GALOIS_GRAPHS_FILEGRAPH_H
30 
31 #include <cstring>
32 #include <deque>
33 #include <type_traits>
34 #include <vector>
35 
36 #include <boost/iterator/counting_iterator.hpp>
37 #include <boost/iterator/transform_iterator.hpp>
38 
39 #include "galois/config.h"
40 #include "galois/Endian.h"
41 #include "galois/MethodFlags.h"
42 #include "galois/LargeArray.h"
43 #include "galois/graphs/Details.h"
45 #include "galois/runtime/Context.h"
49 #include "galois/Reduction.h"
50 
51 namespace galois {
52 namespace graphs {
53 
54 // XXX(ddn): Refactor to eliminate OCFileGraph
55 
57 class FileGraph {
58 public:
60  using GraphNode = uint64_t;
61 
62 private:
63  struct Convert32 : public std::unary_function<uint32_t, uint32_t> {
64  uint32_t operator()(uint32_t x) const { return convert_le32toh(x); }
65  };
66 
67  struct Convert64 : public std::unary_function<uint64_t, uint64_t> {
68  uint64_t operator()(uint64_t x) const { return convert_le64toh(x); }
69  };
70 
71  struct mapping {
72  void* ptr;
73  size_t len;
74  };
75 
76  std::deque<mapping> mappings;
77  std::deque<int> fds;
78 
80  uint64_t sizeofEdge;
82  uint64_t numNodes;
84  uint64_t numEdges;
85 
87  uint64_t* outIdx;
89  void* outs;
91  char* edgeData;
92 
94  int graphVersion;
95 
97  uint64_t nodeOffset;
99  uint64_t edgeOffset;
100 
101  // graph reading speed variables
102  galois::GAccumulator<uint64_t> numBytesReadIndex, numBytesReadEdgeDst,
103  numBytesReadEdgeData;
104 
109  void move_assign(FileGraph&&);
119  uint64_t getEdgeIdx(GraphNode src, GraphNode dst);
120 
127  void* raw_neighbor_begin(GraphNode N);
135  void* raw_neighbor_end(GraphNode N);
136 
141  void fromMem(void* m, uint64_t nodeOffset, uint64_t edgeOffset, uint64_t);
142 
151  void* fromGraph(FileGraph& g, size_t sizeofEdgeData);
152 
171  size_t findIndex(size_t nodeSize, size_t edgeSize, size_t targetSize,
172  size_t lb, size_t ub);
173 
174  void fromFileInterleaved(const std::string& filename, size_t sizeofEdgeData);
175 
185  void pageInByNode(size_t id, size_t total, size_t sizeofEdgeData);
186 
187 protected:
207  void* fromArrays(uint64_t* outIdx, uint64_t numNodes, void* outs,
208  uint64_t numEdges, char* edgeData, size_t sizeofEdgeData,
209  uint64_t nodeOffset, uint64_t edgeOffset, bool converted,
210  int oGraphVersion = 1);
211 
212 public:
217  numBytesReadEdgeDst.reset();
218  numBytesReadIndex.reset();
219  numBytesReadEdgeData.reset();
220  }
221 
225  uint64_t num_bytes_read() {
226  return numBytesReadEdgeDst.reduce() + numBytesReadEdgeData.reduce() +
227  numBytesReadIndex.reduce();
228  }
229 
230  // Node Handling
231 
233  bool containsNode(const GraphNode n) const {
234  return n + nodeOffset < numNodes;
235  }
236 
237  // Edge Handling
238 
240  template <typename EdgeTy>
241  EdgeTy& getEdgeData(GraphNode src, GraphNode dst) {
242  assert(sizeofEdge == sizeof(EdgeTy));
243  numBytesReadEdgeData += sizeof(EdgeTy);
244  return reinterpret_cast<EdgeTy*>(edgeData)[getEdgeIdx(src, dst)];
245  }
246 
248  using edge_iterator = boost::counting_iterator<uint64_t>;
249 
266 
272  return internal::make_no_deref_range(edge_begin(N), edge_end(N));
273  }
274 
280  return edges(N);
281  }
282 
286  template <typename EdgeTy, typename CompTy>
288  const CompTy& comp = std::less<EdgeTy>()) {
289  if (graphVersion == 1) {
290  typedef LargeArray<uint32_t> EdgeDst;
291  typedef LargeArray<EdgeTy> EdgeData;
292 
293  typedef internal::EdgeSortIterator<GraphNode, uint64_t, EdgeDst, EdgeData,
294  Convert32>
295  edge_sort_iterator;
296 
297  EdgeDst edgeDst(outs, numEdges);
298  EdgeData ed(edgeData, numEdges);
299 
300  edge_sort_iterator begin(
301  std::distance((uint32_t*)outs, (uint32_t*)raw_neighbor_begin(N)),
302  &edgeDst, &ed);
303  edge_sort_iterator end(
304  std::distance((uint32_t*)outs, (uint32_t*)raw_neighbor_end(N)),
305  &edgeDst, &ed);
306  std::sort(begin, end,
307  internal::EdgeSortCompWrapper<EdgeSortValue<GraphNode, EdgeTy>,
308  CompTy>(comp));
309  } else if (graphVersion == 2) {
310  typedef LargeArray<uint64_t> EdgeDst;
311  typedef LargeArray<EdgeTy> EdgeData;
312 
313  typedef internal::EdgeSortIterator<GraphNode, uint64_t, EdgeDst, EdgeData,
314  Convert64>
315  edge_sort_iterator;
316 
317  EdgeDst edgeDst(outs, numEdges);
318  EdgeData ed(edgeData, numEdges);
319 
320  edge_sort_iterator begin(
321  std::distance((uint64_t*)outs, (uint64_t*)raw_neighbor_begin(N)),
322  &edgeDst, &ed);
323  edge_sort_iterator end(
324  std::distance((uint64_t*)outs, (uint64_t*)raw_neighbor_end(N)),
325  &edgeDst, &ed);
326  std::sort(begin, end,
327  internal::EdgeSortCompWrapper<EdgeSortValue<GraphNode, EdgeTy>,
328  CompTy>(comp));
329  } else {
330  GALOIS_DIE("unknown file version: ", graphVersion);
331  }
332  }
333 
338  template <typename EdgeTy, typename CompTy>
339  void sortEdges(GraphNode N, const CompTy& comp) {
340  if (graphVersion == 1) {
341  typedef LargeArray<uint32_t> EdgeDst;
342  typedef LargeArray<EdgeTy> EdgeData;
343  typedef internal::EdgeSortIterator<GraphNode, uint64_t, EdgeDst, EdgeData,
344  Convert32>
345  edge_sort_iterator;
346 
347  EdgeDst edgeDst(outs, numEdges);
348  EdgeData ed(edgeData, numEdges);
349 
350  edge_sort_iterator begin(
351  std::distance((uint32_t*)outs, (uint32_t*)raw_neighbor_begin(N)),
352  &edgeDst, &ed);
353  edge_sort_iterator end(
354  std::distance((uint32_t*)outs, (uint32_t*)raw_neighbor_end(N)),
355  &edgeDst, &ed);
356  std::sort(begin, end, comp);
357  } else if (graphVersion == 2) {
358  typedef LargeArray<uint64_t> EdgeDst;
359  typedef LargeArray<EdgeTy> EdgeData;
360  typedef internal::EdgeSortIterator<GraphNode, uint64_t, EdgeDst, EdgeData,
361  Convert64>
362  edge_sort_iterator;
363 
364  EdgeDst edgeDst(outs, numEdges);
365  EdgeData ed(edgeData, numEdges);
366 
367  edge_sort_iterator begin(
368  std::distance((uint64_t*)outs, (uint64_t*)raw_neighbor_begin(N)),
369  &edgeDst, &ed);
370  edge_sort_iterator end(
371  std::distance((uint64_t*)outs, (uint64_t*)raw_neighbor_end(N)),
372  &edgeDst, &ed);
373  std::sort(begin, end, comp);
374  } else {
375  GALOIS_DIE("unknown file version: ", graphVersion);
376  }
377  }
378 
379  // template<typename EdgeTy>
380  // const EdgeTy& getEdgeData(edge_iterator it) const {
381  // assert(edgeData);
382  // return reinterpret_cast<const EdgeTy*>(edgeData)[*it];
383  //}
384 
386  template <typename EdgeTy>
388  assert(edgeData);
389  numBytesReadEdgeData += sizeof(EdgeTy);
390  return reinterpret_cast<EdgeTy*>(edgeData)[*it];
391  }
392 
400 
402  typedef boost::transform_iterator<Convert32, uint32_t*> neighbor_iterator;
404  typedef boost::transform_iterator<Convert32, uint32_t*> node_id_iterator;
406  typedef boost::transform_iterator<Convert64, uint64_t*> edge_id_iterator;
408  typedef boost::counting_iterator<uint64_t> iterator;
409 
416  return boost::make_transform_iterator((uint32_t*)raw_neighbor_begin(N),
417  Convert32());
418  }
419 
426  return boost::make_transform_iterator((uint32_t*)raw_neighbor_end(N),
427  Convert32());
428  }
429 
430  template <typename EdgeTy>
431  EdgeTy* edge_data_begin() const {
432  assert(edgeData);
433  return reinterpret_cast<EdgeTy*>(edgeData);
434  }
435 
436  template <typename EdgeTy>
437  EdgeTy* edge_data_end() const {
438  assert(edgeData);
439  assert(sizeof(EdgeTy) == sizeofEdge);
440  EdgeTy* r = reinterpret_cast<EdgeTy*>(edgeData);
441  return &r[numEdges];
442  }
443 
450  iterator begin() const;
457  iterator end() const;
458 
460  typedef std::pair<iterator, iterator> NodeRange;
462  typedef std::pair<edge_iterator, edge_iterator> EdgeRange;
464  typedef std::pair<NodeRange, EdgeRange> GraphRange;
465 
479  GraphRange divideByNode(size_t nodeSize, size_t edgeSize, size_t id,
480  size_t total);
481 
496  GraphRange divideByEdge(size_t nodeSize, size_t edgeSize, size_t id,
497  size_t total);
532 
542  bool hasNeighbor(GraphNode N1, GraphNode N2);
543 
545  size_t size() const { return numNodes; }
546 
548  size_t sizeEdges() const { return numEdges; }
549 
551  size_t edgeSize() const { return sizeofEdge; }
552 
556  FileGraph();
557 
563  FileGraph(const FileGraph&);
567  FileGraph& operator=(const FileGraph&);
571  FileGraph(FileGraph&&);
579  ~FileGraph();
580 
587  void fromFile(const std::string& filename);
588 
603  void partFromFile(const std::string& filename, NodeRange nrange,
604  EdgeRange erange, bool numaMap = false);
605 
612  template <typename EdgeTy>
614  const std::string& filename,
615  typename std::enable_if<!std::is_void<EdgeTy>::value>::type* = 0) {
616  fromFileInterleaved(filename, sizeof(EdgeTy));
617  }
618 
625  template <typename EdgeTy>
627  const std::string& filename,
628  typename std::enable_if<std::is_void<EdgeTy>::value>::type* = 0) {
629  fromFileInterleaved(filename, 0);
630  }
631 
636  template <typename T>
638  return reinterpret_cast<T*>(fromGraph(g, sizeof(T)));
639  }
640 
647  void toFile(const std::string& file);
648 };
649 
662 class FileGraphWriter : public FileGraph {
663  std::vector<uint64_t> outIdx;
664  std::vector<uint32_t> starts;
665  std::vector<uint32_t> outs;
666  std::vector<uint64_t> starts64;
667  std::vector<uint64_t> outs64;
668 
669  size_t sizeofEdgeData;
670  size_t numNodes;
671  size_t numEdges;
672 
673 public:
675  FileGraphWriter() : sizeofEdgeData(0), numNodes(0), numEdges(0) {}
676 
679  void setNumNodes(size_t n) { numNodes = n; }
682  void setNumEdges(size_t n) { numEdges = n; }
685  void setSizeofEdgeData(size_t n) { sizeofEdgeData = n; }
686 
689  void phase1() { outIdx.resize(numNodes); }
690 
692  void incrementDegree(size_t id, int delta = 1) {
693  assert(id < numNodes);
694  outIdx[id] += delta;
695  }
696 
698  void phase2() {
699  if (numNodes == 0)
700  return;
701 
702  // Turn counts into partial sums
703  auto prev = outIdx.begin();
704  for (auto ii = outIdx.begin() + 1, ei = outIdx.end(); ii != ei;
705  ++ii, ++prev) {
706  *ii += *prev;
707  }
708  assert(outIdx[numNodes - 1] == numEdges);
709 
710  if (numNodes <= std::numeric_limits<uint32_t>::max()) {
711  // version 1
712  starts.resize(numNodes);
713  outs.resize(numEdges);
714  } else {
715  // version 2
716  starts64.resize(numNodes);
717  outs64.resize(numEdges);
718  }
719  }
720 
722  size_t addNeighbor(size_t src, size_t dst) {
723  size_t base = src ? outIdx[src - 1] : 0;
724 
725  if (numNodes <= std::numeric_limits<uint32_t>::max()) {
726  // version 1
727  size_t idx = base + starts[src]++;
728  assert(idx < outIdx[src]);
729  outs[idx] = dst;
730  return idx;
731  } else {
732  // version 2
733  size_t idx = base + (starts64)[src]++;
734  assert(idx < outIdx[src]);
735  outs64[idx] = dst;
736  return idx;
737  }
738  }
739 
744  template <typename T>
745  T* finish() {
746  void* ret;
747  if (numNodes <= std::numeric_limits<uint32_t>::max()) {
748  // version 1
749  ret = fromArrays(&outIdx[0], numNodes, &outs[0], numEdges, nullptr,
750  sizeofEdgeData, 0, 0, false, 1);
751  starts.clear();
752  outs.clear();
753  } else {
754  // version 2
755  ret = fromArrays(&outIdx[0], numNodes, &outs64[0], numEdges, nullptr,
756  sizeofEdgeData, 0, 0, false, 2);
757  }
758 
759  outIdx.clear();
760  return reinterpret_cast<T*>(ret);
761  }
762 };
763 
769 template <typename EdgeTy>
770 void makeSymmetric(FileGraph& in_graph, FileGraph& out) {
771  typedef FileGraph::GraphNode GNode;
772  typedef LargeArray<EdgeTy> EdgeData;
773  typedef typename EdgeData::value_type edge_value_type;
774 
775  FileGraphWriter g;
776  EdgeData edgeData;
777 
778  size_t numEdges = 0;
779 
780  for (FileGraph::iterator ii = in_graph.begin(), ei = in_graph.end(); ii != ei;
781  ++ii) {
782  GNode src = *ii;
783  for (FileGraph::edge_iterator jj = in_graph.edge_begin(src),
784  ej = in_graph.edge_end(src);
785  jj != ej; ++jj) {
786  GNode dst = in_graph.getEdgeDst(jj);
787  numEdges += 1;
788  if (src != dst)
789  numEdges += 1;
790  }
791  }
792 
793  g.setNumNodes(in_graph.size());
794  g.setNumEdges(numEdges);
795  g.setSizeofEdgeData(EdgeData::has_value ? sizeof(edge_value_type) : 0);
796 
797  g.phase1();
798  for (FileGraph::iterator ii = in_graph.begin(), ei = in_graph.end(); ii != ei;
799  ++ii) {
800  GNode src = *ii;
801  for (FileGraph::edge_iterator jj = in_graph.edge_begin(src),
802  ej = in_graph.edge_end(src);
803  jj != ej; ++jj) {
804  GNode dst = in_graph.getEdgeDst(jj);
805  g.incrementDegree(src);
806  if (src != dst)
807  g.incrementDegree(dst);
808  }
809  }
810 
811  g.phase2();
812  edgeData.create(numEdges);
813  for (FileGraph::iterator ii = in_graph.begin(), ei = in_graph.end(); ii != ei;
814  ++ii) {
815  GNode src = *ii;
816  for (FileGraph::edge_iterator jj = in_graph.edge_begin(src),
817  ej = in_graph.edge_end(src);
818  jj != ej; ++jj) {
819  GNode dst = in_graph.getEdgeDst(jj);
820  if (EdgeData::has_value) {
821  edge_value_type& data = in_graph.getEdgeData<edge_value_type>(jj);
822  edgeData.set(g.addNeighbor(src, dst), data);
823  if (src != dst)
824  edgeData.set(g.addNeighbor(dst, src), data);
825  } else {
826  g.addNeighbor(src, dst);
827  if (src != dst)
828  g.addNeighbor(dst, src);
829  }
830  }
831  }
832 
833  edge_value_type* rawEdgeData = g.finish<edge_value_type>();
834  if (EdgeData::has_value)
835  std::uninitialized_copy(std::make_move_iterator(edgeData.begin()),
836  std::make_move_iterator(edgeData.end()),
837  rawEdgeData);
838 
839  out = std::move(g);
840 }
841 
853 template <typename EdgeTy, typename PTy>
854 void permute(FileGraph& in_graph, const PTy& p, FileGraph& out) {
855  typedef FileGraph::GraphNode GNode;
856  typedef LargeArray<EdgeTy> EdgeData;
857  typedef typename EdgeData::value_type edge_value_type;
858 
859  FileGraphWriter g;
860  EdgeData edgeData;
861 
862  size_t numEdges = in_graph.sizeEdges();
863  g.setNumNodes(in_graph.size());
864  g.setNumEdges(numEdges);
865  g.setSizeofEdgeData(EdgeData::has_value ? sizeof(edge_value_type) : 0);
866 
867  g.phase1();
868  for (FileGraph::iterator ii = in_graph.begin(), ei = in_graph.end(); ii != ei;
869  ++ii) {
870  GNode src = *ii;
871  for (FileGraph::edge_iterator jj = in_graph.edge_begin(src),
872  ej = in_graph.edge_end(src);
873  jj != ej; ++jj) {
874  g.incrementDegree(p[src]);
875  }
876  }
877 
878  g.phase2();
879  edgeData.create(numEdges);
880  for (FileGraph::iterator ii = in_graph.begin(), ei = in_graph.end(); ii != ei;
881  ++ii) {
882  GNode src = *ii;
883  for (FileGraph::edge_iterator jj = in_graph.edge_begin(src),
884  ej = in_graph.edge_end(src);
885  jj != ej; ++jj) {
886  GNode dst = in_graph.getEdgeDst(jj);
887  if (EdgeData::has_value) {
888  edge_value_type& data = in_graph.getEdgeData<edge_value_type>(jj);
889  edgeData.set(g.addNeighbor(p[src], p[dst]), data);
890  } else {
891  g.addNeighbor(p[src], p[dst]);
892  }
893  }
894  }
895 
896  edge_value_type* rawEdgeData = g.finish<edge_value_type>();
897  if (EdgeData::has_value)
898  std::uninitialized_copy(std::make_move_iterator(edgeData.begin()),
899  std::make_move_iterator(edgeData.end()),
900  rawEdgeData);
901 
902  out = std::move(g);
903 }
904 
905 } // namespace graphs
906 } // namespace galois
907 #endif
void fromFileInterleaved(const std::string &filename, typename std::enable_if<!std::is_void< EdgeTy >::value >::type *=0)
Reads graph connectivity information from file.
Definition: FileGraph.h:613
EdgeTy & getEdgeData(edge_iterator it)
Get edge data given an edge iterator.
Definition: FileGraph.h:387
EdgeTy * edge_data_end() const
Definition: FileGraph.h:437
std::pair< NodeRange, EdgeRange > GraphRange
pair of a NodeRange and an EdgeRange
Definition: FileGraph.h:464
std::pair< edge_iterator, edge_iterator > EdgeRange
pair specifying an edge range
Definition: FileGraph.h:462
neighbor_iterator neighbor_end(GraphNode N)
Gets an iterator to the end of node N&#39;s neighbors.
Definition: FileGraph.h:425
Simplifies writing graphs.
Definition: FileGraph.h:662
~FileGraph()
Destructor.
Definition: FileGraph.cpp:111
node_id_iterator node_id_end() const
Returns an iterator to the end of the node destination array.
Definition: FileGraph.cpp:688
void reset()
Definition: Reduction.h:113
uint64_t num_bytes_read()
Return all bytes read.
Definition: FileGraph.h:225
void permute(FileGraph &in_graph, const PTy &p, FileGraph &out)
Permutes a graph.
Definition: FileGraph.h:854
edge_iterator edge_begin(GraphNode N)
Returns the index to the beginning of global node N&#39;s outgoing edges in the outgoing edges array...
Definition: FileGraph.cpp:641
size_t size() const
Returns the number of nodes in the (sub)graph.
Definition: FileGraph.h:545
boost::counting_iterator< uint64_t > iterator
uint64 boost counting iterator
Definition: FileGraph.h:408
bool hasNeighbor(GraphNode N1, GraphNode N2)
Determines if an edge with source N1 and destination N2 existed in the currently loaded (local) graph...
Definition: FileGraph.cpp:701
void setSizeofEdgeData(size_t n)
Set the size of the edge data to write to n.
Definition: FileGraph.h:685
void phase2()
Marks the transition to next phase of parsing, adding edges.
Definition: FileGraph.h:698
void setNumNodes(size_t n)
Set number of nodes to write to n.
Definition: FileGraph.h:679
GraphNode getEdgeDst(edge_iterator it)
Gets the destination of some edge.
Definition: FileGraph.cpp:669
runtime::iterable< NoDerefIterator< edge_iterator > > out_edges(GraphNode N)
Returns the edges of node N as a range that can be iterated through by C++ foreach.
Definition: FileGraph.h:279
boost::counting_iterator< uint64_t > edge_iterator
Edge iterators (boost iterator)
Definition: FileGraph.h:248
Definition: Iterable.h:36
uint64_t GraphNode
type of a node
Definition: FileGraph.h:60
edge_id_iterator edge_id_end() const
Returns an iterator to the end of the array specifying the index into the destination array where a p...
Definition: FileGraph.cpp:697
boost::transform_iterator< Convert32, uint32_t * > neighbor_iterator
iterator over neighbors
Definition: FileGraph.h:402
void incrementDegree(size_t id, int delta=1)
Increments degree of id by delta.
Definition: FileGraph.h:692
#define GALOIS_DIE(...)
Definition: gIO.h:96
boost::transform_iterator< Convert64, uint64_t * > edge_id_iterator
edge iterator
Definition: FileGraph.h:406
void fromFileInterleaved(const std::string &filename, typename std::enable_if< std::is_void< EdgeTy >::value >::type *=0)
Reads graph connectivity information from file.
Definition: FileGraph.h:626
void * fromArrays(uint64_t *outIdx, uint64_t numNodes, void *outs, uint64_t numEdges, char *edgeData, size_t sizeofEdgeData, uint64_t nodeOffset, uint64_t edgeOffset, bool converted, int oGraphVersion=1)
Copies graph connectivity information from arrays.
Definition: FileGraph.cpp:212
size_t edgeSize() const
Returns the size of an edge.
Definition: FileGraph.h:551
void makeSymmetric(FileGraph &in_graph, FileGraph &out)
Adds reverse edges to a graph.
Definition: FileGraph.h:770
void sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp)
Definition: ParallelSTL.h:247
runtime::iterable< NoDerefIterator< edge_iterator > > edges(GraphNode N)
Returns the edges of node N as a range that can be iterated through by C++ foreach.
Definition: FileGraph.h:271
std::pair< iterator, iterator > NodeRange
pair specifying a node range
Definition: FileGraph.h:460
void phase1()
Marks the transition to next phase of parsing: counting the degree of nodes.
Definition: FileGraph.h:689
FileGraphWriter()
Constructor: initializes nodes, edges, and edge data to 0.
Definition: FileGraph.h:675
void toFile(const std::string &file)
Write current contents of mappings to a file.
Definition: FileGraph.cpp:510
GraphRange divideByEdge(size_t nodeSize, size_t edgeSize, size_t id, size_t total)
Divides nodes only considering edges.
Definition: FileGraph.cpp:489
boost::transform_iterator< Convert32, uint32_t * > node_id_iterator
iterator over node ids
Definition: FileGraph.h:404
neighbor_iterator neighbor_begin(GraphNode N)
Gets an iterator to the first neighbor of node N.
Definition: FileGraph.h:415
T * fromGraph(FileGraph &g)
Reads graph connectivity information from graph but not edge data.
Definition: FileGraph.h:637
void reset_byte_counters()
Reset the num bytes counters.
Definition: FileGraph.h:216
const Ty max(std::atomic< Ty > &a, const Ty &b)
Definition: AtomicHelpers.h:40
void sortEdges(GraphNode N, const CompTy &comp)
Sorts outgoing edges of a node.
Definition: FileGraph.h:339
Proxy object for internal EdgeSortReference.
Definition: Details.h:56
FileGraph()
Default file graph constructor which initializes fields to null values.
Definition: FileGraph.cpp:83
edge_id_iterator edge_id_begin() const
Returns an iterator to the beginning of the array specifying the index into the destination array whe...
Definition: FileGraph.cpp:693
FileGraph & operator=(const FileGraph &)
Copy constructor operator for FileGraph.
Definition: FileGraph.cpp:92
void operator()(void)
Definition: Executor_ParaMeter.h:417
void fromFile(const std::string &filename)
Given a file name, mmap the entire file into memory.
Definition: FileGraph.cpp:301
void setNumEdges(size_t n)
Set number of edges to write to n.
Definition: FileGraph.h:682
void sortEdgesByEdgeData(GraphNode N, const CompTy &comp=std::less< EdgeTy >())
Sorts outgoing edges of a node.
Definition: FileGraph.h:287
size_t addNeighbor(size_t src, size_t dst)
Adds a neighbor between src and dst.
Definition: FileGraph.h:722
void partFromFile(const std::string &filename, NodeRange nrange, EdgeRange erange, bool numaMap=false)
Loads/mmaps particular portions of a graph corresponding to a node range and edge range into memory...
Definition: FileGraph.cpp:375
EdgeTy & getEdgeData(GraphNode src, GraphNode dst)
Get edge data of an edge between 2 nodes.
Definition: FileGraph.h:241
iterator begin() const
Gets the first node of the loaded graph.
Definition: FileGraph.cpp:705
T & reduce()
Returns the final reduction value.
Definition: Reduction.h:102
iterator end() const
Gets the end of the nodes of the loaded graph.
Definition: FileGraph.cpp:707
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&#39;s outgoing edges in the outgoing edges array...
Definition: FileGraph.cpp:655
size_t sizeEdges() const
Returns the number of edges in the (sub)graph.
Definition: FileGraph.h:548
T * finish()
Finish making graph.
Definition: FileGraph.h:745
Graph that mmaps Galois gr files for access.
Definition: FileGraph.h:57
bool containsNode(const GraphNode n) const
Checks if a node is in the graph (already added)
Definition: FileGraph.h:233
T value_type
Definition: Executor_ParaMeter.h:111
EdgeTy * edge_data_begin() const
Definition: FileGraph.h:431
node_id_iterator node_id_begin() const
Returns an iterator to the beginning of the node destination array.
Definition: FileGraph.cpp:684