<commit_before>#ifndef _DIRECTEDGRAPH_H_
#define _DIRECTEDGRAPH_H_

#include <Graph.h>

class DirectedGraph : public Graph {
 public:
  DirectedGraph(int _id = 0);
  DirectedGraph(const DirectedGraph & other);

  std::shared_ptr<Graph> createSimilar() const override;
  Graph * copy() const override { return new DirectedGraph(*this); }
  bool isDirected() const override { return true; }
  
  int addEdge(int n1, int n2, int face = -1, float weight = 1.0f, int arc = 0) override {
    assert(n1 != -1 && n2 != -1);
    int edge = (int)edge_attributes.size();
    int next_node_edge = getNodeFirstEdge(n1);
    node_geometry2[n1].first_edge = edge;
    int next_face_edge = -1;
    if (face != -1) next_face_edge = getFaceFirstEdge(face);

    node_geometry2[n1].outdegree += weight;
    total_outdegree += weight;
    if (getNodeSizeMethod().definedForSource()) {
      updateNodeSize(n1);
    }

    node_geometry2[n2].indegree += weight;
    total_indegree += weight;
    if (getNodeSizeMethod().definedForTarget()) {
      updateNodeSize(n2);	
    }
    
    edge_attributes.push_back(edge_data_s( weight, n1, n2, next_node_edge, face, next_face_edge, arc ));
    edges.addRow();
    total_edge_weight += fabsf(weight);

    if (face != -1) {
      face_attributes[face].first_edge = edge;
    }
<commit_msg>use methods from Graph to update degrees and node edges<commit_after>#ifndef _DIRECTEDGRAPH_H_
#define _DIRECTEDGRAPH_H_

#include <Graph.h>

class DirectedGraph : public Graph {
 public:
  DirectedGraph(int _id = 0);
  DirectedGraph(const DirectedGraph & other);

  std::shared_ptr<Graph> createSimilar() const override;
  Graph * copy() const override { return new DirectedGraph(*this); }
  bool isDirected() const override { return true; }
  
  int addEdge(int n1, int n2, int face = -1, float weight = 1.0f, int arc = 0) override {
    assert(n1 != -1 && n2 != -1);
    int edge = (int)edge_attributes.size();
    int next_node_edge = getNodeFirstEdge(n1);
    int next_face_edge = -1;
    if (face != -1) next_face_edge = getFaceFirstEdge(face);

    setNodeFirstEdge(n1, edge);
    updateOutdegree(n1, weight);
    if (getNodeArray().getNodeSizeMethod().definedForSource()) {
      updateNodeSize(n1);
    }
    updateIndegree(n2, weight);
    if (getNodeArray().getNodeSizeMethod().definedForTarget()) {
      updateNodeSize(n2);	
    }
    
    edge_attributes.push_back(edge_data_s( weight, n1, n2, next_node_edge, face, next_face_edge, arc ));
    edges.addRow();
    total_edge_weight += fabsf(weight);

    if (face != -1) {
      face_attributes[face].first_edge = edge;
    }

{'fraction_non_alphanumeric': 0.1264411990776326, 'fraction_numerical': 0.0180630284396618, 'mean_word_length': 3.829313543599258, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '320117', 'n_tokens_mistral': 906, 'n_tokens_neox': 891, 'n_words': 203}