-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6268d5f
commit 1998e68
Showing
10 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from igraph import * | ||
import pandas as pd | ||
g = load("boundary_labeled_graphs/phase1_users_boundary_edges.graphml") | ||
# g = load("boundary_labeled_graphs/phase2_users_boundary_edges.graphml") | ||
# g = load("boundary_labeled_graphs/phase3_users_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 | ||
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 | ||
if (internalSum + boundarySum != 0): | ||
node_value += (internalSum / (internalSum + boundarySum)) - 0.5 | ||
else: | ||
node_value = 0 | ||
sum_node_values += node_value | ||
print(sum_node_values) | ||
print(sum_boundary_nodes) | ||
print(sum_node_values / sum_boundary_nodes) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from igraph import * | ||
import pandas as pd | ||
g = load("boundary_labeled_graphs/phase1_users_boundary_nodes.graphml") | ||
# g = load("boundary_labeled_graphs/phase2_users_boundary_nodes.graphml") | ||
# g = load("boundary_labeled_graphs/phase3_users_boundary_nodes.graphml") | ||
vs = g.vs.select(polar_eq = "None") | ||
for polar in vs: | ||
boundary_vs = g.vs.select(status_eq = "boundary" + polar["name"]) #get boundary vertices of each polar | ||
for boundary_node in boundary_vs: | ||
incident_edges = g.incident(boundary_node) | ||
for edge in incident_edges: | ||
full_edge = g.es.select(edge)[0] | ||
if(full_edge.source == boundary_node.index): #means boundary node is src | ||
opp_node = g.vs.select(full_edge.target)[0] | ||
if(full_edge.target == boundary_node.index): #means boundary node is target | ||
opp_node = g.vs.select(full_edge.source)[0] | ||
my_boundary = "boundary" + polar["name"] #name of my community's boundary nodes | ||
if(opp_node["status"][0:8] == "boundary" and opp_node["status"]!= my_boundary and opp_node["polar"] != 'None' and boundary_node["polar"] != 'None'): #if boundary node from diff community | ||
g.es[edge]["status"] = "Eboundary" + polar["name"] | ||
elif(opp_node["status"] == "internal"+ polar["name"]): #if internal node from my community | ||
g.es[edge]["status"] = "Einternal" + polar["name"] | ||
|
||
g.save("boundary_labeled_graphs/phase1_users_boundary_edges.graphml") | ||
# g.save("boundary_labeled_graphs/phase2_users_boundary_edges.graphml") | ||
# g.save("boundary_labeled_graphs/phase3_users_boundary_edges.graphml") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from igraph import * | ||
import pandas as pd | ||
g = load("users_graphs/p1_users_graph_with_polar.graphml") | ||
# g = load("users_graphs/p2_users_graph_with_polar.graphml") | ||
# g = load("users_graphs/p3_users_graph_with_polar.graphml") | ||
vs = g.vs.select(polar_eq = "None") | ||
g.vs["status"] = None | ||
print(len(vs)) | ||
for pole in vs: #for each community Gi | ||
if (pole != "neu"): | ||
# print(topic) | ||
for member_id in g.neighbors(pole.index): #for each community member id | ||
member = g.vs.select(member_id)[0] #get full community member | ||
for neighbor_id in g.neighbors(member_id): # for each of neighbor'd ids | ||
neighbor = g.vs.select(neighbor_id)[0] #get full neighbor | ||
if (neighbor["polar"] != "None" and neighbor["polar"] != member["polar"]): #normal node from other pole/reply | ||
member["status"] = "boundary"+ member["polar"] | ||
for v in g.vs: | ||
if(v["status"] is None): | ||
if (v["polar"] == "None"): #if pole node | ||
v["status"] = "boundary" + v["name"] | ||
else: | ||
v["status"] = "internal"+ v["polar"] | ||
g.save("boundary_labeled_graphs/phase1_users_boundary_nodes.graphml") | ||
# g.save("boundary_labeled_graphs/phase2_users_boundary_nodes.graphml" | ||
# g.save("boundary_labeled_graphs/phase3_users_boundary_nodes.graphml" |