graphs.breadth_first_search¶
Author: OMKAR PATHAK
Attributes¶
Classes¶
Module Contents¶
- class graphs.breadth_first_search.Graph¶
- 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
- 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]
- print_graph() None ¶
prints adjacency list representation of graaph >>> g = Graph() >>> g.print_graph() >>> g.add_edge(0, 1) >>> g.print_graph() 0 : 1
- vertices: dict[int, list[int]]¶
- graphs.breadth_first_search.g¶