This commit is contained in:
Tiago Batista Cardoso
2026-02-28 11:10:17 +01:00
parent 2736884f46
commit 500e03af35
10 changed files with 508 additions and 28 deletions

View File

@@ -28,19 +28,6 @@ graph_t *create_graph(int n, double p, double q)
return new_graph;
}
//void add_edge(graph_t *graph, int src, int dest)
//{
// // src -> dest
// node_t *new_node = create_node(dest);
// new_node->next = graph->adj_lists[src];
// graph->adj_lists[src] = new_node;
//
// // dest -> src
// new_node = create_node(src);
// new_node->next = graph->adj_lists[dest];
// graph->adj_lists[dest] = new_node;
//}
void add_edge(graph_t *graph, int src, int dest)
{
// Guard against self-loops and out-of-bounds
@@ -89,7 +76,7 @@ graph_t *basic_graph()
return basic;
}
graph_t *generate_graph(int n, double p, double q)
graph_t *generate_graph(int n, double p, double q, int seed)
{
clock_t start, end;
double cpu_time_used;
@@ -100,6 +87,8 @@ graph_t *generate_graph(int n, double p, double q)
graph_t *result = create_graph(n, p, q);
int remaining = n;
srand(seed);
// Calcul des repartitions aleatoires
int n1 = rand() % (remaining + 1);
remaining -= n1;