aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2014-08-06 14:08:10 -0400
committerGlenn Elliott <gelliott@cs.unc.edu>2014-08-06 14:08:10 -0400
commitcd028d1d0da2a352a7c5ebff551bbbc6f46c2cf8 (patch)
treed3eddf37eac46d8de052adfe88d3139417360f82
parent33d150622e0dde9de7abb32aae96e88dd7243ca5 (diff)
depthtest: Test graphs with backedges.
-rw-r--r--tools/depthtest.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/tools/depthtest.cpp b/tools/depthtest.cpp
index 97ff379..30b4fbc 100644
--- a/tools/depthtest.cpp
+++ b/tools/depthtest.cpp
@@ -43,8 +43,9 @@ int main(void)
43 graph_t g; 43 graph_t g;
44 node_t n0, n1, n2, n3, n4; 44 node_t n0, n1, n2, n3, n4;
45 edge_t e0_1, e0_2, e1_4, e2_3, e3_4; 45 edge_t e0_1, e0_2, e1_4, e2_3, e3_4;
46 edge_t be4_0, be3_1;
46 47
47 CheckError(pgm_init("/tmp/graphs", 1)); 48 CheckError(pgm_init_process_local());
48 CheckError(pgm_init_graph(&g, "demo")); 49 CheckError(pgm_init_graph(&g, "demo"));
49 50
50 CheckError(pgm_init_node(&n0, g, "n0")); 51 CheckError(pgm_init_node(&n0, g, "n0"));
@@ -59,12 +60,21 @@ int main(void)
59 CheckError(pgm_init_edge(&e2_3, n2, n3, "e2_3")); 60 CheckError(pgm_init_edge(&e2_3, n2, n3, "e2_3"));
60 CheckError(pgm_init_edge(&e3_4, n3, n4, "e3_4")); 61 CheckError(pgm_init_edge(&e3_4, n3, n4, "e3_4"));
61 62
62 printf("depths:\n"); 63 CheckError(pgm_init_backedge(&be4_0, 1, n4, n0, "be4_0"));
64 CheckError(pgm_init_backedge(&be3_1, 1, n3, n1, "be3_1"));
65
66 printf("min depths:\n");
63 printf("depth(n0): %d\n", (int)pgm_get_min_depth(n0)); 67 printf("depth(n0): %d\n", (int)pgm_get_min_depth(n0));
64 printf("depth(n1): %d\n", (int)pgm_get_min_depth(n1)); 68 printf("depth(n1): %d\n", (int)pgm_get_min_depth(n1));
65 printf("depth(n2): %d\n", (int)pgm_get_min_depth(n2)); 69 printf("depth(n2): %d\n", (int)pgm_get_min_depth(n2));
66 printf("depth(n3): %d\n", (int)pgm_get_min_depth(n3)); 70 printf("depth(n3): %d\n", (int)pgm_get_min_depth(n3));
67 printf("depth(n4): %d\n", (int)pgm_get_min_depth(n4)); 71 printf("depth(n4): %d\n", (int)pgm_get_min_depth(n4));
72 printf("max depths:\n");
73 printf("depth(n0): %d\n", (int)pgm_get_max_depth(n0));
74 printf("depth(n1): %d\n", (int)pgm_get_max_depth(n1));
75 printf("depth(n2): %d\n", (int)pgm_get_max_depth(n2));
76 printf("depth(n3): %d\n", (int)pgm_get_max_depth(n3));
77 printf("depth(n4): %d\n", (int)pgm_get_max_depth(n4));
68 78
69 weights[e0_1] = 3; 79 weights[e0_1] = 3;
70 weights[e0_2] = 5; 80 weights[e0_2] = 5;
@@ -114,7 +124,6 @@ int main(void)
114 printf("dist(n3): %d\n", (int)pgm_get_max_depth(n3, weight)); 124 printf("dist(n3): %d\n", (int)pgm_get_max_depth(n3, weight));
115 printf("dist(n4): %d\n", (int)pgm_get_max_depth(n4, weight)); 125 printf("dist(n4): %d\n", (int)pgm_get_max_depth(n4, weight));
116 126
117
118 CheckError(pgm_destroy_graph(g)); 127 CheckError(pgm_destroy_graph(g));
119 128
120 return 0; 129 return 0;