<commit_before>#pragma once

#include <Communicator.hpp>
#include <Addressing.hpp>
#include <Collective.hpp>
#include <ParallelLoop.hpp>
#include <GlobalAllocator.hpp>
#include <Delegate.hpp>
#include <AsyncDelegate.hpp>
#include <Array.hpp>

#include <algorithm>

#include "common.h"

// #define USE_MPI3_COLLECTIVES
#undef USE_MPI3_COLLECTIVES
#ifdef USE_MPI3_COLLECTIVES
#include <mpi.h>
#endif

using namespace Grappa;

struct Vertex {
  int64_t * local_adj; // adjacencies that are local
  int64_t nadj;        // number of adjacencies
  int64_t local_sz;    // size of local allocation (regardless of how full it is)
  // int64_t parent;
  void * vertex_data;
  
  Vertex(): local_adj(nullptr), nadj(0), local_sz(0) {}    
  ~Vertex() {}
  
  template< typename F >
  void forall_adj(F body) {
    for (int64_t i=0; i<nadj; i++) {
      body(local_adj[i]);
    }
  }
  
  auto adj_iter() -> decltype(util::iterator(local_adj)) { return util::iterator(local_adj, nadj); }
};

// vertex with parent
struct VertexP : public Vertex {
  VertexP(): Vertex() { parent(-1); }
  int64_t parent() { return (int64_t)vertex_data; }
  void parent(int64_t parent) { vertex_data = (void*)parent; }
};

template< class V = Vertex >
struct Graph {
  static_assert(block_size % sizeof(V) == 0, "V size not evenly divisible into blocks!");
  
  // // Helpers (for if we go with custom cyclic distribution)
  // inline Core    vertex_owner (int64_t v) { return v % cores(); }
  // inline int64_t vertex_offset(int64_t v) { return v / cores(); }
  
  // Fields
  GlobalAddress<V> vs;
  int64_t nv, nadj, nadj_local;
  
  // Internal fields<commit_msg>oops, fix another use of util::iterator->iterate<commit_after>#pragma once

#include <Communicator.hpp>
#include <Addressing.hpp>
#include <Collective.hpp>
#include <ParallelLoop.hpp>
#include <GlobalAllocator.hpp>
#include <Delegate.hpp>
#include <AsyncDelegate.hpp>
#include <Array.hpp>

#include <algorithm>

#include "common.h"

// #define USE_MPI3_COLLECTIVES
#undef USE_MPI3_COLLECTIVES
#ifdef USE_MPI3_COLLECTIVES
#include <mpi.h>
#endif

using namespace Grappa;

struct Vertex {
  int64_t * local_adj; // adjacencies that are local
  int64_t nadj;        // number of adjacencies
  int64_t local_sz;    // size of local allocation (regardless of how full it is)
  // int64_t parent;
  void * vertex_data;
  
  Vertex(): local_adj(nullptr), nadj(0), local_sz(0) {}    
  ~Vertex() {}
  
  template< typename F >
  void forall_adj(F body) {
    for (int64_t i=0; i<nadj; i++) {
      body(local_adj[i]);
    }
  }
  
  auto adj_iter() -> decltype(util::iterate(local_adj)) { return util::iterate(local_adj, nadj); }
};

// vertex with parent
struct VertexP : public Vertex {
  VertexP(): Vertex() { parent(-1); }
  int64_t parent() { return (int64_t)vertex_data; }
  void parent(int64_t parent) { vertex_data = (void*)parent; }
};

template< class V = Vertex >
struct Graph {
  static_assert(block_size % sizeof(V) == 0, "V size not evenly divisible into blocks!");
  
  // // Helpers (for if we go with custom cyclic distribution)
  // inline Core    vertex_owner (int64_t v) { return v % cores(); }
  // inline int64_t vertex_offset(int64_t v) { return v / cores(); }
  
  // Fields
  GlobalAddress<V> vs;
  int64_t nv, nadj, nadj_local;
  
  // Internal fields
{'fraction_non_alphanumeric': 0.13222390317700453, 'fraction_numerical': 0.019364599092284416, 'mean_word_length': 3.840409956076135, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1198184', 'n_tokens_mistral': 1231, 'n_tokens_neox': 1185, 'n_words': 312}