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 svg_graph, svg_digraph
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]
membership = sparse.csr_matrix([[p, 1-p] for p in probs])
[5]:
image = svg_graph(adjacency, position, membership=membership, 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()
louvain.fit(adjacency)
membership = louvain.membership_
[8]:
image = svg_graph(adjacency, position, membership=membership)
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()
louvain.fit(adjacency)
membership = louvain.membership_
[11]:
image = svg_digraph(adjacency, names=names, membership=membership, node_size=10)
SVG(image)
[11]:
../../_images/tutorials_visualization_pie_charts_13_0.svg