In [6]:
import networkx as nx
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
import os
from glob import glob
#Gc_files = glob('../output/network/Gc_negative.gml')
#Gc_files = glob('../output/network/Gc_positive.gml')
Gc_files = glob('../output/network/Gc_neutral.gml')
def calculate_graph_inf(graph):
graph.name = filename
info = nx.info(graph)
print info
for graph_num, gml_graph in enumerate(Gc_files):
graph = nx.read_gml(gml_graph)
(filepath, filename) = os.path.split(gml_graph)
print('-' * 10)
print(gml_graph)
calculate_graph_inf(graph)
In [3]:
# negative
N = graph.order()
degrees = graph.degree().values()
max_in = max(degrees)
centralization = float((N*max_in - sum(degrees)))/(N-1)**2
centralization
Out[3]:
In [5]:
# positive
N = graph.order()
degrees = graph.degree().values()
max_in = max(degrees)
centralization = float((N*max_in - sum(degrees)))/(N-1)**2
centralization
Out[5]:
In [8]:
# neutral
N = graph.order()
degrees = graph.degree().values()
max_in = max(degrees)
centralization = float((N*max_in - sum(degrees)))/(N-1)**2
centralization
Out[8]:
In [ ]: