<commit_before>/**
 * Syntax
 * node <this_file_path> <graph_file_path>
*/

// load parameters
var graphFilePath = process.argv[2];

// dependencies
fs = require('fs');

// validations
if (!graphFilePath) {
  throw new Error('Missing graphFilePath parameter');
}

fs.readFile(graphFilePath, 'utf8', function (err,data) {
  if (err) {
    return console.log(err);
  }

  data = data.split('\n');

  var graphModule = require('../../libNode/EuclideanGraph.js');
  var graph = new graphModule.EuclideanGraph(data);

  console.time('nearestNeighborCycle');
  var nearestNeighborCycle = graph.getNearestNeighborCycle();
  console.timeEnd('nearestNeighborCycle');

  console.time('2OPT');
  var opt2Cycle = graph.get2Opt(nearestNeighborCycle);
  console.timeEnd('2OPT');

  opt2Cycle.pop(); // removes last element, which is equal to the first

  console.log(opt2Cycle.join(' '));
  console.log('Numero de elementos: ' + opt2Cycle.length);
});
<commit_msg>Executing 2-opt seven times in example<commit_after>/**
 * Syntax
 * node <this_file_path> <graph_file_path>
*/

// load parameters
var graphFilePath = process.argv[2];

// dependencies
fs = require('fs');

// validations
if (!graphFilePath) {
  throw new Error('Missing graphFilePath parameter');
}

fs.readFile(graphFilePath, 'utf8', function (err,data) {
  if (err) {
    return console.log(err);
  }

  data = data.split('\n');

  var graphModule = require('../../libNode/EuclideanGraph.js');
  var graph = new graphModule.EuclideanGraph(data);

  console.time('nearestNeighborCycle');
  var nearestNeighborCycle = graph.getNearestNeighborCycle();
  console.timeEnd('nearestNeighborCycle');

  console.time('2OPT');
  var opt2Cycle = graph.get2Opt(nearestNeighborCycle);
  for(var i = 0; i < 6; i++)
  {
    opt2Cycle = graph.get2Opt(opt2Cycle);
  }  
  console.timeEnd('2OPT');

  opt2Cycle.pop(); // removes last element, which is equal to the first

  console.log(opt2Cycle.join(' '));
  console.log('Numero de elementos: ' + opt2Cycle.length);
});

{'fraction_non_alphanumeric': 0.15553339980059822, 'fraction_numerical': 0.011964107676969093, 'mean_word_length': 4.46866485013624, 'pattern_counts': {'":': 0, '<': 8, '<?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': '1528374', 'n_tokens_mistral': 702, 'n_tokens_neox': 674, 'n_words': 139}