Toy graphs

This notebook shows how to load some toy graphs.

[1]:
from IPython.display import SVG
[2]:
import numpy as np
[3]:
from sknetwork.data import house, bow_tie, karate_club, miserables, painters, hourglass, star_wars, movie_actor
from sknetwork.visualization import visualize_graph, visualize_bigraph

House graph

[4]:
graph = house(metadata=True)
adjacency = graph.adjacency
position = graph.position
[5]:
image = visualize_graph(adjacency, position, scale=0.5)
SVG(image)
[5]:
../../_images/tutorials_data_toy_graphs_7_0.svg
[6]:
# adjacency matrix only
adjacency = house()

Bow tie

[7]:
graph = bow_tie(metadata=True)
adjacency = graph.adjacency
position = graph.position
[8]:
image = visualize_graph(adjacency, position, scale=0.5)
[9]:
SVG(image)
[9]:
../../_images/tutorials_data_toy_graphs_12_0.svg

Karate club

[10]:
graph = karate_club(metadata=True)
adjacency = graph.adjacency
position = graph.position
labels = graph.labels
[11]:
image = visualize_graph(adjacency, position, labels=labels)
SVG(image)
[11]:
../../_images/tutorials_data_toy_graphs_15_0.svg

Les Miserables

[12]:
graph = miserables(metadata=True)
adjacency = graph.adjacency
position = graph.position
names = graph.names
[13]:
image = visualize_graph(adjacency, position, names, scale=2)
SVG(image)
[13]:
../../_images/tutorials_data_toy_graphs_18_0.svg

Painters

[14]:
graph = painters(metadata=True)
adjacency = graph.adjacency
names = graph.names
position = graph.position
[15]:
image = visualize_graph(adjacency, position, names)
SVG(image)
[15]:
../../_images/tutorials_data_toy_graphs_21_0.svg

Star wars

[16]:
# bipartite graph
graph = star_wars(metadata=True)
biadjacency = graph.biadjacency
names_row = graph.names_row
names_col = graph.names_col
[17]:
image = visualize_bigraph(biadjacency, names_row, names_col)
SVG(image)
[17]:
../../_images/tutorials_data_toy_graphs_24_0.svg
[18]:
# biadjacency matrix only
biadjacency = star_wars()

Movie-actor

[19]:
# bipartite graph
graph = movie_actor(metadata=True)
biadjacency = graph.biadjacency
names_row = graph.names_row
names_col = graph.names_col
[20]:
image = visualize_bigraph(biadjacency, names_row, names_col)
SVG(image)
[20]:
../../_images/tutorials_data_toy_graphs_28_0.svg