<commit_before>#ifndef _ordering_io_cpp_included_
#define _ordering_io_cpp_included_

// c++ header files
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>

// my header files
#include "ordering-io.hpp"
#include "ordering-tools.hpp"

// namespaces
using namespace std;


//********************************************///

vector<int> OrderVector(int l1,int l2,int w,int n){

  int i;
  vector<int> ordvec(n);

  for(i=0;i<n;i++)
    ordvec[i] = i;

  for(i=0;i<w;i++){

    swap( ordvec[ l1 + i ], ordvec[ l2 + i ]);

  }

  return ordvec;

}


/****************************************************************/

 vector<int> GetNodeOrder(const vector<int>& kernelOrder,
                          const vector<int>& klines,
			   int netSize, int option){
   //kernelOrder is kernel order
   //netSize is total number of nodes <= KernelOrder.size()
   //option:
   //0: means  nodeOrder[originalposition]=currentposition
   //1: means nodeOrder[currentposition]=originalposition

   int i,j,k,jmax;
   vector<int> nodeOrder(netSize);

   switch(option){

   case 0:

     k=0;
     for(i=0;i<kernelOrder.size();i++){
       
       jmax=netSize-klines[kernelOrder[i]];
       if(kernelOrder[i]!=kernelOrder.size()-1) 
	 jmax=klines[kernelOrder[i]+1]-klines[kernelOrder[i]];
       
       for(j=0;j<jmax;j++){
	 nodeOrder[klines[kernelOrder[i]]+j]=k;
 	 k++;
       }
       
     }

     break;
   case 1:

     k=0;

     for(i=0;i<kernelOrder.size();i++){
       jmax=netSize-klines[kernelOrder[i]];

       if(kernelOrder[i]!=kernelOrder.size()-1) 
	 jmax=klines[kernelOrder[i]+1]-klines[kernelOrder[i]];
       for(j=0;j<jmax;j++){
	 nodeOrder[k]=klines[kernelOrder[i]]+j;

	 k++;
       }
       
     }
   }

   return nodeOrder;

 }

/*********************************************************************/

vector< vector<int> > GetKernels( vector<double>& similarityMatrix,
				  vector<int>& originalOrder,
				  vector <int>& klines, int& n,
				  vector<int>& translationTable ){
  int nn=n,i,j;
  vector<int> kernelsize,knodelist;
  vector<vector<int> > kernelList;//list of nodes inside each kernel
  vector<int> kernelOrder;//order of the kernels
  vector<int> kkline;//list of lines at which each kernel starts
  vector<int> assignedNodes;//previously assigned nodes
  vector<double> similarityMatrixNew (nn*nn, 0.); //we create new matrix reordered by kernels
  vector<int> translationTableNew(nn);//and update translation table to new order

  int kernelCount, nodeCount;
  nodeCount =0;
  kernelCount =0;
  int k;
  for (i=0;i<nn; i++){
//     cout<<i<<" "<<nn<<endl;
    if(find(assignedNodes.begin(),assignedNodes.end(),i) == assignedNodes.end()){
      knodelist.push_back(nodeCount);
      kkline.push_back(nodeCount);
      kernelOrder.push_back(kernelCount);
      assignedNodes.push_back(i);<commit_msg>more inconsequential changes in spacing<commit_after>#ifndef _ordering_io_cpp_included_
#define _ordering_io_cpp_included_

// c++ header files
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>

// my header files
#include "ordering-io.hpp"
#include "ordering-tools.hpp"

// namespaces
using namespace std;


//********************************************///

vector<int> OrderVector(int l1,int l2,int w,int n){

  int i;
  vector<int> ordvec(n);

  for(i=0;i<n;i++)
    ordvec[i] = i;

  for(i=0;i<w;i++){

    swap( ordvec[ l1 + i ], ordvec[ l2 + i ]);

  }

  return ordvec;

}


/****************************************************************/

vector<int> GetNodeOrder(const vector<int>& kernelOrder,
                         const vector<int>& klines,
                         int netSize,
                         int option){
   //kernelOrder is kernel order
   //netSize is total number of nodes <= KernelOrder.size()
   //option:
   //0: means  nodeOrder[originalposition]=currentposition
   //1: means nodeOrder[currentposition]=originalposition

  int i,j,k,jmax;
  vector<int> nodeOrder(netSize);

  switch(option){

  case 0:

    k=0;
    for(i=0;i<kernelOrder.size();i++){
       
      if(kernelOrder[i]!=kernelOrder.size()-1)
        jmax=klines[kernelOrder[i]+1]-klines[kernelOrder[i]];
      else
        jmax=netSize-klines[kernelOrder[i]];
       
      for(j=0;j<jmax;j++){
        nodeOrder[klines[kernelOrder[i]]+j]=k;
        k++;
      }
       
    }

    break;
  
  case 1:

    k=0;
    for(i=0;i<kernelOrder.size();i++){

      if(kernelOrder[i]!=kernelOrder.size()-1)
        jmax=klines[kernelOrder[i]+1]-klines[kernelOrder[i]];
      else
        jmax=netSize-klines[kernelOrder[i]];
      
      for(j=0;j<jmax;j++){
        nodeOrder[k]=klines[kernelOrder[i]]+j;
        k++;
      }
       
    }
  }

  return nodeOrder;
}

/*********************************************************************/

vector< vector<int> > GetKernels( vector<double>& similarityMatrix,
				  vector<int>& originalOrder,
				  vector <int>& klines, int& n,
				  vector<int>& translationTable ){
  int nn=n,i,j;
  vector<int> kernelsize,knodelist;
  vector<vector<int> > kernelList;//list of nodes inside each kernel
  vector<int> kernelOrder;//order of the kernels
  vector<int> kkline;//list of lines at which each kernel starts
  vector<int> assignedNodes;//previously assigned nodes
  vector<double> similarityMatrixNew (nn*nn, 0.); //we create new matrix reordered by kernels
  vector<int> translationTableNew(nn);//and update translation table to new order

  int kernelCount, nodeCount;
  nodeCount =0;
  kernelCount =0;
  int k;
  for (i=0;i<nn; i++){
//     cout<<i<<" "<<nn<<endl;
    if(find(assignedNodes.begin(),assignedNodes.end(),i) == assignedNodes.end()){
      knodelist.push_back(nodeCount);
      kkline.push_back(nodeCount);
      kernelOrder.push_back(kernelCount);
      assignedNodes.push_back(i);
{'fraction_non_alphanumeric': 0.20223221722472098, 'fraction_numerical': 0.0079960019990005, 'mean_word_length': 3.5484848484848484, 'pattern_counts': {'":': 0, '<': 93, '<?xml version=': 0, '>': 61, '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': '6060477', 'n_tokens_mistral': 2131, 'n_tokens_neox': 1985, 'n_words': 401}