Esempio n. 1
0
def test_Rossa():
	# Rossa =========================
	G=nx.karate_club_graph()
	print("Running Rossa's algorithm ...")
	rs = cpa.Rossa()
	rs.detect(G)
	pair_id = rs.get_pair_id()
	coreness = rs.get_coreness()
	sig_pair_id, sig_coreness, significance, p_values = cpa.qstest(pair_id, coreness, G, rs)
Esempio n. 2
0
def test_KM_config():
	# KM--config =========================
	G=nx.karate_club_graph()
	print("Running KM_config ...")
	km = cpa.KM_config()
	km.detect(G)
	pair_id = km.get_pair_id()
	coreness = km.get_coreness()
	sig_pair_id, sig_coreness, significance, p_values = cpa.qstest(pair_id, coreness, G, km)
Esempio n. 3
0
def test_BE():
	# BE =========================
	G=nx.karate_club_graph()
	print("Running BE algorithm ...")
	be = cpa.BE()
	be.detect(G)
	pair_id = be.get_pair_id()
	coreness = be.get_coreness()
	sig_pair_id, sig_coreness, significance, p_values = cpa.qstest(pair_id, coreness, G, be)
Esempio n. 4
0
def test_LapSgnCore():
	# LapSgnCore =========================
	G=nx.karate_club_graph()
	print("Running LapSgnCore algorithm ...")
	lsc = cpa.LapSgnCore()
	lsc.detect(G)
	pair_id = lsc.get_pair_id()
	coreness = lsc.get_coreness()
	sig_pair_id, sig_coreness, significance, p_values = cpa.qstest(pair_id, coreness, G, lsc)
Esempio n. 5
0
def test_SBM():
	# SBM =========================
	G=nx.karate_club_graph()
	print("Running SBM algorithm ...")
	sbm = cpa.SBM()
	sbm.detect(G)
	pair_id = sbm.get_pair_id()
	coreness = sbm.get_coreness()
	sig_pair_id, sig_coreness, significance, p_values = cpa.qstest(pair_id, coreness, G, sbm)
Esempio n. 6
0
def test_MINRES():
	# MINRES =========================
	G=nx.karate_club_graph()
	print("Running MINRES algorithm ...")
	mrs = cpa.MINRES()
	mrs.detect(G)
	pair_id = mrs.get_pair_id()
	coreness = mrs.get_coreness()
	sig_pair_id, sig_coreness, significance, p_values = cpa.qstest(pair_id, coreness, G, mrs)
Esempio n. 7
0
def test_Surprise():
	# Surprise =========================
	G=nx.karate_club_graph()
	print("Running Surprise ...")
	spr = cpa.Surprise()
	spr.detect(G)
	pair_id = spr.get_pair_id()
	coreness = spr.get_coreness()
	sig_pair_id, sig_coreness, significance, p_values = cpa.qstest(pair_id, coreness, G, spr)
Esempio n. 8
0
def test_Divisive():
	# KM--config =========================
	G=nx.karate_club_graph()
	print("Running Divisive ...")
	dv = cpa.Divisive()
	dv.detect(G)
	pair_id = dv.get_pair_id()
	coreness = dv.get_coreness()
	sig_pair_id, sig_coreness, significance, p_values = cpa.qstest(pair_id, coreness, G, dv)
#only needed for continues models like Rossa
cut = 0.15

algorithm = cp.MINRES()
algorithm.detect(DPI)

#dictionary of nodes, telling to which core-periphery pair the node belongs (if only single core
#-periphery structure then then each key has the value 0)
c = algorithm.get_pair_id()
#Dictionary with node as keys telling if the node is a core node (1) or periphery node(0)
x = algorithm.get_coreness()

# this function calculates the significance that the network is a core perihpery network by comparing it to
# 1000 random networks (configuration network)
sig_c, sig_x, significant, p_values = cp.qstest(c, x, DPI, algorithm, num_of_rand_net=500)
#sig_c same as c but only for significant assiciations (else None value)
#sig_x same as x but only for significant assiciations (else None value)
#boolean True/False if network is core perihpery structures
#p_values for the individual core-periphery structures
print(sig_x)


print('Significant Core-Periphery Structure?')
print(significant)
print('Pvalues: ')
print(p_values)


if model != 'Rossa':
    print('Core Nodes: %d' %len([node for node in sig_x if sig_x[node] == 1]))