<commit_before>        #include "Graph.h"

Graph::Graph() {}
Graph::~Graph() {
  for (auto &i : _nodes) {
    delete i.second;
  }
}

Graph::Node* Graph::addNode(const int& id) {
  auto node = getNode(id);
  if (node == nullptr) {
    node = new Node();
    _nodes[id] = node;
  }

  return node;
}

Graph::Node* Graph::getNode(const int& id) {
  auto iter = _nodes.find(id);
  if (iter == _nodes.end()) {
    return nullptr;
  }
  
  return iter->second;
}

int Graph::addLink(const int& fromId, const int &toId) {
  auto fromNode = addNode(fromId);
  auto toNode = addNode(toId);

  fromNode->outNodes.insert(toId);
  toNode->inNodes.insert(fromId);
  
  return getLinkId(fromId, toId);
}

int Graph::getLinkId(const int& fromId, const int &toId) {
  // TODO: Should I inline this?
  return fromId ^ (toId << 1);
}

bool Graph::hasLink(const int& fromId, const int &toId) {
  auto fromNode = getNode(fromId);
  if (fromNode == nullptr) return false;
  
  return fromNode->outNodes.find(toId) != fromNode->outNodes.end();
}<commit_msg>better seed.<commit_after>        #include "Graph.h"

Graph::Graph() {}
Graph::~Graph() {
  for (auto &i : _nodes) {
    delete i.second;
  }
}

Graph::Node* Graph::addNode(const int& id) {
  auto node = getNode(id);
  if (node == nullptr) {
    node = new Node();
    _nodes[id] = node;
  }

  return node;
}

Graph::Node* Graph::getNode(const int& id) {
  auto iter = _nodes.find(id);
  if (iter == _nodes.end()) {
    return nullptr;
  }
  
  return iter->second;
}

int Graph::addLink(const int& fromId, const int &toId) {
  auto fromNode = addNode(fromId);
  auto toNode = addNode(toId);

  fromNode->outNodes.insert(toId);
  toNode->inNodes.insert(fromId);
  
  return getLinkId(fromId, toId);
}

int Graph::getLinkId(const int& fromId, const int &toId) {
  int seed = 0;
  seed ^= fromId + 0x9e3779b9 + (seed << 6) + (seed >> 2);
  seed ^= toId + 0x9e3779b9 + (seed << 6) + (seed >> 2);
  return seed;
}

bool Graph::hasLink(const int& fromId, const int &toId) {
  auto fromNode = getNode(fromId);
  if (fromNode == nullptr) return false;
  
  return fromNode->outNodes.find(toId) != fromNode->outNodes.end();
}
{'fraction_non_alphanumeric': 0.16620241411327763, 'fraction_numerical': 0.009285051067780872, 'mean_word_length': 3.594882729211087, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, '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': '1010375', 'n_tokens_mistral': 827, 'n_tokens_neox': 812, 'n_words': 199}