]> git.ozlabs.org Git - ccan/blobdiff - ccan/aga/test/simple-graph.h
aga,agar: New shortcut2 sample graph and testcases based on it
[ccan] / ccan / aga / test / simple-graph.h
index 3f4f9acc767121da1ac4a5c25e969770365b22b8..b8da3ad999045bc9207b59871a56fae691a13120 100644 (file)
@@ -52,9 +52,10 @@ static const struct adjacency_list trivial_adjacency[] = {
  */
 struct parallel_graph {
        int nlinks;
+       int cheaplink;
        struct simple_graph sg;
 };
-void parallel_graph_init(struct parallel_graph *pg, int nlinks);
+void parallel_graph_init(struct parallel_graph *pg, int nlinks, int cheaplink);
 static const struct adjacency_list parallel_adjacency_nlinks3[] = {
        {1, {2, 2, 2}},
        {2, {}},
@@ -214,4 +215,45 @@ static const struct adjacency_list 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_graph {
+       struct simple_graph sg;
+};
+void shortcut1_graph_init(struct shortcut1_graph *s1g);
+static const struct adjacency_list shortcut1_adjacency[] = {
+       {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_graph {
+       struct simple_graph sg;
+};
+void shortcut2_graph_init(struct shortcut2_graph *s2g);
+static const struct adjacency_list shortcut2_adjacency[] = {
+       {1, {3, 2}},
+       {2, {3}},
+       {3, {}},
+       {},
+};
+
 #endif /* _TEST_GRAPHS_H */