# HG changeset patch # User suruga # Date 1517999493 -32400 # Node ID 8a33595a0d8cdf27ce83bcf6b64842e57f5f989e # Parent 3fda0de2d13908f74414cb8b12bf0deef50a1d61 add tree.rb diff -r 3fda0de2d139 -r 8a33595a0d8c scripts/LogupdateTest.sh --- a/scripts/LogupdateTest.sh Thu Jan 25 13:04:09 2018 +0900 +++ b/scripts/LogupdateTest.sh Wed Feb 07 19:31:33 2018 +0900 @@ -1,5 +1,6 @@ export JAR=build/libs/logupdateTest-1.1.jar -java -cp $JAR alice.topology.manager.TopologyManager -host localhost -p 10000 -port 10001 --noKeepAlive & +ruby scripts/tree.rb 3 > scripts/tree.dot +java -cp $JAR alice.topology.manager.TopologyManager -conf scripts/tree.dot -host localhost -p 10000 -port 10001 --noKeepAlive & sleep 3 java -jar $JAR -host localhost -p 10003 -port 10000 --noKeepAlive & java -jar $JAR -host localhost -p 10001 -port 10000 --noKeepAlive & diff -r 3fda0de2d139 -r 8a33595a0d8c scripts/tree.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/tree.rb Wed Feb 07 19:31:33 2018 +0900 @@ -0,0 +1,38 @@ +def create_nodes(node_num) + (0..node_num - 1).map { |i| + i = "node" + i.to_s + } +end + +def print_dot(connections) + puts "digraph test {" + connections.each { |connection| + print "\t" + print connection[0] + print " -> " + print connection[1] + print ' [label="' + connection[2] + '"]' + puts + } + puts "}" +end + +node_num = ARGV[0].to_i +nodes = create_nodes(node_num) +connections = Array.new +nodes.each_with_index { |node, i| + parent = (i - 1) / 2; + child1 = 2 * i + 1; + child2 = 2 * i + 2; + if parent >= 0 then + connections << [nodes[i], nodes[parent], "parent"] + end + if child1 < node_num then + connections << [nodes[i], nodes[child1], "child1"] + end + if child2 < node_num then + connections << [nodes[i], nodes[child2], "child2"] + end +} +print_dot(connections) +