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.4.tar.gz (281.4 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.4-py3-none-any.whl (68.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pygraphs_x-0.0.4.tar.gz
Algorithm Hash digest
SHA256 9564b3367e8ec8c85cce35c9f2f5440ae85ffedf75ad0e715f0b64246d6338dd
MD5 6245679d2dcfcf3a487fdbee506d7a72
BLAKE2b-256 a7843dcf9fcfd2c4b9f02b5305cc21052b03c26d647b1f642b8c1e9262f50505

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pygraphs_x-0.0.4-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.11.15

File hashes

Hashes for pygraphs_x-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7e34cf732c72f6b3906b04d624bce22984f7040e209d66aa9a4b547b676dd280
MD5 7bd6c47435dfbfc2780ff224802a18a3
BLAKE2b-256 4e3d306738833e425dae5983b0cb54d86caf2f25e306270990e3d58977c023f1

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