Browse Source

initial commit

main
josch 10 years ago
commit
02328e94c4
  1. 12
      .gitmodules
  2. 8
      Makefile
  3. 21
      README.md
  4. 2
      _tags
  5. 22
      rand_graph.ml
  6. 46
      test.sh

12
.gitmodules vendored

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
[submodule "abate"]
path = abate
url = git://github.com/josch/cycles_johnson_abate.git
[submodule "hawick"]
path = hawick
url = git://github.com/josch/cycles_hawick_james.git
[submodule "meyer"]
path = meyer
url = git://github.com/josch/cycles_johnson_meyer.git
[submodule "tarjan"]
path = tarjan
url = git://github.com/josch/cycles_tarjan.git

8
Makefile

@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
CFLAGS=-Xs abate,hawick,meyer,tarjan
all:
ocamlbuild ${CFLAGS} -classic-display -use-ocamlfind rand_graph.native
clean:
ocamlbuild ${CFLAGS} -clean
rm -f *.dot

21
README.md

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
Run cycle enumerating code on sample input and compare results
--------------------------------------------------------------
An ocaml script generates random directed graphs with loops.
Those loops are fed to a number of different cycle enumeration algorithms.
The outputs are compared with each other to ensure correct execution.
Setup
-----
git submodule update --init
Usage
-----
./test.sh 11
The argument to the shell script is an integer denoting the maximum number of
vertices for which graphs will be generated.

2
_tags

@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
<*.ml{i,}>: debug, pp(camlp4o Camlp4MacroParser.cmo)
<rand_graph.*>: package(ocamlgraph), package(extlib)

22
rand_graph.ml

@ -0,0 +1,22 @@ @@ -0,0 +1,22 @@
open Graph
module G = Pack.Digraph
module Dfs = Graph.Traverse.Dfs(G)
if Array.length Sys.argv != 2 then begin
Printf.printf "usage: %s max_num_vertices\n" Sys.argv.(0);
exit 1;
end;
let max_v = int_of_string Sys.argv.(1) in
for v = 1 to max_v do
let e = ref 1 in
try
while true do
let g = G.Rand.graph ~v ~e:!e () in
if Dfs.has_cycle g then
G.dot_output g (Printf.sprintf "graph-%d-%d.dot" v !e);
incr e;
done;
with _ -> ();
done;

46
test.sh

@ -0,0 +1,46 @@ @@ -0,0 +1,46 @@
#!/bin/sh -e
echo compiling ./hawick/circuits_hawick...
make -C ./hawick >/dev/null
echo compiling ./meyer/de/normalisiert/utils/graphs/TestCycles.class
make -C ./meyer >/dev/null
echo compiling ./abate/cycles_iter.native and ./abate/cycles_functional.native
make -C ./abate >/dev/null
echo compiling ./rand_graph.native...
make > /dev/null
echo generating random graphs...
rm -f *.dot
./rand_graph.native $1
echo testing graphs...
counter=0
for f in *.dot; do
num_vertices=$(sed -n -e '/^ [0-9]\+;$/p' $f | wc -l)
adj_list=$(sed -n -e 's/^ \([0-9]\) -> \([0-9]\);$/\1,\2/p' $f)
result_hawick=$(./hawick/circuits_hawick $num_vertices $(echo $adj_list))
result_meyer=$(java -classpath ./meyer de.normalisiert.utils.graphs.TestCycles $num_vertices $(echo $adj_list))
result_tarjan=$(python ./tarjan/cycles.py $num_vertices $(echo $adj_list))
result_abate_iter=$(./abate/cycles_iter.native $num_vertices $(echo $adj_list))
result_abate_func=$(./abate/cycles_functional.native $num_vertices $(echo $adj_list))
if [ "$result_hawick" != "$result_meyer" ]; then
echo error: hawick differs from meyer
exit 1
fi
if [ "$result_hawick" != "$result_tarjan" ]; then
echo error: hawick differs from tarjan
exit 1
fi
if [ "$result_hawick" != "$result_abate_iter" ]; then
echo error: hawick differs from abate_iter
exit 1
fi
if [ "$result_hawick" != "$result_abate_func" ]; then
echo error: hawick differs from abate_func
exit 1
fi
echo $f okay, $(echo "$result_hawick" | wc -l) cycles
counter=$((counter+1))
done
echo successfully tested $counter graphs
Loading…
Cancel
Save