Skip to main content

Python graphs library to perform BFS, DFS, Dijkstra, and more.

Project description

pygraphs

Description

pygraphs provides tools to perform BFS, DFS, Dijkstra, and more on graphs. The package support weighted graphs, directed graphs but not multigraphs.

Authors

Installation

Install with pip

pip install pygraphs
pip install git+https://github.com/Artezaru/pygraphs.git

Clone with git

git clone https://github.com/Artezaru/pygraphs.git

Usage

This section will guide you through the basic usage of the pygraphs package. Several examples are available on the online documentation.

Construct a graph

To create a graph, you can provide the edges or the adjacency :

from pygraphs import Graph

graph = [[1, 2], [0, 2], [0, 1, 3], [2, 4], [3], [6], [5]]
undirected_graph = Graph.from_adjacency(graph)

Perform operations on graphs

Several algorithms are availables to perform basic operations on graphs. For example, the following compute the adjacency matrix by BFS:

from pygraphs import bfs_matrix

adjacency_matrix = bfs_matrix(undirected_graph)
print(f"adjacency_matrix (shape={len(adjacency_matrix)}x{len(adjacency_matrix[0])}):")
print(adjacency_matrix)

# Expected output:
# adjacency_matrix (shape=(7x7)):
# [[ 0  1  1  2  3 -1 -1]
#  [ 1  0  1  2  3 -1 -1]
#  [ 1  1  0  1  2 -1 -1]
#  [ 2  2  1  0  1 -1 -1]
#  [ 3  3  2  1  0 -1 -1]
#  [-1 -1 -1 -1 -1  0  1]
#  [-1 -1 -1 -1 -1  1  0]]

License

Copyright 2026 Artezaru

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Project details


Download files

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

Source Distribution

pygraphs_x-0.0.3.tar.gz (281.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pygraphs_x-0.0.3-py3-none-any.whl (68.2 kB view details)

Uploaded Python 3

File details

Details for the file pygraphs_x-0.0.3.tar.gz.

File metadata

  • Download URL: pygraphs_x-0.0.3.tar.gz
  • Upload date:
  • Size: 281.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pygraphs_x-0.0.3.tar.gz
Algorithm Hash digest
SHA256 000309fdcfbdc3a64edbe866cb318c67de7e706b9087f81bf5d5662b82a33ab3
MD5 54e0238c82ec5fb0f92d05ea583a2217
BLAKE2b-256 27a5e34d30f4a5bdab86a92310a3f260e69d19ba5ead6fc4814c0e753e3eb38b

See more details on using hashes here.

File details

Details for the file pygraphs_x-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: pygraphs_x-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 68.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pygraphs_x-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d50c4083c62b4f79b4f6e313b3af85603f012d2659e7310393420715695692f3
MD5 207f1a3c6a4b3ff79584542887a8f0cb
BLAKE2b-256 862a4019a32bf403bfbeb2dafc4cbf3d34a80091a4ea5b25c99009840c44c222

See more details on using hashes here.

Supported by

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