feat: Initial commit
This commit is contained in:
41
Laboratorio 9/Esercizio 1/main.c
Normal file
41
Laboratorio 9/Esercizio 1/main.c
Normal file
@@ -0,0 +1,41 @@
|
||||
// Laboratorio 9 - Esercizio 1 - main.c
|
||||
// Matteo Schiff - s295565
|
||||
|
||||
#include<stdlib.h>
|
||||
|
||||
#include"Graph.h"
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
FILE * fp_read;
|
||||
Graph G;
|
||||
if (argc < 1) {
|
||||
puts("Specifica il file tra gli argomenti");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((fp_read = fopen(argv[1], "r")) == NULL)
|
||||
{
|
||||
puts("Impossibile aprire il file");
|
||||
return 1;
|
||||
}
|
||||
G = GRAPHload(fp_read);
|
||||
fclose(fp_read);
|
||||
|
||||
Edge *edgesToRemove = malloc(GRAPHEdgeCount(G) * sizeof(Edge));
|
||||
int cardinality;
|
||||
GRAPHFindCardMinDAG(G, &cardinality, edgesToRemove);
|
||||
if (cardinality != 0) {
|
||||
GRAPHRemoveEdges(G, edgesToRemove, cardinality);
|
||||
|
||||
// Salvo il DAG su file
|
||||
FILE * fp_write = fopen("DAG.txt", "w");
|
||||
GRAPHstore(G, fp_write);
|
||||
fclose(fp_write);
|
||||
}
|
||||
GRAPHmaxPathFromSource(G);
|
||||
|
||||
GRAPHfree(G);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user