-
Notifications
You must be signed in to change notification settings - Fork 1
/
phase2_boundary_score_calculation.py
38 lines (35 loc) · 1.31 KB
/
phase2_boundary_score_calculation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from igraph import *
import pandas as pd
g = load("boundary_labeled_graphs/phase2_boundary_edges.graphml")
vs = g.vs.select(polar_eq = "None")
sum_node_values = 0
sum_boundary_nodes = 0
for polar in vs:
boundary_vs = g.vs.select(status_eq = "boundary" + polar["name"]) #get polar's boundary nodes
total_vs = g.vs.select(polar_eq = polar["name"])
internal_vs = g.vs.select(status_eq = "internal" + polar["name"])
# print(polar["name"])
# print(len(boundary_vs) / len(total_vs))
sum_boundary_nodes+=len(boundary_vs)
node_value = 0
for boundary_node in boundary_vs: #for each boundary node in this polar, calculate di and db
incident_edges = g.incident(boundary_node)
boundarySum = 0
internalSum = 0
for edge in incident_edges:
full_edge = g.es.select(edge)[0]
if(full_edge["status"][0:9] == "Eboundary"):
boundarySum +=1
else:
internalSum +=1
# print("go")
# print(boundarySum)
# print(internalSum)
# print("stop")
node_value += (internalSum / (internalSum + boundarySum)) - 0.5
# print(node_value)
sum_node_values += node_value
print(sum_node_values)
print(sum_boundary_nodes)
print(sum_node_values / sum_boundary_nodes)
print(sum_boundary_nodes / len(g.vs))