-
Notifications
You must be signed in to change notification settings - Fork 3
/
SMHN.py
36 lines (32 loc) · 784 Bytes
/
SMHN.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
36
import networkx as nx
import matplotlib.pyplot as plt
import csv
import pandas
import random
import pickle
import analysis as al
import numpy as np
G = nx.read_graphml("data/c.elegans.herm_pharynx_1.graphml")
probabilityData = {}
median = al.medianDegree(G)
hubFraction = al.nodeDegreeClassification(G, median)
def SMHN(G):
SH = 0
SN = 0
MH = 0
MN = 0
for i,nbrs1 in G.adjacency_iter():
if G.node[i]['role'] == 'S' and G.node[i]['degreeClass'] == 'High':
SH += 1
elif G.node[i]['role'] == 'S' and G.node[i]['degreeClass'] == 'Low':
SN += 1
elif G.node[i]['role'] == 'M' and G.node[i]['degreeClass'] == 'High':
MH += 1
elif G.node[i]['role'] == 'M' and G.node[i]['degreeClass'] == 'Low':
MN += 1
print SH
print SN
print MH
print MN
return 0
SMHN(G)