<commit_before>#include <iostream>
#include <fstream>
#include <cmath>
#include "../data/PathSerializer.hpp"
#include "GraphConverter.hpp"

namespace tsp
{

    GraphConverter::GraphConverter()
        : pathFile_(""), dataFile_(""), plotFile_(""), resultFile_("")
    {
    }

    GraphConverter::~GraphConverter()
    {
    }

    int GraphConverter::createPlot(Graph &graph, const std::string &pathFile,
                                   const std::string &resultFile)
    {
        pathFile_ = pathFile;
        dataFile_ = "tsp.dat";
        plotFile_ = "tsp.plt";
        resultFile_ = resultFile;

        // serialize path
        Path path;

        PathSerializer::load(path, pathFile_);

        // write *.dat file
        std::ofstream os(dataFile_);
        os << "#TSP Points\n";
        for(unsigned int i = 0; i < path.size(); ++i) {
            uint nodeId = path[i];
            if(nodeId < graph.size())
                os << graph[nodeId].x() << " " << graph[nodeId].y() << std::endl;
        }
        os.close();

        // write *.plt file
        /*
        set style line <index> {{linetype  | lt} <line_type> | <colorspec>}
                               {{linecolor | lc} <colorspec>}
                               {{linewidth | lw} <line_width>}
                               {{pointtype | pt} <point_type>}
                               {{pointsize | ps} <point_size>}
                               {palette}
        */

        int wHeight = 600, wWidth = 480;
        float density = (float)(wHeight * wWidth) / (path.size() - 1);
        float lineWidth = density / 3000, pointSize = density / 6000;

        os.open(plotFile_, std::ofstream::out);
        os << "set terminal svg size " << wWidth << "," << wHeight <<
           " fname 'Verdana' fsize 10" << std::endl;
        os << "set output '" << resultFile_ << "'" << std::endl;
        os << "set terminal svg enhanced background rgb 'white'" << std::endl;
        os << "set tics font ', 8'" << std::endl;
        os << "set nokey" << std::endl;
        os << "set title 'TSP Graph Visualisation (points: " << path.size() - 1 << ")'"
           << std::endl;
        os << "set style line 1 lc rgb '#0060ad' lt 1 lw " << lineWidth << " pt 7 ps "
           << pointSize << "   # --- blue" << std::endl;
        os << "plot '" << dataFile_ << "' with linespoints ls 1" << std::endl;<commit_msg>Change gnuplot commands<commit_after>#include <iostream>
#include <fstream>
#include <cmath>
#include "../data/PathSerializer.hpp"
#include "GraphConverter.hpp"

namespace tsp
{

    GraphConverter::GraphConverter()
        : pathFile_(""), dataFile_(""), plotFile_(""), resultFile_("")
    {
    }

    GraphConverter::~GraphConverter()
    {
    }

    int GraphConverter::createPlot(Graph &graph, const std::string &pathFile,
                                   const std::string &resultFile)
    {
        pathFile_ = pathFile;
        dataFile_ = "tsp.dat";
        plotFile_ = "tsp.plt";
        resultFile_ = resultFile;

        // serialize path
        Path path;

        PathSerializer::load(path, pathFile_);

        // write *.dat file
        std::ofstream os(dataFile_);
        os << "#TSP Points\n";
        for(unsigned int i = 0; i < path.size(); ++i) {
            uint nodeId = path[i];
            if(nodeId < graph.size())
                os << graph[nodeId].x() << " " << graph[nodeId].y() << std::endl;
        }
        os.close();

        // write *.plt file
        /*
        set style line <index> {{linetype  | lt} <line_type> | <colorspec>}
                               {{linecolor | lc} <colorspec>}
                               {{linewidth | lw} <line_width>}
                               {{pointtype | pt} <point_type>}
                               {{pointsize | ps} <point_size>}
                               {palette}
        */

        int wHeight = 600, wWidth = 480;
        float density = (float)(wHeight * wWidth) / (path.size() - 1);
        float lineWidth = density / 3000, pointSize = density / 6000;

        os.open(plotFile_, std::ofstream::out);
        os << "set terminal svg size " << wWidth << "," << wHeight <<
           " fname 'Verdana' fsize 10" << std::endl;
        os << "set output '" << resultFile_ << "'" << std::endl;
        os << "set terminal svg enhanced background rgb 'white'" << std::endl;
        os << "set tics font ', 8'" << std::endl;
        os << "unset key" << std::endl;
        os << "set title 'TSP Graph Visualisation (points: " << path.size() - 1 << ")'"
           << std::endl;
        os << "set style line 1 lc rgb '#0060ad' lt 1 lw " << lineWidth << " pt 7 ps "
           << pointSize << "   # --- blue" << std::endl;
        os << "plot '" << dataFile_ << "' with linespoints ls 1" << std::endl;
	os << "quit" << std::endl;
{'fraction_non_alphanumeric': 0.1619659892160929, 'fraction_numerical': 0.011613438407299876, 'mean_word_length': 1.8024404416037187, 'pattern_counts': {'":': 0, '<': 171, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5374097', 'n_tokens_mistral': 1520, 'n_tokens_neox': 1423, 'n_words': 368}