Develop and Download Open Source Software

Browse Subversion Repository

Contents of /cmap/attr.rb

Parent Directory Parent Directory | Revision Log Revision Log


Revision 120 - (show annotations) (download)
Sat Jul 6 05:58:10 2013 UTC (10 years, 10 months ago) by masao
File size: 929 byte(s)
reqire relative for "graph.rb"

1 #!/usr/bin/env ruby
2 # $Id: ext-graph-attr.rb,v 1.4 2010/01/13 20:57:17 masao Exp $
3
4 require "open3"
5 require "pp"
6
7 $:.push( File.dirname( __FILE__ ) )
8 require "graph"
9
10 ARGV.each do |f|
11 STDERR.puts f
12 g = nil
13 open( f ) do |io|
14 g = DirectedGraph.load_dot2( io )
15 end
16 puts "Nodes: #{ g.node_count }"
17 puts "Edges: #{ g.edge_count }"
18 puts "Edge labels: #{ g.edge_labels.size }"
19 #p g.edge_labels
20 #puts "Clustering coefficience: #{ g.clustering_coefficient }"
21 #puts "Average shortest path: #{ g.mean_average_shortest_path }"
22 root = "id0"
23 dists = g.warshal_floyd_shortest_paths
24 count = {}
25 g.nodes.each do |n|
26 next if n == root
27 count[ dists[ Set[root,n] ] ] ||= []
28 count[ dists[ Set[root,n] ] ] << n
29 end
30 puts "Distance from the root node (#{ root }):"
31 count.keys.sort.each do |i|
32 puts [ "dist#{i}", count[i].size, count[i].join(", ") ].join( "\t" )
33 end
34 end

Properties

Name Value
svn:executable *

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26