Skip to main content

reachability

This function checks if it is possible to travel from a source vertex to a destination vertex

Usage

reachability(graph: Graph, source: int, destination: int)

Parameters:
      graph : Graph
            Graph Object
      source : int
            Source Vertex
      destination : int
            Destination Vertex

Returns:
      tuple
            A tuple consisting of a boolean value and the path to travel from source to destination.

Example

from jellybeans.algos import reachabilityfrom 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)reachable, path = reachability(g, 1, 9)print(reachable) # Trueprint(path) # (1, 5, 9)