Paths

Visualization of paths.

[1]:
from IPython.display import SVG
[2]:
from sknetwork.data import house, cyclic_digraph, star_wars
from sknetwork.visualization import svg_graph, svg_digraph, svg_bigraph

Graphs

[3]:
graph = house(True)
adjacency = graph.adjacency
position = graph.position
[4]:
image = svg_graph(adjacency, position, edge_width=5, edge_labels=[(0, 1, 0), (1, 2, 0), (2, 3, 0)])
[5]:
SVG(image)
[5]:
../../_images/tutorials_visualization_paths_7_0.svg
[6]:
image = svg_graph(None, position, edge_width=5, edge_labels=[(0, 1, 0), (1, 2, 0), (2, 3, 0)])
[7]:
SVG(image)
[7]:
../../_images/tutorials_visualization_paths_9_0.svg

Digraphs

[8]:
graph = cyclic_digraph(10, metadata=True)
adjacency = graph.adjacency
position = graph.position
[9]:
path1 = [(0, 1, 0), (1, 2, 0), (2, 3, 0)]
path2 = [(6, 7, 1), (7, 8, 1)]
[10]:
image = svg_digraph(adjacency, position, width = 200, height=None, edge_width=5, edge_labels=path1 + path2)
[11]:
SVG(image)
[11]:
../../_images/tutorials_visualization_paths_14_0.svg

Bigraphs

[12]:
graph = star_wars(True)
biadjacency = graph.biadjacency
names_row = graph.names_row
names_col = graph.names_col
[13]:
path = [(0, 1, 0), (2, 1, 0)]
[14]:
image = svg_bigraph(biadjacency, names_row=names_row, names_col=names_col, edge_width=5, edge_labels=path)
[15]:
SVG(image)
[15]:
../../_images/tutorials_visualization_paths_19_0.svg