Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Andrew was here
- def nc(g1, g2, matrix, min = 0.5)
- overall = 0
- # for each vertex in the first group count the number of connections to
- # the other group
- # FIXME I only need to do this once as I already cover all connections
- # between both groups in one pairwise loop
- g1c = {}
- g2c = {}
- g1.each { |v| g1c[v] = 0 }
- g2.each { |v| g2c[v] = 0 }
- g1.each do |v1|
- g2.each do |v2|
- if not matrix[v1][v2].nil? then
- g1c[v1] = g1c[v1] + 1
- g2c[v2] = g2c[v2] + 1
- end
- end
- end
- g1c.each do |k,v|
- return 0 if v.to_f / g2.size.to_f < min
- overall = overall + v
- end
- g2c.each do |k,v|
- return 0 if v.to_f / g1.size.to_f < min
- overall = overall + v
- end
- return overall
- end
- def wc(g1, g2, matrix, min = 0.3)
- overall = 0
- # for each vertex in the first group count the number of connections to
- # the other group
- # FIXME I only need to do this once as I already cover all connections
- # between both groups in one pairwise loop
- g1c = {}
- g2c = {}
- g1.each { |v| g1c[v] = 0 }
- g2.each { |v| g2c[v] = 0 }
- g1.each do |v1|
- g2.each do |v2|
- if not matrix[v1][v2].nil? then
- g1c[v1] = g1c[v1] + matrix[v1][v2]
- g2c[v2] = g2c[v2] + matrix[v1][v2]
- end
- end
- end
- g1c.each do |k,v|
- return 0 if v < min
- overall = overall + v
- end
- g2c.each do |k,v|
- return 0 if v < min
- overall = overall + v
- end
- return overall
- end
Add Comment
Please, Sign In to add comment