<commit_before>/*
 Petar 'PetarV' Velickovic
 Linear Programming TSP Solver (Dantzig-Fulkerson-Johnson)
*/

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <assert.h>
#include <unistd.h>
#include <iostream>
#include <vector>
#include <list>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <complex>

#include <mst.h>
#include <simplex.h>

#define MAX_N 5001

typedef long long lld;
typedef unsigned long long llu;
typedef unsigned int uint;
using namespace std;

char path_adj[150], path_demo[150], file_graph[150], file_map[150];
char path_graph[150], path_map[150];
FILE *f_adj, *f_graph;

char cmd[150];
char cmd_map[150];

int n;
double adj[MAX_N][MAX_N];

int simp_n;
double c[MAX_N * MAX_N];

// Constraints
vector<vector<double> > Ap;
vector<double> bp;

int curr_pos = 0;
stack<int> positions;

inline void print_delimiter()
{
    printf("---------------------------------------------------------------\n");
}

inline int encode_edge(int i, int j)
{
    // Precondition: i > j
    assert(i > j);
    return (((i - 1) * (i - 2)) >> 1) + (j - 1);
}

inline pair<int, int> decode_edge(int x)
{
    int i = 2, j = 1;
    
    while (((i * (i - 1)) >> 1) <= x) i++;
    j = x - (((i - 1) * (i - 2)) >> 1) + 1;
    
    return make_pair(i, j);
}

inline void dump_edge(int x, double val)
{
    fprintf(f_graph, "\\draw[edge] (%d) to node[lab]{%g} (%d);\n", decode_edge(x).first, val, decode_edge(x).second);
}

inline void write_full_edge(int x, int y)
{
    fprintf(f_graph, "\\draw[edge] (%d) to node[lab]{%d} (%d);\n", x, 1, y);
}

int main()
{
    srand(time(NULL));
    
    printf("Linear Programming TSP Solver, implemented by <NAME>.\n");
    printf("Special thanks to <NAME>!\n");
    print_delimiter();
    
    printf("Enter the path to the file containing the adjacency matrix:\n");
    scanf("%s", path_adj);
    
    if ((f_adj = fopen(path_adj, "r")) == NULL)
    {
        printf("Error: Adjacency matrix file could not be opened!\n");
        return 1;
    }
    
    printf("Processing adjacency matrix...\n");<commit_msg>Increased clarity for partial edges<commit_after>/*
 Petar 'PetarV' Velickovic
 Linear Programming TSP Solver (Dantzig-Fulkerson-Johnson)
*/

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <assert.h>
#include <unistd.h>
#include <iostream>
#include <vector>
#include <list>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <complex>

#include <mst.h>
#include <simplex.h>

#define MAX_N 5001
#define EPS 1e-5

typedef long long lld;
typedef unsigned long long llu;
typedef unsigned int uint;
using namespace std;

char path_adj[150], path_demo[150], file_graph[150], file_map[150];
char path_graph[150], path_map[150];
FILE *f_adj, *f_graph;

char cmd[150];
char cmd_map[150];

int n;
double adj[MAX_N][MAX_N];

int simp_n;
double c[MAX_N * MAX_N];

// Constraints
vector<vector<double> > Ap;
vector<double> bp;

int curr_pos = 0;
stack<int> positions;

inline void print_delimiter()
{
    printf("---------------------------------------------------------------\n");
}

inline int encode_edge(int i, int j)
{
    // Precondition: i > j
    assert(i > j);
    return (((i - 1) * (i - 2)) >> 1) + (j - 1);
}

inline pair<int, int> decode_edge(int x)
{
    int i = 2, j = 1;
    
    while (((i * (i - 1)) >> 1) <= x) i++;
    j = x - (((i - 1) * (i - 2)) >> 1) + 1;
    
    return make_pair(i, j);
}

inline void dump_edge(int x, double val)
{
    fprintf(f_graph, "\\draw[edge,%s] (%d) to node[lab]{%g} (%d);\n", ((fabs(1.0 - val) < EPS) ? "black" : "red"), decode_edge(x).first, val, decode_edge(x).second);
}

inline void write_full_edge(int x, int y)
{
    fprintf(f_graph, "\\draw[edge] (%d) to node[lab]{%d} (%d);\n", x, 1, y);
}

int main()
{
    srand(time(NULL));
    
    printf("Linear Programming TSP Solver, implemented by <NAME>.\n");
    printf("Special thanks to <NAME>!\n");
    print_delimiter();
    
    printf("Enter the path to the file containing the adjacency matrix:\n");
    scanf("%s", path_adj);
    
    if ((f_adj = fopen(path_adj, "r")) == NULL)
    {
        printf("Error: Adjacency matrix file could not be opened!\n");
        return 1;
    }
    
    printf("Processing adjacency matrix...\n");
{'fraction_non_alphanumeric': 0.20161476355247981, 'fraction_numerical': 0.020761245674740483, 'mean_word_length': 3.169230769230769, 'pattern_counts': {'":': 0, '<': 54, '<?xml version=': 0, '>': 67, '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': '4695675', 'n_tokens_mistral': 1716, 'n_tokens_neox': 1604, 'n_words': 455}