From 171b8a9f4b18358f827675bab399d69cb8e56cce Mon Sep 17 00:00:00 2001 From: Martin McGrane Date: Fri, 2 Dec 2016 10:16:37 +1100 Subject: [PATCH] Add 5 new tests of aggregate functions. --- tests/evaluation.at | 5 ++++ tests/evaluation/degree/InDegree.csv | 4 +++ tests/evaluation/degree/OutDegree.csv | 3 +++ tests/evaluation/degree/degree.dl | 12 +++++++++ tests/evaluation/degree/degree.err | 0 tests/evaluation/degree/degree.out | 0 tests/evaluation/degree/facts/Edge.facts | 6 +++++ .../evaluation/disconnected/DisConnected.csv | 27 +++++++++++++++++++ tests/evaluation/disconnected/disconnected.dl | 16 +++++++++++ .../evaluation/disconnected/disconnected.err | 0 .../evaluation/disconnected/disconnected.out | 0 .../evaluation/disconnected/facts/Edge.facts | 9 +++++++ .../highest_degree/HighestInDegree.csv | 1 + .../highest_degree/HighestOutDegree.csv | 1 + .../highest_degree/facts/Edge.facts | 6 +++++ .../highest_degree/highest_degree.dl | 17 ++++++++++++ .../highest_degree/highest_degree.err | 0 .../highest_degree/highest_degree.out | 0 .../shortest_edges/ShortestEdgeFromN.csv | 3 +++ .../shortest_edges/facts/Edge.facts | 6 +++++ .../shortest_edges/shortest_edges.dl | 8 ++++++ .../shortest_edges/shortest_edges.err | 0 .../shortest_edges/shortest_edges.out | 0 .../evaluation/shortest_path/ShortestPath.csv | 9 +++++++ .../evaluation/shortest_path/facts/Edge.facts | 6 +++++ .../evaluation/shortest_path/shortest_path.dl | 13 +++++++++ .../shortest_path/shortest_path.err | 0 .../shortest_path/shortest_path.out | 0 28 files changed, 152 insertions(+) create mode 100644 tests/evaluation/degree/InDegree.csv create mode 100644 tests/evaluation/degree/OutDegree.csv create mode 100644 tests/evaluation/degree/degree.dl create mode 100644 tests/evaluation/degree/degree.err create mode 100644 tests/evaluation/degree/degree.out create mode 100644 tests/evaluation/degree/facts/Edge.facts create mode 100644 tests/evaluation/disconnected/DisConnected.csv create mode 100644 tests/evaluation/disconnected/disconnected.dl create mode 100644 tests/evaluation/disconnected/disconnected.err create mode 100644 tests/evaluation/disconnected/disconnected.out create mode 100644 tests/evaluation/disconnected/facts/Edge.facts create mode 100644 tests/evaluation/highest_degree/HighestInDegree.csv create mode 100644 tests/evaluation/highest_degree/HighestOutDegree.csv create mode 100644 tests/evaluation/highest_degree/facts/Edge.facts create mode 100644 tests/evaluation/highest_degree/highest_degree.dl create mode 100644 tests/evaluation/highest_degree/highest_degree.err create mode 100644 tests/evaluation/highest_degree/highest_degree.out create mode 100644 tests/evaluation/shortest_edges/ShortestEdgeFromN.csv create mode 100644 tests/evaluation/shortest_edges/facts/Edge.facts create mode 100644 tests/evaluation/shortest_edges/shortest_edges.dl create mode 100644 tests/evaluation/shortest_edges/shortest_edges.err create mode 100644 tests/evaluation/shortest_edges/shortest_edges.out create mode 100644 tests/evaluation/shortest_path/ShortestPath.csv create mode 100644 tests/evaluation/shortest_path/facts/Edge.facts create mode 100644 tests/evaluation/shortest_path/shortest_path.dl create mode 100644 tests/evaluation/shortest_path/shortest_path.err create mode 100644 tests/evaluation/shortest_path/shortest_path.out diff --git a/tests/evaluation.at b/tests/evaluation.at index d92a18f5e70..adecc0b9291 100644 --- a/tests/evaluation.at +++ b/tests/evaluation.at @@ -143,3 +143,8 @@ POSITIVE_TEST([circuit_records],[evaluation]) POSITIVE_TEST([circuit_sat],[evaluation]) POSITIVE_TEST([factoring],[evaluation]) POSITIVE_TEST([perfect_numbers],[evaluation]) +POSITIVE_TEST([shortest_path],[evaluation]) +POSITIVE_TEST([shortest_edges],[evaluation]) +POSITIVE_TEST([degree],[evaluation]) +POSITIVE_TEST([highest_degree],[evaluation]) +POSITIVE_TEST([disconnected],[evaluation]) diff --git a/tests/evaluation/degree/InDegree.csv b/tests/evaluation/degree/InDegree.csv new file mode 100644 index 00000000000..609f9c8f4a7 --- /dev/null +++ b/tests/evaluation/degree/InDegree.csv @@ -0,0 +1,4 @@ +b 1 +e 3 +c 1 +d 1 diff --git a/tests/evaluation/degree/OutDegree.csv b/tests/evaluation/degree/OutDegree.csv new file mode 100644 index 00000000000..7a623863697 --- /dev/null +++ b/tests/evaluation/degree/OutDegree.csv @@ -0,0 +1,3 @@ +a 2 +b 2 +c 2 diff --git a/tests/evaluation/degree/degree.dl b/tests/evaluation/degree/degree.dl new file mode 100644 index 00000000000..7e291942f9f --- /dev/null +++ b/tests/evaluation/degree/degree.dl @@ -0,0 +1,12 @@ +// Find the shorted outward edge for every Node +.type Node + +.decl Edge(n:Node, m:Node, w:number) input + +.decl OutDegree(n:Node, l:number) output + +OutDegree(x, l) :- Edge(x, _, _), l = sum 1 : Edge(x, _, _). + +.decl InDegree(n:Node, l:number) output + +InDegree(x, l) :- Edge(_, x, _), l = sum 1 : Edge(_, x, _). diff --git a/tests/evaluation/degree/degree.err b/tests/evaluation/degree/degree.err new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/evaluation/degree/degree.out b/tests/evaluation/degree/degree.out new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/evaluation/degree/facts/Edge.facts b/tests/evaluation/degree/facts/Edge.facts new file mode 100644 index 00000000000..217d8492888 --- /dev/null +++ b/tests/evaluation/degree/facts/Edge.facts @@ -0,0 +1,6 @@ +a b 1 +a e 5 +b c 2 +b e 4 +c d 3 +c e 40 diff --git a/tests/evaluation/disconnected/DisConnected.csv b/tests/evaluation/disconnected/DisConnected.csv new file mode 100644 index 00000000000..3afee109f9b --- /dev/null +++ b/tests/evaluation/disconnected/DisConnected.csv @@ -0,0 +1,27 @@ +a g +a h +a f +b g +b h +b f +c b +c g +c h +c f +f b +f e +f c +f d +g b +g e +g c +g d +h b +h e +h c +h d +b a +c a +f a +g a +h a diff --git a/tests/evaluation/disconnected/disconnected.dl b/tests/evaluation/disconnected/disconnected.dl new file mode 100644 index 00000000000..3ac73e115bc --- /dev/null +++ b/tests/evaluation/disconnected/disconnected.dl @@ -0,0 +1,16 @@ +// Find all disconnected node pairs +.type Node + +.decl Edge(n:Node, m:Node, w:number) input + +// Find the connected nodes +.decl Connected(n:Node, m:Node) +Connected(n, n) :- Edge(n, _, _). +Connected(n, n) :- Edge(_, n, _). +Connected(n, m) :- Edge(n, m, _). +Connected(n, m) :- Edge(n, z, _), Connected(z, m). + +// Find nodes without a connection +.decl DisConnected(n:Node, m:Node) output +DisConnected(n, m) :- Edge(n, _, _), Edge(_, m, _), !Connected(n, m). +DisConnected(n, m) :- Edge(n, _, _), Edge(m, _, _), !Connected(n, m). diff --git a/tests/evaluation/disconnected/disconnected.err b/tests/evaluation/disconnected/disconnected.err new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/evaluation/disconnected/disconnected.out b/tests/evaluation/disconnected/disconnected.out new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/evaluation/disconnected/facts/Edge.facts b/tests/evaluation/disconnected/facts/Edge.facts new file mode 100644 index 00000000000..36ba2ee8070 --- /dev/null +++ b/tests/evaluation/disconnected/facts/Edge.facts @@ -0,0 +1,9 @@ +a b 1 +a e 5 +b c 2 +b e 4 +c d 3 +c e 40 +f g 1 +g h 1 +h f 1 diff --git a/tests/evaluation/highest_degree/HighestInDegree.csv b/tests/evaluation/highest_degree/HighestInDegree.csv new file mode 100644 index 00000000000..00750edc07d --- /dev/null +++ b/tests/evaluation/highest_degree/HighestInDegree.csv @@ -0,0 +1 @@ +3 diff --git a/tests/evaluation/highest_degree/HighestOutDegree.csv b/tests/evaluation/highest_degree/HighestOutDegree.csv new file mode 100644 index 00000000000..0cfbf08886f --- /dev/null +++ b/tests/evaluation/highest_degree/HighestOutDegree.csv @@ -0,0 +1 @@ +2 diff --git a/tests/evaluation/highest_degree/facts/Edge.facts b/tests/evaluation/highest_degree/facts/Edge.facts new file mode 100644 index 00000000000..217d8492888 --- /dev/null +++ b/tests/evaluation/highest_degree/facts/Edge.facts @@ -0,0 +1,6 @@ +a b 1 +a e 5 +b c 2 +b e 4 +c d 3 +c e 40 diff --git a/tests/evaluation/highest_degree/highest_degree.dl b/tests/evaluation/highest_degree/highest_degree.dl new file mode 100644 index 00000000000..6f9f9c1681d --- /dev/null +++ b/tests/evaluation/highest_degree/highest_degree.dl @@ -0,0 +1,17 @@ +// Find the highest in and out degree nodes in the graph +.type Node + +.decl Edge(n:Node, m:Node, w:number) input + +.decl OutDegree(n:Node, l:number) +OutDegree(x, l) :- Edge(x, _, _), l = sum 1 : Edge(x, _, _). + +.decl InDegree(n:Node, l:number) +InDegree(x, l) :- Edge(_, x, _), l = sum 1 : Edge(_, x, _). + +.decl HighestOutDegree(d:number) output +HighestOutDegree(d) :- OutDegree(_, _), d = max D : OutDegree(_, D). + +.decl HighestInDegree(d:number) output +HighestInDegree(d) :- InDegree(_, _), d = max D : InDegree(_, D). + diff --git a/tests/evaluation/highest_degree/highest_degree.err b/tests/evaluation/highest_degree/highest_degree.err new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/evaluation/highest_degree/highest_degree.out b/tests/evaluation/highest_degree/highest_degree.out new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/evaluation/shortest_edges/ShortestEdgeFromN.csv b/tests/evaluation/shortest_edges/ShortestEdgeFromN.csv new file mode 100644 index 00000000000..eb8f732589c --- /dev/null +++ b/tests/evaluation/shortest_edges/ShortestEdgeFromN.csv @@ -0,0 +1,3 @@ +a 1 +b 2 +c 3 diff --git a/tests/evaluation/shortest_edges/facts/Edge.facts b/tests/evaluation/shortest_edges/facts/Edge.facts new file mode 100644 index 00000000000..217d8492888 --- /dev/null +++ b/tests/evaluation/shortest_edges/facts/Edge.facts @@ -0,0 +1,6 @@ +a b 1 +a e 5 +b c 2 +b e 4 +c d 3 +c e 40 diff --git a/tests/evaluation/shortest_edges/shortest_edges.dl b/tests/evaluation/shortest_edges/shortest_edges.dl new file mode 100644 index 00000000000..688f66c72cd --- /dev/null +++ b/tests/evaluation/shortest_edges/shortest_edges.dl @@ -0,0 +1,8 @@ +// Find the shortest outward edge for every Node +.type Node + +.decl Edge(n:Node, m:Node, w:number) input + +.decl ShortestEdgeFromN(n:Node, l:number) output + +ShortestEdgeFromN(x, l) :- Edge(x, _, _), l = min Z : Edge(x, _, Z). diff --git a/tests/evaluation/shortest_edges/shortest_edges.err b/tests/evaluation/shortest_edges/shortest_edges.err new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/evaluation/shortest_edges/shortest_edges.out b/tests/evaluation/shortest_edges/shortest_edges.out new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/evaluation/shortest_path/ShortestPath.csv b/tests/evaluation/shortest_path/ShortestPath.csv new file mode 100644 index 00000000000..3ea89e79ec6 --- /dev/null +++ b/tests/evaluation/shortest_path/ShortestPath.csv @@ -0,0 +1,9 @@ +a b 1 +a e 5 +b c 2 +b e 4 +c d 3 +c e 40 +a c 3 +b d 5 +a d 6 diff --git a/tests/evaluation/shortest_path/facts/Edge.facts b/tests/evaluation/shortest_path/facts/Edge.facts new file mode 100644 index 00000000000..217d8492888 --- /dev/null +++ b/tests/evaluation/shortest_path/facts/Edge.facts @@ -0,0 +1,6 @@ +a b 1 +a e 5 +b c 2 +b e 4 +c d 3 +c e 40 diff --git a/tests/evaluation/shortest_path/shortest_path.dl b/tests/evaluation/shortest_path/shortest_path.dl new file mode 100644 index 00000000000..69eb069f732 --- /dev/null +++ b/tests/evaluation/shortest_path/shortest_path.dl @@ -0,0 +1,13 @@ +// Find the shortest paths between all nodes, the slow way +.type Node + +.decl Edge(n:Node, m:Node, w:number) input + +// Find all paths +.decl Length (n:Node, m:Node, l:number) +Length(x,y,t) :- t=l, Edge(x,y,l). +Length(x,y,t+l) :- Edge(x,z,l), Length(z,y,t). + +// Filter out the longest path +.decl ShortestPath(n:Node, m:Node, l:number) output +ShortestPath(x, y, a) :- Length(x, y, _), a = min Z : Length(x, y, Z). diff --git a/tests/evaluation/shortest_path/shortest_path.err b/tests/evaluation/shortest_path/shortest_path.err new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/evaluation/shortest_path/shortest_path.out b/tests/evaluation/shortest_path/shortest_path.out new file mode 100644 index 00000000000..e69de29bb2d