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, painters
from sknetwork.visualization import svg_graph
from sknetwork.clustering import Louvain

Graphs

[3]:
graph = bow_tie(True)
adjacency = graph.adjacency
position = graph.position
[4]:
image = svg_graph(adjacency, position, membership=sparse.csr_matrix([[.5, .5], [0, 1], [0, 1], [1, 0], [1, 0]]), node_size=15)
[5]:
SVG(image)
[5]:
../../_images/tutorials_visualization_pie_charts_6_0.svg

Digraphs

[6]:
graph = painters(True)
adjacency = graph.adjacency
names = graph.names
[7]:
louvain = Louvain()
louvain.fit(adjacency)
membership = louvain.membership_
[8]:
image = svg_graph(adjacency, names=names, membership=membership, node_size=15)
[9]:
SVG(image)
[9]:
../../_images/tutorials_visualization_pie_charts_11_0.svg