diff options
| author | Mikkel Thestrup <mithe24@student.sdu.dk> | 2025-12-03 22:38:44 +0100 |
|---|---|---|
| committer | Mikkel Thestrup <mithe24@student.sdu.dk> | 2025-12-03 22:38:44 +0100 |
| commit | a846e5e8b6442f6aa9ad738e2173da3211325f8e (patch) | |
| tree | 3bff07717d3375be4de1abecebe0bff5288bbdf7 /src/graph.c | |
| parent | 4a71e268c9cc5d7d9dd8a734ead6d657efa555a6 (diff) | |
| download | cycle-detector-a846e5e8b6442f6aa9ad738e2173da3211325f8e.tar.gz cycle-detector-a846e5e8b6442f6aa9ad738e2173da3211325f8e.zip | |
Added graph_remove_edge()
Diffstat (limited to '')
| -rw-r--r-- | src/graph.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/graph.c b/src/graph.c index 5ad439a..f3e7517 100644 --- a/src/graph.c +++ b/src/graph.c @@ -43,6 +43,18 @@ void graph_add_edge(Graph *g, int i, int j) { g->num_edges++; } +void graph_remove_edge(Graph *g, int i, int j) { + LinkedListNode *in_node = linked_list_find( + g->vertices[i].out_neighbours, + &g->vertices[j]); + LinkedListNode *out_node = linked_list_find( + g->vertices[j].in_neighbours, + &g->vertices[j]); + linked_list_remove(g->vertices[i].out_neighbours, in_node); + linked_list_remove(g->vertices[j].in_neighbours, out_node); + g->num_edges--; +} + Graph *graph_read(const char *filename) { FILE *file = fopen(filename, "r"); char line[1024]; |