X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fagar%2Ftest%2Fsimple-graphr.h;h=2fe98a48776c9c2ddbc8bdd9a85100ad0a9b0685;hb=09378088f7f49f30cb61435712a8dc2e52a32f69;hp=2abe72dcb6903989fafa71d46b5c5f3715b95ab2;hpb=a2eaae42b58a44d6f88f5e20e4a7d7cdbde9edae;p=ccan diff --git a/ccan/agar/test/simple-graphr.h b/ccan/agar/test/simple-graphr.h index 2abe72dc..2fe98a48 100644 --- a/ccan/agar/test/simple-graphr.h +++ b/ccan/agar/test/simple-graphr.h @@ -199,4 +199,45 @@ static const struct adjacency_listr traversal1_adjacency[] = { {}, }; +/* Shortcut-1 graph + * + * A ---- (3) -----> C + * \ / + * (1)-> B --(1) + * + * This provides an example of a graph where the lowest cost path from + * (A) to (C) is not the path with the smallest number od edges. + */ +struct shortcut1_graphr { + struct agar_graph gr; +}; +void shortcut1_graphr_init(struct shortcut1_graphr *s1gr); +static const struct adjacency_listr shortcut1_adjacencyr[] = { + {1, {3, 2}}, + {2, {3}}, + {3, {}}, + {}, +}; + +/* Shortcut-2 graph + * + * A ---- (2) -----> C + * \ / + * (2)-> B --(-1) + * + * This provides an example of a graph with a negative edge cost, but + * no negative cost cycles (and so still with well defined shortest + * paths). + */ +struct shortcut2_graphr { + struct agar_graph gr; +}; +void shortcut2_graphr_init(struct shortcut2_graphr *s2gr); +static const struct adjacency_listr shortcut2_adjacencyr[] = { + {1, {3, 2}}, + {2, {3}}, + {3, {}}, + {}, +}; + #endif /* _SIMPLE_GRAPHR_H */