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 svg_graph, svg_digraph, svg_bigraph

Graphs

House graph

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

Bow tie

[8]:
graph = bow_tie(metadata=True)
adjacency = graph.adjacency
position = graph.position
[9]:
image = svg_graph(adjacency, position, scale=0.5)
[10]:
SVG(image)
[10]:
../../_images/tutorials_data_toy_graphs_14_0.svg

Karate club

[11]:
graph = karate_club(metadata=True)
adjacency = graph.adjacency
position = graph.position
labels = graph.labels
[12]:
image = svg_graph(adjacency, position, labels=labels)
[13]:
SVG(image)
[13]:
../../_images/tutorials_data_toy_graphs_18_0.svg

Les Miserables

[14]:
graph = miserables(metadata=True)
adjacency = graph.adjacency
position = graph.position
names = graph.names
[15]:
image = svg_graph(adjacency, position, names, scale=2)
[16]:
SVG(image)
[16]:
../../_images/tutorials_data_toy_graphs_22_0.svg

Digraphs

[17]:
graph = painters(metadata=True)
adjacency = graph.adjacency
names = graph.names
position = graph.position
[18]:
image = svg_digraph(adjacency, position, names)
[19]:
SVG(image)
[19]:
../../_images/tutorials_data_toy_graphs_26_0.svg

Bigraphs

Star wars

[20]:
graph = star_wars(metadata=True)
biadjacency = graph.biadjacency
names_row = graph.names_row
names_col = graph.names_col
[21]:
image = svg_bigraph(biadjacency, names_row, names_col)
[22]:
SVG(image)
[22]:
../../_images/tutorials_data_toy_graphs_31_0.svg
[23]:
# biadjacency matrix only
biadjacency = star_wars()

Movie-actor

[24]:
graph = movie_actor(metadata=True)
biadjacency = graph.biadjacency
names_row = graph.names_row
names_col = graph.names_col
[25]:
image = svg_bigraph(biadjacency, names_row, names_col)
[26]:
SVG(image)
[26]:
../../_images/tutorials_data_toy_graphs_36_0.svg