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.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| multi_weighted_graph-0.4.0.tar.gz | 9.2 kB | Without provenance | Details for multi_weighted_graph-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| multi_weighted_graph-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for multi_weighted_graph-0.4.0-py3-none-any.whl |
Total release size: 18.6 kB
Release files / multi_weighted_graph-0.4.0.tar.gz
| Download URL | multi_weighted_graph-0.4.0.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ee9e1f18c2f688c936b3e2fa6328880453afd13218a7fff84276596c8005b7d9
|
|
BLAKE2b-256 checksum How to use checksums |
a69fb748189f64dc4168a7d7387075d82b9476a87cdc7823490174588278fe0a
|
| 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.4.0-py3-none-any.whl
| Download URL | multi_weighted_graph-0.4.0-py3-none-any.whl |
|---|---|
| Size | 9.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b87295093e46d1deee59a95d3226cd9e47b28bb29d9cbc6c36a7131a692873a9
|
|
BLAKE2b-256 checksum How to use checksums |
29982bb4351d40e9a0a7368d48a79c2a651a035151413c068614bd8de0e01922
|
| 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.4.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.