Skip to main content

A python package for constructing and analysing the minimum spanning tree

Project description


Author: Krishna Naidoo
Version: 1.2.0

Build Status codecov PyPI version status DOI License: MIT Binder


The minimum spanning tree (MST), a graph constructed from a distribution of points, draws lines between pairs of points so that all points are linked in a single skeletal structure that contains no loops and has minimal total edge length. The MST has been used in a broad range of scientific fields such as particle physics, in astronomy and cosmology. Its success in these fields has been driven by its sensitivity to the spatial distribution of points and the patterns within. MiSTree, a public Python package, allows a user to construct the MST in a variety of coordinates systems, including Celestial coordinates used in astronomy. The package enables the MST to be constructed quickly by initially using a k-nearest neighbour graph (k NN, rather than a matrix of pairwise distances) which is then fed to Kruskal's algorithm to construct the MST. MiSTree enables a user to measure the statistics of the MST and provides classes for binning the MST statistics (into histograms) and plotting the distributions. Applying the MST will enable the inclusion of high-order statistics information from the cosmic web which can provide additional information to improve cosmological parameter constraints. This information has not been fully exploited due to the computational cost of calculating N-point statistics. MiSTree was designed to be used in cosmology but could be used in any field which requires extracting non-Gaussian information from point distributions.


  • Python 2.7 or 3.4+
  • numpy
  • matplotlib
  • scipy
  • scikit-learn
  • f2py (should be installed with numpy)

For testing you will require nose or pytest.


MiSTree can be installed as follows:

pip install mistree [--user]

The --user is optional and only required if you don’t have write permission. If you want to work on the Github version you can clone the repository and install an editable version:

git clone
cd mistree
pip install -e . [--user]

From the mistree directory you can then test the install using nose:

python test

or using pytest:

python -m pytest

You should now be able to import the module:

import mistree as mist


In depth documentation and tutorials are provided here.


The tutorials in the documentation are supplied as ipython notebooks which can be downloaded from here or can be run online using binder.


If you have any issues with the code or want to suggest ways to improve it please open a new issue (here) or (if you don't have a github account) email

Download files

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

Source Distribution

mistree-1.2.0.tar.gz (27.9 kB view hashes)

Uploaded source

Built Distributions

mistree-1.2.0-py2.7-macosx-10.6-x86_64.egg (191.8 kB view hashes)

Uploaded 2 7

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page