Skip to main content

yamada

Python implementation of the Yamada-Kataoka-Watanabe algorithm to find all minimum spanning trees in an undirected graph.

Implementation mostly follows the ALL_MST2 algorithm outlined in the original paper. The implementation differs slightly by performing a breadth-first search in liue of a depth-first search. This modification was made so that more variable spanning trees were returned when capping the total number of trees returned.

Original Paper

Yamada, T. Kataoka, S. Watanabe, K. "Listing all the minimum spanning trees in an undirected graph". International Journal of Computer Mathematics. Vol 87, No. 14. pp. 3175 - 3185. November 2010.

Installation

This module is not currently hosted through popular package managing tools such as pip or conda. Therefore, simply cloning, downloading, or forking this repository is the best way to install the package. To ensure global access to the module, you'll want to add the repository location to your PYTHONPATH.

Tests

Proper implementation was tested using the examples found in the original paper, and implementation of those tests can be found in the test subdirectory. The graph structure used in Figure 3 of the original paper, is used to explicitly test for exact minimum spanning tree membership. Meanwhile, the unit-weight, complete graphs ki are tested for unique membership and expected length for i in {3, 4, 5, 6}. The Substitute() algorithm is tested using the example found in table 3 of the original paper.

To run the tests simply execute the following command:

python tests/test_yamada.py

Dependencies

This module depends on the numpy, networkx, collections, sortedcontainers, sys, and unittest packages, and was written in Python 3.6. The exact requirements can be found in the requirements.txt file. A yamada.yaml file is also provided for conda environment creation.

Example

import yamada
import networkx as nx
 
example = {1: {2: {'weight': 2},
               3: {'weight': 1}},
           2: {1: {'weight': 2},
               3: {'weight': 3},
               4: {'weight': 1}},
           3: {1: {'weight': 1},
               2: {'weight': 3},
               4: {'weight': 2},
               5: {'weight': 2}},
           4: {2: {'weight': 1},
               3: {'weight': 2},
               5: {'weight': 1},
               6: {'weight': 3}},
           5: {3: {'weight': 2},
               4: {'weight': 1},
               6: {'weight': 3}},
           6: {4: {'weight': 3},
               5: {'weight': 3}}}
graph = nx.Graph(example)

# retrieve all minimum spanning trees 
graph_yamada = yamada.Yamada(graph)
all_msts = graph_yamada.spanning_trees()
print(len(all_msts))

# retrieve fixed number of minimum spanning trees
graph_yamada = yamada.Yamada(graph, n_trees=3)
msts = graph_yamada.spanning_trees()
print(len(msts))

Metadata

Release files for yamada-mst 0.1.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 yamada-mst 0.1.0
File Size Uploaded Provenance Actions
yamada-mst-0.1.0.tar.gz 14.7 kB Without provenance Details for yamada-mst-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for yamada-mst 0.1.0
File Interpreter ABI Platform Actions
yamada_mst-0.1.0-py3-none-any.whl Python 3 none any Details for yamada_mst-0.1.0-py3-none-any.whl

Total release size: 27.2 kB

Release files / yamada-mst-0.1.0.tar.gz

Download URL yamada-mst-0.1.0.tar.gz
Size 14.7 kB
Tags Source
SHA-256 checksum
How to use checksums
393ca1c8a70f04da6c9448f05d12e86a1a973c2e9bbcba9952835748a729a86c
BLAKE2b-256 checksum
How to use checksums
5e18c7d32691976ed8ee71eff68c70c64b97c8b105f0b6ec01ffdbb55fd6337a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.8.8

Release files / yamada_mst-0.1.0-py3-none-any.whl

Download URL yamada_mst-0.1.0-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6bb887dd1e04b15221f16f13344047e33f2ea1b84d5eac6cb1cc1d08fea0bee2
BLAKE2b-256 checksum
How to use checksums
6078f99654c5b75fb8e92495e2c148c21b2fe2327c1c5bd357b0fb633e553ad0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.8.8

Security for yamada-mst 0.1.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.1.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