Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/pygraph/functions/__pycache__/spanning_tree.cpython-39.pyc
Ðазад
a ^�hb � @ s` d Z ddlmZ ddlmZmZ ddlmZmZm Z dd� Z dd � Zd d� Zdd � Z dd� ZdS )z-Implements a minimum spanning tree algorithm.� )�DisconnectedGraphError� )�get_connected_components�%get_connected_components_as_subgraphs)�DisjointSet� PriorityQueue�get_subgraph_from_edge_listc C sH g }| � � dkr|S | �� dkr$|S t| �}t|�dkr<t�t| �}|S )z�Calculates a minimum spanning tree for a graph. Returns a list of edges that define the tree. Returns an empty list for an empty graph. � r )� num_nodes� num_edgesr �lenr �kruskal_mst)�graphZmst�connected_components� edge_list� r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/pygraph/functions/spanning_tree.py�find_minimum_spanning_tree s r c C s t | �}t| |�}|S )zFCalculates a minimum spanning tree and returns a graph representation.)r r )r r �subgraphr r r �&find_minimum_spanning_tree_as_subgraph s r c C sL g }| � � dkr|S | �� dkr$|S t| �}|D ]}t|�}|�|� q0|S )z�Calculates the minimum spanning forest of a disconnected graph. Returns a list of lists, each containing the edges that define that tree. Returns an empty list for an empty graph. r )r r r r �append)r Zmsfr r r r r r �find_minimum_spanning_forest% s r c s t � �}� fdd�|D �}|S )zPCalculates the minimum spanning forest and returns a list of trees as subgraphs.c s g | ]}t � |��qS r )r )�.0r �r r r � <listcomp><