<commit_before>#include "geometry/RipsExpander.hh"

#include "filtrations/Data.hh"

#include "topology/io/EdgeLists.hh"

#include "persistentHomology/Calculation.hh"

#include "topology/Simplex.hh"
#include "topology/SimplicialComplex.hh"

#include <iostream>
#include <fstream>
#include <string>

using DataType          = double;
using VertexType        = unsigned;

using Simplex           = aleph::topology::Simplex<DataType, VertexType>;
using SimplicialComplex = aleph::topology::SimplicialComplex<Simplex>;

int main( int argc, char** argv )
{
  if( argc <= 1 )
    return -1;

  aleph::io::EdgeListReader reader;

  std::string input = argv[1];
  std::ifstream in( input );

  std::cerr << "* Reading '" << input << "'...";

  SimplicialComplex K;
  reader( in, K );

  std::cerr << "finished\n"
            << "* Extracted simplicial complex with " << K.size() << " simplices\n";

  std::cerr << "* Expanding simplicial complex...";

  // TODO: Make expansion configurable
  aleph::geometry::RipsExpander<SimplicialComplex> ripsExpander;
  K = ripsExpander( K, 2 );
  K = ripsExpander.assignMaximumWeight( K );

  std::cerr << "...finished\n"
            << "* Expanded complex has " << K.size() << " simplices\n";

  std::cerr << "* Establishing filtration order...";

  K.sort(
    aleph::filtrations::Data<Simplex>()
  );

  std::cerr << "...finished\n";

  std::cerr << "* Calculating persistent homology...";

  auto diagrams
    = aleph::calculatePersistenceDiagrams( K );

  std::cerr << "...finished\n";

  for( auto&& D : diagrams )
  {
    D.removeDiagonal();

    std::cout << "# Persistence diagram <" << input << ">\n"
              << "#\n"
              << "# Dimension: " << D.dimension() << "\n"
              << "# Entries  : " << D.size() << "\n"
              << D << "\n\n";
  }
}
<commit_msg>Added Betti number calculation to network analysis example<commit_after>#include "geometry/RipsExpander.hh"

#include "filtrations/Data.hh"

#include "topology/io/EdgeLists.hh"

#include "persistentHomology/Calculation.hh"

#include "topology/Simplex.hh"
#include "topology/SimplicialComplex.hh"

#include <iostream>
#include <fstream>
#include <string>

using DataType          = double;
using VertexType        = unsigned;

using Simplex           = aleph::topology::Simplex<DataType, VertexType>;
using SimplicialComplex = aleph::topology::SimplicialComplex<Simplex>;

int main( int argc, char** argv )
{
  if( argc <= 1 )
    return -1;

  aleph::io::EdgeListReader reader;

  std::string input = argv[1];
  std::ifstream in( input );

  std::cerr << "* Reading '" << input << "'...";

  SimplicialComplex K;
  reader( in, K );

  std::cerr << "finished\n"
            << "* Extracted simplicial complex with " << K.size() << " simplices\n";

  std::cerr << "* Expanding simplicial complex...";

  // TODO: Make expansion configurable
  aleph::geometry::RipsExpander<SimplicialComplex> ripsExpander;
  K = ripsExpander( K, 2 );
  K = ripsExpander.assignMaximumWeight( K );

  std::cerr << "...finished\n"
            << "* Expanded complex has " << K.size() << " simplices\n";

  std::cerr << "* Establishing filtration order...";

  K.sort(
    aleph::filtrations::Data<Simplex>()
  );

  std::cerr << "...finished\n";

  std::cerr << "* Calculating persistent homology...";

  auto diagrams
    = aleph::calculatePersistenceDiagrams( K );

  std::cerr << "...finished\n";

  for( auto&& D : diagrams )
  {
    D.removeDiagonal();

    std::cout << "# Persistence diagram <" << input << ">\n"
              << "#\n"
              << "# Dimension   : " << D.dimension() << "\n"
              << "# Entries     : " << D.size() << "\n"
              << "# Betti number: " << D.betti() << "\n"
              << D << "\n\n";
  }
}

{'fraction_non_alphanumeric': 0.1816728822589238, 'fraction_numerical': 0.002131060202450719, 'mean_word_length': 2.9735449735449735, 'pattern_counts': {'":': 0, '<': 139, '<?xml version=': 0, '>': 19, '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': '4304834', 'n_tokens_mistral': 1301, 'n_tokens_neox': 1216, 'n_words': 265}