graphs.depth_first_search¶

Non recursive implementation of a DFS algorithm.

Attributes¶

G

Functions¶

depth_first_search(→ set[str])

Depth First Search on Graph

Module Contents¶

graphs.depth_first_search.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

graphs.depth_first_search.G¶

thealgorithms-python

Navigation

index.md

  • Contributing guidelines
  • Getting Started
  • Community Channels
  • List of Algorithms
  • MIT License
  • API Reference
    • maths
    • other
    • sorts
    • graphs
    • hashes
    • matrix
    • ciphers
    • geodesy
    • physics
    • quantum
    • strings
    • fractals
    • geometry
    • graphics
    • knapsack
    • searches
    • financial
    • blockchain
    • scheduling
    • conversions
    • electronics
    • fuzzy_logic
    • backtracking
    • audio_filters
    • file_transfer
    • project_euler
    • greedy_methods
    • linear_algebra
    • neural_network
    • boolean_algebra
    • computer_vision
    • data_structures
    • networking_flow
    • web_programming
    • bit_manipulation
    • data_compression
    • machine_learning
    • cellular_automata
    • genetic_algorithm
    • divide_and_conquer
    • linear_programming
    • dynamic_programming
    • digital_image_processing

Related Topics

  • Documentation overview
    • API Reference
      • graphs
        • Previous: graphs.deep_clone_graph
        • Next: graphs.depth_first_search_2
©2014, TheAlgorithms. | Powered by Sphinx 8.2.3 & Alabaster 1.0.0 | Page source