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]:
[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]:
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]: