graphs.connected_components =========================== .. py:module:: graphs.connected_components .. autoapi-nested-parse:: https://en.wikipedia.org/wiki/Component_(graph_theory) Finding connected components in graph Attributes ---------- .. autoapisummary:: graphs.connected_components.test_graph_1 graphs.connected_components.test_graph_2 Functions --------- .. autoapisummary:: graphs.connected_components.connected_components graphs.connected_components.dfs Module Contents --------------- .. py:function:: connected_components(graph: dict) -> list This function takes graph as a parameter and then returns the list of connected components >>> connected_components(test_graph_1) [[0, 1, 3, 2], [4, 5, 6]] >>> connected_components(test_graph_2) [[0, 1, 3, 2], [4], [5]] .. py:function:: dfs(graph: dict, vert: int, visited: list) -> list Use depth first search to find all vertices being in the same component as initial vertex >>> dfs(test_graph_1, 0, 5 * [False]) [0, 1, 3, 2] >>> dfs(test_graph_2, 0, 6 * [False]) [0, 1, 3, 2] .. py:data:: test_graph_1 .. py:data:: test_graph_2