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_bigraph

Graphs

[3]:
graph = house(True)
adjacency = graph.adjacency
position = graph.position
[4]:
path = [(0, 1), (1, 2), (2, 3)]
edge_labels = [(*edge, 0) for edge in path]
[5]:
image = svg_graph(adjacency, position, edge_width=3, edge_labels=edge_labels)
SVG(image)
[5]:
../../_images/tutorials_visualization_paths_7_0.svg
[6]:
image = svg_graph(None, position, edge_width=3, edge_labels=edge_labels)
SVG(image)
[6]:
../../_images/tutorials_visualization_paths_8_0.svg

Directed graphs

[7]:
graph = cyclic_digraph(10, metadata=True)
adjacency = graph.adjacency
position = graph.position
[8]:
paths = [[(0, 1), (1, 2), (2, 3)], [(6, 7), (7, 8)]]
edge_labels = [(*edge, label) for label, path in enumerate(paths) for edge in path]
[9]:
image = svg_graph(adjacency, position, width=200, height=None, edge_width=3, edge_labels=edge_labels)
SVG(image)
[9]:
../../_images/tutorials_visualization_paths_12_0.svg

Bipartite graphs

[10]:
graph = star_wars(True)
biadjacency = graph.biadjacency
names_row = graph.names_row
names_col = graph.names_col
[11]:
path = [(0, 1), (2, 1)]
edge_labels = [(*edge, 0) for edge in path]
[12]:
image = svg_bigraph(biadjacency, names_row=names_row, names_col=names_col, edge_width=3, edge_labels=edge_labels)
SVG(image)
[12]:
../../_images/tutorials_visualization_paths_16_0.svg