import matplotlib
matplotlib.use('PS') # generate postscript output by default
import networkx as nx
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from scholarNetwork import scholarNetwork as sn
print(sn.__file__)
print(sn.__version__)
/Users/chengjun/anaconda/lib/python2.7/site-packages/pandas/computation/__init__.py:19: UserWarning: The installed version of numexpr 2.4.4 is not supported in pandas and will be not be used UserWarning)
/Users/chengjun/anaconda/lib/python2.7/site-packages/scholarNetwork/scholarNetwork.pyc $version = 1.2.2.1$
G = nx.DiGraph()
G.add_weighted_edges_from([(1,2,50),(1,3,30), (3, 2, 10), (2, 4, 20), (2, 5, 30), (5, 3, 5), (4, 5, 10)])
Gb=sn.flowBalancing(G)
sn.flowDistanceFromSource(Gb)
{1: 1.0, 2: 2.223639455782313, 3: 2.352324263038549, 4: 3.2236394557823136, 5: 3.4736394557823136, 'sink': 3.935728458049887}
fig = plt.figure(figsize=(5, 5),facecolor='white')
edge_labels = nx.get_edge_attributes(G, 'weight')
sn.draw_graph(edge_labels.keys(), graph_layout='spring', labels = edge_labels.values())