Paths
Visualization of paths.
[1]:
from IPython.display import SVG
[2]:
from sknetwork.data import house, cyclic_digraph, star_wars
from sknetwork.visualization import visualize_graph, visualize_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 = visualize_graph(adjacency, position, edge_width=3, edge_labels=edge_labels)
SVG(image)
[5]:
[6]:
image = visualize_graph(None, position, edge_width=3, edge_labels=edge_labels)
SVG(image)
[6]:
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 = visualize_graph(adjacency, position, width=200, height=None, edge_width=3, edge_labels=edge_labels)
SVG(image)
[9]:
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 = visualize_bigraph(biadjacency, names_row=names_row, names_col=names_col, edge_width=3, edge_labels=edge_labels)
SVG(image)
[12]: