Skip to main content

MultiWeightedGraph

  • A class representing graphs having multiple weights associated to each edge.

Project structure

- multi_weighted_graph (root)
    - license
    - README.md
    - .gitignore
    - pyproject.toml
    - src/multi_weighted_graph (folder)
        - __init__.py
        - _core.py
        - _utils.py
        - py.typed
    - tests (folder)
        - test_core.py

Tech stack

  • Python 3.14.3
  • pytest 9.1.1

How to use it

  • To run tests run the command:
pytest
  • Import the class and start using it:
from multi_weighted_graph import MultiWeightedGraph

my_graph = MultiWeightedGraph("My New Graph", 2)
my_graph.add_edge("a", "b", [4, 2])
my_graph.add_edge("b", "c", [3, 2])
my_graph.add_edge("c", "d", [2, 2])
my_graph.add_edge("a", "d", [1, 3])
my_graph.add_edge("e", "f", [3, 5])
my_graph.remove_edge("e", "f")

print(my_graph.minimal_spanning_tree())
print(my_graph.matrix_of_distances())
print(my_graph.matrix_of_distances_from_source("a"))
  • Calculate the minimal spanning tree:
>>> print(my_graph.minimal_spanning_tree()) 
[GraphEdge('a', 'd', [1, 2]), GraphEdge('c', 'd', [2, 2]), GraphEdge('b', 'c', [3, 2])]

>>> print(my_graph.minimal_spanning_tree(1)) # building the minimal spanning tree using the second weight associated to edges
[GraphEdge('a', 'b', [4, 2]), GraphEdge('b', 'c', [3, 2]), GraphEdge('c', 'd', [2, 2])]
  • Calculate the matrix of distances between each vertex:
>>> print(my_graph.matrix_of_distances())
[[0, 4, 3, 1], [4, 0, 3, 5], [3, 3, 0, 2], [1, 5, 2, 0]]
  • Calculate the matrix of distances from a vertex to all the others
>>> print(my_graph.matrix_of_distances_from_source("a", 0)) # distance from vertex "a" to all the others, using first weight associated to edges
[0, 4, 3, 1]

Notes

  • The intended use of this project is for personal and/or educational purposes.
  • The project is under the Apache License, that you can see from here

Metadata

Release files for multi-weighted-graph 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for multi-weighted-graph 0.3.0
File Size Uploaded Provenance Actions
multi_weighted_graph-0.3.0.tar.gz 8.7 kB Without provenance Details for multi_weighted_graph-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for multi-weighted-graph 0.3.0
File Interpreter ABI Platform Actions
multi_weighted_graph-0.3.0-py3-none-any.whl Python 3 none any Details for multi_weighted_graph-0.3.0-py3-none-any.whl

Total release size: 17.7 kB

Release files / multi_weighted_graph-0.3.0.tar.gz

Download URL multi_weighted_graph-0.3.0.tar.gz
Size 8.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f85bae9def16f6c1fb9ba566f1c133c07f9244737f2b3385a1fc966f478bb35b
BLAKE2b-256 checksum
How to use checksums
c3483d5067a3cfb2bc0ffa84cde8900522e2c621f4b30dc229e568a87240b104
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Release files / multi_weighted_graph-0.3.0-py3-none-any.whl

Download URL multi_weighted_graph-0.3.0-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e0d3afe1b93e91d97cfe4b1246a48e607d3d6b21a1d59db0b5a041025332f4ef
BLAKE2b-256 checksum
How to use checksums
0b26fa2ef192aaaab91217c5e36d82efb398c19f183a594bf3f9cfc0ae3a8a2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Security for multi-weighted-graph 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page