Commit fd96a212 authored by David Gibson's avatar David Gibson

aga,agar: Rename aga_dijkstra_all_paths()

aga_dijkstra_all_paths() runs Dijkstra's algorithm to completion (as
opposed to aga_dijkstra_path(), which operates lazily).  In effect this
computes the shortest path to all (reachable) nodes from the start node.

So, in this context the name makes sense.  But for an analogous function
for future algorithms (e.g. Bellman-Ford), the name doesn't make sense.

So, in the interests of consistency with those future extensions, change
the name of this to aga_dijkstra_complete().
Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
parent f8361f19
......@@ -416,15 +416,15 @@ bool aga_dijkstra_path(struct aga_graph *g, struct aga_node *dest,
struct aga_node **prev, const void **prevedge);
/**
* aga_dijkstra_all_paths - Find shortest paths to all reachable nodes
* aga_dijkstra_complete - Find shortest paths to all reachable nodes
* @g: graph
*
* Finds shortest paths from the source node (specified in
* aga_dijkstra_start()) to all other reachable nodes in @g. No
* results are returned directly, but between calling
* aga_dijkstra_all_paths() and aga_finish, aga_dijkstra_path() is
* aga_dijkstra_all_paths() and aga_finish(), aga_dijkstra_path() is
* guaranteed to complete in O(1) time for all destinations.
*/
void aga_dijkstra_all_paths(struct aga_graph *g);
void aga_dijkstra_complete(struct aga_graph *g);
#endif /* CCAN_AGA_H */
......@@ -114,7 +114,7 @@ bool aga_dijkstra_path(struct aga_graph *g, struct aga_node *node,
return true;
}
void aga_dijkstra_all_paths(struct aga_graph *g)
void aga_dijkstra_complete(struct aga_graph *g)
{
if (!aga_check_state(g))
return;
......
......@@ -241,7 +241,7 @@ static void test_shortcut2(void)
shortcut2_graph_init(&s2g);
ok1(aga_dijkstra_start(&s2g.sg.g, &s2g.sg.nodes[1]) == 0);
aga_dijkstra_all_paths(&s2g.sg.g);
aga_dijkstra_complete(&s2g.sg.g);
ok1(aga_error(&s2g.sg.g) == AGA_ERR_NEGATIVE_COST);
aga_finish(&s2g.sg.g);
}
......
......@@ -286,8 +286,8 @@ bool agar_dijkstra_path(struct agar_state *sr, const void *destr,
return true;
}
void agar_dijkstra_all_paths(struct agar_state *sr)
void agar_dijkstra_complete(struct agar_state *sr)
{
aga_dijkstra_all_paths(&sr->g);
aga_dijkstra_complete(&sr->g);
}
......@@ -84,6 +84,6 @@ bool agar_dijkstra_step(struct agar_state *sr, const void **nextr);
bool agar_dijkstra_path(struct agar_state *sr, const void *destr,
aga_icost_t *total_cost,
const void **prevr, const void **prevedge);
void agar_dijkstra_all_paths(struct agar_state *sr);
void agar_dijkstra_complete(struct agar_state *sr);
#endif /* CCAN_AGAR_H */
......@@ -231,7 +231,7 @@ static void test_shortcut2(void)
struct agar_state *sr;
ok1(sr = agar_dijkstra_new(NULL, &shortcut2_graphr.gr, int2ptr(1)));
agar_dijkstra_all_paths(sr);
agar_dijkstra_complete(sr);
ok1(agar_error(sr) == AGA_ERR_NEGATIVE_COST);
tal_free(sr);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment