projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix weight comparison in edge BFS
[tinc]
/
src
/
graph.c
diff --git
a/src/graph.c
b/src/graph.c
index
da64909
..
c100a93
100644
(file)
--- a/
src/graph.c
+++ b/
src/graph.c
@@
-115,11
+115,13
@@
static void mst_kruskal(void) {
}
}
}
}
+// Not putting it into header, the outside world doesn't need to know about it.
+extern void sssp_bfs(void);
+
/* Implementation of a simple breadth-first search algorithm.
Running time: O(E)
*/
/* Implementation of a simple breadth-first search algorithm.
Running time: O(E)
*/
-
-static void sssp_bfs(void) {
+void sssp_bfs(void) {
list_t *todo_list = list_alloc(NULL);
/* Clear visited status on nodes */
list_t *todo_list = list_alloc(NULL);
/* Clear visited status on nodes */
@@
-181,7
+183,7
@@
static void sssp_bfs(void) {
// Only update nexthop if it doesn't increase the path length
// Only update nexthop if it doesn't increase the path length
- if(!e->to->status.visited || (e->to->distance == n->distance + 1 && e->weight
>=
e->to->prevedge->weight)) {
+ if(!e->to->status.visited || (e->to->distance == n->distance + 1 && e->weight
<
e->to->prevedge->weight)) {
e->to->nexthop = (n->nexthop == myself) ? e->to : n->nexthop;
}
e->to->nexthop = (n->nexthop == myself) ? e->to : n->nexthop;
}