{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "0750e74e",
            "cell_type": "markdown",
            "source": "<div class='alert alert-warning'>\n\nSciPy's interactive examples with Jupyterlite are experimental and may not always work as expected. Execution of cells containing imports may result in large downloads (up to 60MB of content for the first import from SciPy). Load times when importing from SciPy may take roughly 10-20 seconds. If you notice any problems, feel free to open an [issue](https://github.com/scipy/scipy/issues/new/choose).\n\n</div>",
            "metadata": {}
        },
        {
            "id": "913ac69e",
            "cell_type": "markdown",
            "source": "The following example shows the computation of a minimum spanning tree\nover a simple four-component graph\n```\n\ninput graph             minimum spanning tree\n\n(0)                         (0)\n/   \\                       /\n3     8                     3\n/       \\                   /\n(3)---5---(1)               (3)---5---(1)\n\\       /                           /\n6     2                           2\n\\   /                           /\n(2)                         (2)\n\n```\nIt is easy to see from inspection that the minimum spanning tree involves\nremoving the edges with weights 8 and 6.  In compressed sparse\nrepresentation, the solution looks like this:\n",
            "metadata": {}
        },
        {
            "id": "69755e1e",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "from scipy.sparse import csr_array\nfrom scipy.sparse.csgraph import minimum_spanning_tree\nX = csr_array([[0, 8, 0, 3],\n               [0, 0, 2, 5],\n               [0, 0, 0, 6],\n               [0, 0, 0, 0]])\nTcsr = minimum_spanning_tree(X)\nTcsr.toarray().astype(int)",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([[0, 0, 0, 3],\n       [0, 0, 2, 5],\n       [0, 0, 0, 0],\n       [0, 0, 0, 0]])"
                    },
                    "execution_count": null
                }
            ]
        }
    ]
}