<commit_before>/**
  * @file IntegerVectorEncoding.hpp
  * @brief encoder interface implementation
  */

#include "../include/IntegerVectorEncoding.hpp"

namespace clusterer
{
namespace backend
{

IntegerVectorEncoding::IntegerVectorEncoding(Graph& g) : graph(g), ClusterEncoding(g)
{
    // Set encoding to be as big as the vertex array
    encoding.resize(g.getNoVertices());
}

int IntegerVectorEncoding::addToCluster(VertexId vertexId, ClusterId clusterId)
{
    if (encoding.size() < vertexId)
    { return -1; }
    encoding[vertexId] = clusterId;
    return 0;
}

ClusterId IntegerVectorEncoding::getClusterOfVertex(VertexId vertexId)
{
    return encoding[vertexId];
}

std::vector<VertexId> IntegerVectorEncoding::getVerticesInCluster(ClusterId clusterId)
{
    std::vector<VertexId> result;
    //iterating through the encoding vector
    for (int i = 0; i < encoding.size(); i++)
    {
        //check if VertexId is in the cluster
        if (encoding[i] == clusterId)
        { result.push_back(i); }
    }
    return result;
}

ClusterEncoding::Encoding IntegerVectorEncoding::getEncoding()
{
    return encoding;
}

int IntegerVectorEncoding::normalize()
{
    std::map<ClusterId, VertexId> minVertex;
    VertexId i;

    // Find the minimum vertex id in each cluster
    for (i = 0; i < encoding.size(); i++)
    {
        if (minVertex.find(encoding[i]) == minVertex.end())
        {
            // Newly found cluster
            minVertex[encoding[i]] = i;
        }
        else if (i < minVertex[encoding[i]])<commit_msg>Fixed auto formatting mistakes.<commit_after>/**
  * @file IntegerVectorEncoding.hpp
  * @brief encoder interface implementation
  */

#include "../include/IntegerVectorEncoding.hpp"

namespace clusterer
{
namespace backend
{

IntegerVectorEncoding::IntegerVectorEncoding(Graph& g) : graph(g), ClusterEncoding(g)
{
    // Set encoding to be as big as the vertex array
    encoding.resize(g.getNoVertices());
}

int IntegerVectorEncoding::addToCluster(VertexId vertexId, ClusterId clusterId)
{
    if (encoding.size() < vertexId)
    {
        return -1;
    }
    encoding[vertexId] = clusterId;
    return 0;
}

ClusterId IntegerVectorEncoding::getClusterOfVertex(VertexId vertexId)
{
    return encoding[vertexId];
}

std::vector<VertexId> IntegerVectorEncoding::getVerticesInCluster(ClusterId clusterId)
{
    std::vector<VertexId> result;
    //iterating through the encoding vector
    for (int i = 0; i < encoding.size(); i++)
    {
        //check if VertexId is in the cluster
        if (encoding[i] == clusterId)
        {
            result.push_back(i);
        }
    }
    return result;
}

ClusterEncoding::Encoding IntegerVectorEncoding::getEncoding()
{
    return encoding;
}

int IntegerVectorEncoding::normalize()
{
    std::map<ClusterId, VertexId> minVertex;
    VertexId i;

    // Find the minimum vertex id in each cluster
    for (i = 0; i < encoding.size(); i++)
    {
        if (minVertex.find(encoding[i]) == minVertex.end())
        {
            // Newly found cluster
            minVertex[encoding[i]] = i;
        }
        else if (i < minVertex[encoding[i]])
{'fraction_non_alphanumeric': 0.11830357142857142, 'fraction_numerical': 0.002551020408163265, 'mean_word_length': 3.2564450474898234, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 9, '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': '6175404', 'n_tokens_mistral': 941, 'n_tokens_neox': 927, 'n_words': 230}