Skip to main content

Graph.update_edge_weight

Update the weight of a directed edge

Usage

update_edge_weight(edge:list, newWeight:int)

Parameters:
      edge : list
            A list in the form of: [source vertice, destination vertice]
      new_weight : int
            new weight of the edge

Example

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