From 8b55dfacb199d152391aa5f7adbbbe35bceea7d7 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Tue, 12 Dec 2006 14:49:09 +0000 Subject: [PATCH] When building the minimum spanning tree, make sure we start from a reachable node. --- src/graph.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/graph.c b/src/graph.c index eadb36a7..9dd3fa5d 100644 --- a/src/graph.c +++ b/src/graph.c @@ -101,7 +101,13 @@ void mst_kruskal(void) /* Starting point */ - ((edge_t *) edge_weight_tree->head->data)->from->status.visited = true; + for(node = edge_weight_tree->head; node; node = next) { + e = node->data; + if(e->from->status.reachable) { + e->from->status.visited = true; + break; + } + } /* Add safe edges */ @@ -307,8 +313,8 @@ void sssp_bfs(void) void graph(void) { - mst_kruskal(); sssp_bfs(); + mst_kruskal(); graph_changed = true; } -- 2.39.5