Mercurial > hg > Database > Alice
view scripts/topology/ring.rb @ 601:30f2c04571c2 dispose
add chat, add Star topology to topology manager&node
author | Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 27 Apr 2016 16:28:10 +0900 |
parents | 5c704b9a9a87 |
children |
line wrap: on
line source
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| connections << [nodes[i], nodes[(i + 1) % node_num], "right"] connections << [nodes[i], nodes[i - 1], "left"] } print_dot(connections)