graphs.breadth_first_search =========================== .. py:module:: graphs.breadth_first_search .. autoapi-nested-parse:: Author: OMKAR PATHAK Attributes ---------- .. autoapisummary:: graphs.breadth_first_search.g Classes ------- .. autoapisummary:: graphs.breadth_first_search.Graph Module Contents --------------- .. py:class:: Graph .. py:method:: add_edge(from_vertex: int, to_vertex: int) -> None adding the edge between two vertices >>> g = Graph() >>> g.print_graph() >>> g.add_edge(0, 1) >>> g.print_graph() 0 : 1 .. py:method:: bfs(start_vertex: int) -> set[int] >>> g = Graph() >>> g.add_edge(0, 1) >>> g.add_edge(0, 1) >>> g.add_edge(0, 2) >>> g.add_edge(1, 2) >>> g.add_edge(2, 0) >>> g.add_edge(2, 3) >>> g.add_edge(3, 3) >>> sorted(g.bfs(2)) [0, 1, 2, 3] .. py:method:: print_graph() -> None prints adjacency list representation of graaph >>> g = Graph() >>> g.print_graph() >>> g.add_edge(0, 1) >>> g.print_graph() 0 : 1 .. py:attribute:: vertices :type: dict[int, list[int]] .. py:data:: g