X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fgraph.c;h=5dfbb72eb9824140f9267e9e3d39abe4d7c28244;hp=b5af2241f51b189b8fafd8268aa6c63112cee8f5;hb=e9576632dc4b780b867044269d06cc50f76d8c05;hpb=0200d3cd5d773d9b101c33264532d2a301c2af32 diff --git a/src/graph.c b/src/graph.c index b5af2241..5dfbb72e 100644 --- a/src/graph.c +++ b/src/graph.c @@ -1,6 +1,6 @@ /* graph.c -- graph algorithms - Copyright (C) 2001-2006 Guus Sliepen , + Copyright (C) 2001-2007 Guus Sliepen , 2001-2005 Ivo Timmermans This program is free software; you can redistribute it and/or modify @@ -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 = 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; } @@ -364,9 +370,13 @@ void dump_graph(void) fprintf(file, "}\n"); - fclose(file); - - if(filename[0] != '|') { + if(filename[0] == '|') { + pclose(file); + } else { + fclose(file); +#ifdef HAVE_MINGW + unlink(filename); +#endif rename(tmpname, filename); free(tmpname); }