graphs.depth_first_search ========================= .. py:module:: graphs.depth_first_search .. autoapi-nested-parse:: Non recursive implementation of a DFS algorithm. Attributes ---------- .. autoapisummary:: graphs.depth_first_search.G Functions --------- .. autoapisummary:: graphs.depth_first_search.depth_first_search Module Contents --------------- .. py:function:: depth_first_search(graph: dict, start: str) -> set[str] Depth First Search on Graph :param graph: directed graph in dictionary format :param start: starting vertex as a string :returns: the trace of the search >>> input_G = { "A": ["B", "C", "D"], "B": ["A", "D", "E"], ... "C": ["A", "F"], "D": ["B", "D"], "E": ["B", "F"], ... "F": ["C", "E", "G"], "G": ["F"] } >>> output_G = list({'A', 'B', 'C', 'D', 'E', 'F', 'G'}) >>> all(x in output_G for x in list(depth_first_search(input_G, "A"))) True >>> all(x in output_G for x in list(depth_first_search(input_G, "G"))) True .. py:data:: G