Skip to main content

Graph.to_adj_list

Generate an adjancency list from the graph

Usage

to_adj_list()

Returns:
      dict
            The transposed graph

Example

from jellybeans.structures import Graphg = Graph()g.add_vertex(1)g.add_vertex(5)g.add_vertex(9)g.add_bidirected_edge(1, 5, (20, 30))g.add_edge(5, 9, 12)print(g.to_adj_list()) # {1: [(5, 20)], 5: [(1, 30), (9, 12)], 9: []}