Skip to main content

Implement of Depth First Search for a graph

Project description

Overview

PyGraph_DFS is a Python package that provides a straightforward and efficient way to perform Depth-First Search (DFS) on a graph. It is a versatile tool that can be used in various scenarios where graph traversal and exploration are necessary.

Installation

You can install PyGraph_DFS using pip:

pip install PyGraph_DFS

Usage

After installing the package, you can use it in your Python scripts as follows:

from PyGraph_DFS import GraphDFS

# Create a graph instance
my_graph = GraphDFS()

# Add edges to the graph
my_graph.add_edge("A", "B")
my_graph.add_edge("B", "C")
my_graph.add_edge("B", "D")
my_graph.add_edge("D", "E")

# Perform Depth-First Search (DFS)
visited_nodes = my_graph.dfs("A")

# Print the visited nodes
print(visited_nodes)

Example Output

The above code will produce the following output:

['A', 'B', 'C', 'D', 'E']

License

This project is licensed under the MIT License. See the LICENSE.

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyGraph_DFS-0.1.tar.gz (2.5 kB view hashes)

Uploaded Source

Built Distribution

PyGraph_DFS-0.1-py3-none-any.whl (2.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page