<commit_before>//
// George 'papanikge' Papanikolaou
// CEID Advance Algorithm Design Course 2014
// Library of Efficient Data types and Algorithms (LEDA) testing
//

#include "basic.h"
#include <LEDA/system/timer.h>
#include <iostream>
#include <cmath>

/*
 * Constructing hard graphs with k connected cliques.
 * Of course they should have k SCC.
 *
 * @k : number of cliques
 * @n : number of nodes in the graph
 */
static void construct_cliqued_graph(leda::graph& G, int k, long n)
{
    int i, j;
    leda::node f, v, w;
    long nodes_per_clique = n/k;

    /* Constructing the initial nodes that will connect the cliques */
    f = G.new_node();
    for (i = 1; i < k; i++) {
        v = G.new_node();
        G.new_edge(f,v);
        // Constructing clique
        for (j = 0; j < nodes_per_clique; j++) {
            w = G.new_node();
            G.new_edge(w,f); // TODO: merge. connect others.
            G.new_edge(f,w);
        }
        f = v;
    }
}

/*
 * This function run the two implementations of the algorithm sequentially and checks their output.
 */
static void test_implementations(leda::graph& G, leda::node_array<int>& sccnum)
{
    float T;
    int mine, leda;

    T = leda::used_time();
    leda = leda::STRONG_COMPONENTS(G, sccnum);
    std::cout << "\t\tLEDA Strong-Components: " << leda << " -- Time to calculate: " << leda::used_time(T) << std::endl;
    sccnum.init(G, 0);
    mine = my_STRONG_COMPONENTS(G, sccnum);
    std::cout << "\t\tMy   Strong-Components: " << mine << " -- Time to calculate: " << leda::used_time(T) << std::endl;
}

int main()
{
    int i, j, e;
    int N[] = { 20000, 40000, 90000 };
    int K[] = { 5, 10, 20 };
    leda::graph G, T;
    leda::node t, s;<commit_msg>split the creation of cliques to a function<commit_after>//
// George 'papanikge' Papanikolaou
// CEID Advance Algorithm Design Course 2014
// Library of Efficient Data types and Algorithms (LEDA) testing
//

#include "basic.h"
#include <LEDA/system/timer.h>
#include <iostream>
#include <cmath>

/*
 * Internal auxiliary function to construct a clique around a node
 */
static void generate_clique(leda::graph& G, leda::node& v, int nodes_per_clique)
{
    int i;
    leda::node w, r;
    leda::list<leda::node> L;

    // Constructing clique
    for (i = 0; i < nodes_per_clique; i++) {
        w = G.new_node();
        // bidirectional
        G.new_edge(w,v);
        G.new_edge(v,w);
        // keeping it for later, so we can fill in the missing edges
        L.append(w);
    }

    // Inserting missing edges (to itself included)
    forall(r, L) {
        forall(w, L) {
            if (r == w)
                continue;
            G.new_edge(r,w);
        }
    }
}

/*
 * Constructing hard graphs with k connected cliques.
 * Of course they should have k SCC.
 *
 * @k : number of cliques
 * @n : number of nodes in the graph
 */
static void construct_cliqued_graph(leda::graph& G, int k, long n)
{
    int i;
    leda::node f, v;
    long nodes_per_clique = n/k;

    /* Constructing the initial nodes that will connect the cliques */
    f = G.new_node();
    generate_clique(G, f, nodes_per_clique);
    for (i = 1; i < k; i++) {
        v = G.new_node();
        G.new_edge(f,v);
        generate_clique(G, v, nodes_per_clique);
        f = v;
    }
}

/*
 * This function run the two implementations of the algorithm sequentially and checks their output.
 */
static void test_implementations(leda::graph& G, leda::node_array<int>& sccnum)
{
    float T;
    int mine, leda;

    T = leda::used_time();
    leda = leda::STRONG_COMPONENTS(G, sccnum);
    std::cout << "\t\tLEDA Strong-Components: " << leda << " -- Time to calculate: " << leda::used_time(T) << std::endl;
    sccnum.init(G, 0);
    mine = my_STRONG_COMPONENTS(G, sccnum);
    std::cout << "\t\tMy   Strong-Components: " << mine << " -- Time to calculate: " << leda::used_time(T) << std::endl;
}

int main()
{
    int i, j, e;
    int N[] = { 20000, 40000, 90000 };
    int K[] = { 5, 10, 20 };
    leda::graph G, T;
    leda::node t, s;
{'fraction_non_alphanumeric': 0.14698616600790515, 'fraction_numerical': 0.0133399209486166, 'mean_word_length': 2.599111111111111, 'pattern_counts': {'":': 0, '<': 56, '<?xml version=': 0, '>': 12, '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': '2378162', 'n_tokens_mistral': 1514, 'n_tokens_neox': 1441, 'n_words': 426}