examples/theory/tests.rb in ruby-graphviz-1.0.1 vs examples/theory/tests.rb in ruby-graphviz-1.0.2

- old
+ new

@@ -37,19 +37,21 @@ puts "Symmetric ? #{t.symmetric?}" puts "Incidence matrix :" puts t.incidence_matrix -# => [ 1 1 1 1 0 0 0 0 0 0] -# [ 0 -1 0 0 1 1 1 0 0 0] -# [ 0 0 0 0 -1 0 0 1 1 0] -# [ 0 0 -1 0 0 -1 0 -1 0 1] -# [ 0 0 0 0 0 0 -1 0 0 -1] -# [ 0 0 0 -1 0 0 0 0 -1 0] +# => [ 1 1 1 0 0 0 0 0 0] +# [ -1 0 0 1 1 1 0 0 0] +# [ 0 0 0 -1 0 0 1 1 0] +# [ 0 -1 0 0 -1 0 -1 0 1] +# [ 0 0 0 0 0 -1 0 0 -1] +# [ 0 0 -1 0 0 0 0 -1 0] g.each_node do |name, node| puts "Degree of node `#{name}' = #{t.degree(node)}" + print "neighbors : "; p t.neighbors(name).map{ |e| e.id } # = node.neighbors.map { |e| e.id } + print "incidents : "; p t.incidents(name).map{ |e| e.id } # = node.incidents.map { |e| e.id } end puts "Laplacian matrix :" puts t.laplacian_matrix # => [ 3 -1 0 -1 0 -1] @@ -76,6 +78,10 @@ puts "Your graph contains circuits" if rr.include?(nil) puts "Critical path : " rrr = t.critical_path print "\tPath "; p rrr[:path] -puts "\tDistance : #{rrr[:distance]}" \ No newline at end of file +puts "\tDistance : #{rrr[:distance]}" + +t.pagerank.each { |node, rank| + puts "Pagerank for node #{node.id} = #{rank}" +}