This repository includes the code of the experiments conducted in the paper "The Central Spanning Tree Problem" by Enrique Fita Sanmartín, Christoph Schnörr and Fred A. Hamprecht. The paper is available here.
[11]: Gilbert et. al.: Steiner Minimal Trees (1968)
[18]: Kruskal: On the Shortest Spanning Subtree of a Graph and the Traveling Salesman Problem (1956)
[21]: Masone et. al.: The minimum routing cost tree problem: State of the art and a core-node based heuristic algorithm (2019)
The code should work for Python>=3.8. To install the required packages, run the following command:
pip install -r requirements.txt
import numpy as np
try:
# if installed
from CST.T_datacls.T_datacls import T_data
except ModuleNotFoundError:
#if Not installed
from lib.CST.T_datacls.T_datacls import T_data
# Generate random data
n = 100
np.random.seed(0)
P = np.random.rand(n, 2)
# Create the T_data object
tdata = T_data(P,verbose=False)
# Compute the CST and BCST
alpha=0.5 # alpha parameter
maxiter_mSTreg = 10 # maximum number of iterations for the mSTreg algorithm
return_topo_CST = True # If True, the CST topology is also computed and stored in the trees dictionary of tdata
tdata.compute_BCST(alpha=alpha, maxiter_mSTreg=maxiter_mSTreg, return_topo_CST=return_topo_CST)
# Keys of the dictionary with the trees
print(tdata.trees.keys())
Àfter running tdata.compute_BCST
, the object tdata
stores in an internal dictionary tdata.trees
the CST and
BCST trees. The keys of the dictionary are the names of the trees, which are composed by the tree type (CST or BCST) and
the alpha parameter used to compute the tree, e.g. 'CST_0.50' & 'BCST_0.50'.
The minimum spanning tree is accessed by the key 'mST'.
The values of the dictionary are Tree_cls objects, which store the tree topology and geometry.
print(tdata.trees['CST_%0.2f' % alpha])
'''
Output:
Tree:
T: 100x100
widths
cost: 1.518992
'''
CST trees contain the following attributes:
T
: Sparse adjacency matrix of the treewidths
: List containing the centralities of each edge. They are ordered in the same way as the edges in the adjacency matrix, row-wise.cost
: Total cost of the tree.
print(tdata.trees['BCST_%0.2f' % alpha])
'''
Output:
Tree_SP:
T: 198x198
num_terminals: 100
adj: 98x3
adj_flows: 98x3
coords: 198x2
widths
cost: 1.457789
T_bp_filtered: 163x163
coords_filtered: 163x2
idxs_filtered: len=163
widths_filtered
'''
BCST trees contain the following attributes:
-Tree_SP
: Sparse adjacency matrix of the tree. Terminals correspond to the first indices while Steiner points are
the last ones.
num_terminals
: Number of terminal nodes in the tree.adj
: Different representation of the tree topology. It is a 2D array where each row corresponds to a Steiner point, and the columns are indices of the adjacent nodes (3 per Steiner point).coords
: Coordinates of the nodes in the tree. Terminals correspond to the first indices while Steiner points are the last ones.widths
: List containing the centralities of each edge, ordered in the same way as the edges in the adjacency matrix.cost
: Total cost of the tree.T_bp_filtered
: Sparse adjacency matrix of the tree after removing collapsed Steiner points, i.e. Steiner points which shared the same position once they were optimized.coords_filtered
: Coordinates of the nodes in the filtered tree.idxs_filtered
: List containing the indices of the coordinates included in the filtered tree.widths_filtered
: Centralities of the edges in the filtered tree.
The Central Spanning Tree (CST) is a family of robust spanning trees embedded in Euclidean space, whose geometrical
structure is resilient against perturbations such as noise on the coordinates of the nodes. Two variants of the
problem are explored: one permitting the inclusion of Steiner points (referred to as branched central spanning tree
or BCST), and another that does not. The family of trees is defined through a parameterized NP-hard minimization
problem over the edge lengths, with specific instances including the minimum spanning tree or the Euclidean Steiner
tree. The minimization problem weighs the length of the edges by their tree edge-centralities, which are regulated
by a parameter
where
CST | BCST |
---|---|
As
CST | BCST |
---|---|
α=0.00 | α=0.00 |
α=0.25 | α=0.25 |
α=0.50 | α=0.50 |
α=0.75 | α=0.75 |
α=1.00 | α=1.00 |
The central spanning tree is a NP-hard problem. It is known that BCST topology can be represented by a so called full topology, which is a tree that contains all input nodes (terminals) as leaves and all Steiner points have degree 3. To approximate the solution, we propose a heuristic algorithm called mSTreg, which alternates between two steps:
- Geometry update: It updates the coordinates of the Steiner points. Given a topology, the optimal position of the coordinates can be computed efficiently. Code for the geometry update is available has been based on the optimization of the Steiner points for the Branched Optimal Transport problem, available here.
- Topology update: It updates the topology of the tree. Given the coordinates of the nodes and the optimal Steiner point coordinates of the previous step, it updates the topology of the tree, by computing the minimum spanning tree (mST) over all nodes (Steiner and terminal nodes). The mST is then transformed into a full topology since we know that the optimal topology is a full topology.
α = 0.25 | α = 0.50 |
---|---|
α = 0.75 | α = 1.00 |
---|---|
BCST α = 0.00 | BCST α = 0.50 | BCST α = 0.70 | BCST α = 1.00 |
---|---|---|---|
BCST α = 0.00 | BCST α = 0.50 | BCST α = 0.70 | BCST α = 1.00 |
---|---|---|---|
BCST α = 0.00 | BCST α = 0.50 | BCST α = 0.70 | BCST α = 1.00 |
---|---|---|---|