Develop and Download Open Source Software

Browse Subversion Repository

Contents of /cmap/attr-exerimental.rb

Parent Directory Parent Directory | Revision Log Revision Log


Revision 118 - (show annotations) (download)
Sun Jun 9 02:44:04 2013 UTC (10 years, 11 months ago) by masao
File size: 1145 byte(s)
add combination meaturement for a cmap graph.

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 "graph"
5 require "open3"
6 require "pp"
7
8 ARGV.each do |f|
9 STDERR.puts f
10 g = nil
11 open( f ) do |io|
12 g = DirectedGraph.load_dot2( io )
13 end
14 puts "Nodes: #{ g.node_count }"
15 puts "Edges: #{ g.edge_count }"
16 puts "Edge labels: #{ g.edge_labels.size }"
17 #p g.edge_labels
18 #puts "Clustering coefficience: #{ g.clustering_coefficient }"
19 #puts "Average shortest path: #{ g.mean_average_shortest_path }"
20 root = "id0"
21 dists = g.warshal_floyd_shortest_paths
22 count = {}
23 g.nodes.each do |n|
24 next if n == root
25 count[ dists[ Set[root,n] ] ] ||= []
26 count[ dists[ Set[root,n] ] ] << n
27 end
28 puts "Distance from the root node (#{ root }):"
29 count.keys.sort.each do |i|
30 puts [ "dist#{i}", count[i].size, count[i].join(", ") ].join( "\t" )
31 end
32 extent_m = count[1].size
33 specificity_m = g.mean_average_shortest_path
34 puts "Extent measurements: #{ extent_m }"
35 puts "Specificity measurements: #{ specificity_m }"
36 puts "Combination (just multiplying both): #{ extent_m * specificity_m }"
37 end

Properties

Name Value
svn:executable *

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