In [21]:
import sys, os
import networkx as nx
from nxpd import draw
sys.path.insert(0, os.path.join('..'))
In [25]:
G = nx.DiGraph()
edges = [('a', 'c'),
('c', 'a'),
('b', 'a'),
('f', 'c'),
('h', 'i'),
('i', 'j'),
('j', 'k')]
for i, j in edges:
G.add_edge(i, j, topic='dummy')
draw(G, show='ipynb')
Out[25]:
In [26]:
from socialgraph.socialgraph import elect_committee, paint_graph, compute_powers
committee = elect_committee(G, 2)
In [27]:
draw(paint_graph(G, committee), show='ipynb')
Out[27]:
In [28]:
print(committee)
In [29]:
from pprint import pprint
pprint(compute_powers(G))