From: Guus Sliepen Date: Tue, 12 Dec 2006 14:49:09 +0000 (+0000) Subject: When building the minimum spanning tree, make sure we start from a reachable node. X-Git-Tag: release-1.0.6~10 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=8b55dfacb199d152391aa5f7adbbbe35bceea7d7;p=oweals%2Ftinc.git When building the minimum spanning tree, make sure we start from a reachable node. --- diff --git a/src/graph.c b/src/graph.c index eadb36a..9dd3fa5 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; }