Pie-chart nodes

Visualization of membership matrices with pie-chart nodes.

[1]:
from IPython.display import SVG
from scipy import sparse
[2]:
from sknetwork.data import bow_tie, karate_club, painters
from sknetwork.visualization import visualize_graph
from sknetwork.clustering import Louvain

Graphs

[3]:
graph = bow_tie(True)
adjacency = graph.adjacency
position = graph.position
[4]:
# probabilities
probs = [.5, 0, 0, 1, 1]
probs = sparse.csr_matrix([[p, 1-p] for p in probs])
[5]:
image = visualize_graph(adjacency, position, probs=probs, node_size=10)
SVG(image)
[5]:
../../_images/tutorials_visualization_pie_charts_6_0.svg
[6]:
graph = karate_club(True)
adjacency = graph.adjacency
position = graph.position
[7]:
# soft clustering
louvain = Louvain()
probs = louvain.fit_predict_proba(adjacency)
[8]:
image = visualize_graph(adjacency, position, probs=probs)
SVG(image)
[8]:
../../_images/tutorials_visualization_pie_charts_9_0.svg

Directed graphs

[9]:
graph = painters(True)
adjacency = graph.adjacency
names = graph.names
[10]:
# soft clustering
louvain = Louvain()
probs = louvain.fit_predict_proba(adjacency)
[11]:
image = visualize_graph(adjacency, names=names, probs=probs, node_size=10)
SVG(image)

[11]:
../../_images/tutorials_visualization_pie_charts_13_0.svg