When building the minimum spanning tree, make sure we start from a reachable node.

This commit is contained in:
Guus Sliepen 2006-12-12 14:49:09 +00:00
parent 47d916ec5e
commit 8b55dfacb1

View file

@ -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;
}