In [1]:
%load_ext autoreload
%autoreload 2
import networkx as nx
import nxtools
import nxtools as nxt
import scipy
import scipy.special
import logging
logging.basicConfig(format="[%(asctime)s] {%(filename)s:%(lineno)d} %(levelname)s - %(message)s")
logging.getLogger().setLevel(logging.INFO)
unwieghted/undirected
[2013-03-27 12:11:34,663] {quality.py:204} INFO - comm, len(comm), v1, v2 = mOv: 0 24 -0.400224368509 0.938405797101 [2013-03-27 12:11:34,666] {quality.py:204} INFO - comm, len(comm), v1, v2 = mOv: 1 21 -0.710741854157 1.05 [2013-03-27 12:11:34,669] {quality.py:204} INFO - comm, len(comm), v1, v2 = mOv: 2 38 -0.295849750399 0.866287339972 [2013-03-27 12:11:34,671] {quality.py:204} INFO - comm, len(comm), v1, v2 = mOv: 3 33 -0.354888129903 0.999053030303 [2013-03-27 12:11:34,677] {quality.py:204} INFO - comm, len(comm), v1, v2 = mOv: 4 63 -0.162494808781 1.01152073733 -0.0948530819054
In [2]:
graph_file = '/Users/aonghus/work/bike_networks/communities/oslom/large/complete.dat'
comm_file = '/Users/aonghus/work/bike_networks/communities/oslom/large/tp'
In [5]:
#directed, weighted = False, False
directed, weighted = True, True
create_using = nx.DiGraph() if directed else nx.Graph()
weight = 'weight' if weighted else None
graph = nx.read_weighted_edgelist(graph_file, nodetype=int, create_using=create_using)
comm = nxt.readCommunityFromTP(comm_file)
comm_aff = nxt.affiliation_dict(comm)
graph.remove_edges_from(graph.selfloop_edges())
print graph.is_directed(), graph.is_multigraph()
In [6]:
#reload(nxt)
print nxt.modularityOverlap(graph, comm, affiliation_dict=comm_aff, weight=weight)
In [ ]: