passagemath-tdlib 10.6.31rc2__cp310-cp310-musllinux_1_2_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of passagemath-tdlib might be problematic. Click here for more details.
- passagemath_tdlib-10.6.31rc2.dist-info/METADATA +92 -0
- passagemath_tdlib-10.6.31rc2.dist-info/RECORD +11 -0
- passagemath_tdlib-10.6.31rc2.dist-info/WHEEL +5 -0
- passagemath_tdlib-10.6.31rc2.dist-info/top_level.txt +2 -0
- passagemath_tdlib.libs/libgcc_s-0cd532bd.so.1 +0 -0
- passagemath_tdlib.libs/libstdc++-5d72f927.so.6.0.33 +0 -0
- sage/all__sagemath_tdlib.py +2 -0
- sage/graphs/all__sagemath_tdlib.py +1 -0
- sage/graphs/graph_decompositions/all__sagemath_tdlib.py +1 -0
- sage/graphs/graph_decompositions/tdlib.cpython-310-x86_64-linux-gnu.so +0 -0
- sage/graphs/graph_decompositions/tdlib.pyx +185 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: passagemath-tdlib
|
|
3
|
+
Version: 10.6.31rc2
|
|
4
|
+
Summary: passagemath: Tree decompositions with tdlib
|
|
5
|
+
Author-email: The Sage Developers <sage-support@googlegroups.com>
|
|
6
|
+
Maintainer: Matthias Köppe, passagemath contributors
|
|
7
|
+
License-Expression: GPL-2.0-or-later
|
|
8
|
+
Project-URL: release notes, https://github.com/passagemath/passagemath/releases
|
|
9
|
+
Project-URL: repo (upstream), https://github.com/sagemath/sage
|
|
10
|
+
Project-URL: repo, https://github.com/passagemath/passagemath
|
|
11
|
+
Project-URL: documentation, https://passagemath.org/docs/latest
|
|
12
|
+
Project-URL: homepage (upstream), https://www.sagemath.org
|
|
13
|
+
Project-URL: discourse, https://passagemath.discourse.group
|
|
14
|
+
Project-URL: tracker (upstream), https://github.com/sagemath/sage/issues
|
|
15
|
+
Project-URL: tracker, https://github.com/passagemath/passagemath/issues
|
|
16
|
+
Classifier: Development Status :: 6 - Mature
|
|
17
|
+
Classifier: Intended Audience :: Education
|
|
18
|
+
Classifier: Intended Audience :: Science/Research
|
|
19
|
+
Classifier: Operating System :: POSIX
|
|
20
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
21
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
22
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
27
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
28
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
29
|
+
Requires-Python: <3.14,>=3.10
|
|
30
|
+
Description-Content-Type: text/x-rst
|
|
31
|
+
Requires-Dist: cysignals<1.12.4; sys_platform == "win32"
|
|
32
|
+
Requires-Dist: cysignals!=1.12.0,>=1.11.2
|
|
33
|
+
Provides-Extra: test
|
|
34
|
+
Requires-Dist: passagemath-repl; extra == "test"
|
|
35
|
+
Requires-Dist: passagemath-graphs; extra == "test"
|
|
36
|
+
|
|
37
|
+
========================================================================
|
|
38
|
+
passagemath: Tree decompositions with tdlib
|
|
39
|
+
========================================================================
|
|
40
|
+
|
|
41
|
+
`passagemath <https://github.com/passagemath/passagemath>`__ is open
|
|
42
|
+
source mathematical software in Python, released under the GNU General
|
|
43
|
+
Public Licence GPLv2+.
|
|
44
|
+
|
|
45
|
+
It is a fork of `SageMath <https://www.sagemath.org/>`__, which has been
|
|
46
|
+
developed 2005-2025 under the motto “Creating a Viable Open Source
|
|
47
|
+
Alternative to Magma, Maple, Mathematica, and MATLAB”.
|
|
48
|
+
|
|
49
|
+
The passagemath fork uses the motto "Creating a Free Passage Between the
|
|
50
|
+
Scientific Python Ecosystem and Mathematical Software Communities."
|
|
51
|
+
It was created in October 2024 with the following goals:
|
|
52
|
+
|
|
53
|
+
- providing modularized installation with pip,
|
|
54
|
+
- establishing first-class membership in the scientific Python
|
|
55
|
+
ecosystem,
|
|
56
|
+
- giving `clear attribution of upstream
|
|
57
|
+
projects <https://groups.google.com/g/sage-devel/c/6HO1HEtL1Fs/m/G002rPGpAAAJ>`__,
|
|
58
|
+
- providing independently usable Python interfaces to upstream
|
|
59
|
+
libraries,
|
|
60
|
+
- offering `platform portability and integration testing
|
|
61
|
+
services <https://github.com/passagemath/passagemath/issues/704>`__
|
|
62
|
+
to upstream projects,
|
|
63
|
+
- inviting collaborations with upstream projects,
|
|
64
|
+
- `building a professional, respectful, inclusive
|
|
65
|
+
community <https://groups.google.com/g/sage-devel/c/xBzaINHWwUQ>`__,
|
|
66
|
+
- `empowering Sage users to participate in the scientific Python ecosystem
|
|
67
|
+
<https://github.com/passagemath/passagemath/issues/248>`__ by publishing packages,
|
|
68
|
+
- developing a port to `Pyodide <https://pyodide.org/en/stable/>`__ for
|
|
69
|
+
serverless deployment with Javascript,
|
|
70
|
+
- developing a native Windows port.
|
|
71
|
+
|
|
72
|
+
`Full documentation <https://passagemath.org/docs/latest/html/en/index.html>`__ is
|
|
73
|
+
available online.
|
|
74
|
+
|
|
75
|
+
passagemath attempts to support and provides binary wheels suitable for
|
|
76
|
+
all major Linux distributions and recent versions of macOS.
|
|
77
|
+
|
|
78
|
+
Binary wheels for native Windows (x86_64) are are available for a subset of
|
|
79
|
+
the passagemath distributions. Use of the full functionality of passagemath
|
|
80
|
+
on Windows currently requires the use of Windows Subsystem for Linux (WSL)
|
|
81
|
+
or virtualization.
|
|
82
|
+
|
|
83
|
+
The supported Python versions in the passagemath 10.6.x series are 3.10.x-3.13.x.
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
About this pip-installable distribution package
|
|
87
|
+
-----------------------------------------------
|
|
88
|
+
|
|
89
|
+
This pip-installable distribution ``passagemath-tdlib`` is a small optional distribution for use with `passagemath-graphs <https://pypi.org/project/passagemath-graphs>`_.
|
|
90
|
+
|
|
91
|
+
It provides a Cython interface to the ``tdlib`` library, now also known as `treedec <https://gitlab.com/freetdi/treedec>`_, providing
|
|
92
|
+
algorithms concerning tree decompositions.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
passagemath_tdlib.libs/libgcc_s-0cd532bd.so.1,sha256=QrXyyMoT5eFz2Df1EXoEtsBCQ3VIESveeHklGujc_48,183337
|
|
2
|
+
passagemath_tdlib.libs/libstdc++-5d72f927.so.6.0.33,sha256=i_QxuLSNJcDImiug4WsF5wNgprWyeL3Mc09ILo-0-Dc,3564129
|
|
3
|
+
sage/all__sagemath_tdlib.py,sha256=zag9UqFlkcjkiBCrkeLRFIXjnemsqnpTNJFfqQMezKE,64
|
|
4
|
+
sage/graphs/all__sagemath_tdlib.py,sha256=xwEAp-3HSleZKAjcgudzEBoWekMyMSx7mY9lzHCETcU,44
|
|
5
|
+
sage/graphs/graph_decompositions/all__sagemath_tdlib.py,sha256=xwEAp-3HSleZKAjcgudzEBoWekMyMSx7mY9lzHCETcU,44
|
|
6
|
+
sage/graphs/graph_decompositions/tdlib.cpython-310-x86_64-linux-gnu.so,sha256=rw2LyH3V9_k4cuIJC4kwoJmkjhWtvOr7mwbt74tpc9I,5567105
|
|
7
|
+
sage/graphs/graph_decompositions/tdlib.pyx,sha256=hTSyIq_Va3AV1GzwepFuTGzNC77BhtPvSlLj1lOmM8M,5381
|
|
8
|
+
passagemath_tdlib-10.6.31rc2.dist-info/METADATA,sha256=hUmBU_jBC2vyUxpbMHhGn43wKu3H7hs1JWAyNNGDMM0,4501
|
|
9
|
+
passagemath_tdlib-10.6.31rc2.dist-info/WHEEL,sha256=YJPq7zroHSsdctrb_KymZ4ss41PkmaA9SD9TZzqKSX8,112
|
|
10
|
+
passagemath_tdlib-10.6.31rc2.dist-info/top_level.txt,sha256=Kmzulf9WsphADFQuqgvdy5mvTLDj_V2zkFHU2s3UXos,6
|
|
11
|
+
passagemath_tdlib-10.6.31rc2.dist-info/RECORD,,
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-tdlib
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-tdlib
|
|
Binary file
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# distutils: language = c++
|
|
2
|
+
# distutils: extra_compile_args = -std=c++17
|
|
3
|
+
# sage_setup: distribution = sagemath-tdlib
|
|
4
|
+
|
|
5
|
+
r"""
|
|
6
|
+
Interface with TdLib (algorithms for tree decompositions)
|
|
7
|
+
|
|
8
|
+
This module defines functions based on TdLib, a library that implements
|
|
9
|
+
algorithms for tree decompositions written by Lukas Larisch.
|
|
10
|
+
|
|
11
|
+
**Definition** :
|
|
12
|
+
|
|
13
|
+
A `tree decomposition` of a graph `G` is a pair `(T, \beta)` consisting of a
|
|
14
|
+
tree T and a function `\beta: V(T) \rightarrow 2^{V(G)}` associating with each
|
|
15
|
+
node `t \in V(T)` a set of vertices `\beta (t) \subseteq V(G)` such that
|
|
16
|
+
|
|
17
|
+
* (T1) for every edge `e \in E(G)` there is a node `t \in V(T)` with `e
|
|
18
|
+
\subseteq \beta (t)`, and
|
|
19
|
+
|
|
20
|
+
* (T2) for all `v \in V(G)` the set `\beta^{-1} := \{t \in V(T): v \in \beta
|
|
21
|
+
(t)\}` is non-empty and connected in T.
|
|
22
|
+
|
|
23
|
+
The width of `(T, \beta)` is defined as `max\{|\beta (t)|-1: t \in V(T) \}`.
|
|
24
|
+
The treewidth of G is defined as the minimum width over all tree decompositions
|
|
25
|
+
of `G`.
|
|
26
|
+
|
|
27
|
+
**Some known results** :
|
|
28
|
+
|
|
29
|
+
- Trees have treewidth 1
|
|
30
|
+
|
|
31
|
+
- Cycles have treewidth 2
|
|
32
|
+
|
|
33
|
+
- Series-parallel graphs have treewidth at most 2
|
|
34
|
+
|
|
35
|
+
- Cliques must be contained in some bag of a tree decomposition
|
|
36
|
+
|
|
37
|
+
Computing the treewidth or a tree decomposition of a given graph is NP-hard in
|
|
38
|
+
general.
|
|
39
|
+
|
|
40
|
+
**This module contains the following functions** :
|
|
41
|
+
|
|
42
|
+
.. csv-table::
|
|
43
|
+
:class: contentstable
|
|
44
|
+
:widths: 30, 70
|
|
45
|
+
:delim: |
|
|
46
|
+
|
|
47
|
+
:meth:`treedecomposition_exact` | Compute a tree decomposition of exact width
|
|
48
|
+
:meth:`get_width` | Return the width of a given tree decomposition
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
AUTHOR: Lukas Larisch (10-25-2015): Initial version
|
|
52
|
+
|
|
53
|
+
REFERENCE:
|
|
54
|
+
|
|
55
|
+
- [ST1993]_
|
|
56
|
+
|
|
57
|
+
- [AP1986]_
|
|
58
|
+
|
|
59
|
+
- [Bod1993]_
|
|
60
|
+
|
|
61
|
+
Methods
|
|
62
|
+
-------
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
from libcpp.vector cimport vector
|
|
66
|
+
from cysignals.signals cimport sig_on, sig_off
|
|
67
|
+
|
|
68
|
+
from sage.sets.set import Set
|
|
69
|
+
from sage.graphs.graph import Graph
|
|
70
|
+
|
|
71
|
+
cdef extern from "sage_tdlib.cpp":
|
|
72
|
+
int sage_exact_decomposition(vector[unsigned int] &V_G, vector[unsigned int] &E_G, vector[vector[int]] &V_T, vector[unsigned int] &E_T, int lb)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
##############################################################
|
|
76
|
+
# ########## GRAPH/DECOMPOSITION ENCODING/DECODING ###########
|
|
77
|
+
# the following will be used implicitly to do the translation
|
|
78
|
+
# between Sage graph encoding and BGL graph encoding.
|
|
79
|
+
|
|
80
|
+
cdef make_tdlib_graph(G, vertex_to_int, vector[unsigned int] &V, vector[unsigned int] &E) noexcept:
|
|
81
|
+
for i in range(G.order()):
|
|
82
|
+
V.push_back(i)
|
|
83
|
+
|
|
84
|
+
for u, v in G.edge_iterator(labels=False):
|
|
85
|
+
E.push_back(vertex_to_int[u])
|
|
86
|
+
E.push_back(vertex_to_int[v])
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
cdef make_sage_decomp(G, vector[vector[int]] &V, vector[unsigned int] &E, int_to_vertex) noexcept:
|
|
90
|
+
cdef int i, j
|
|
91
|
+
for i in range(len(V)):
|
|
92
|
+
G.add_vertex(Set([int_to_vertex[j] for j in V[i]]))
|
|
93
|
+
|
|
94
|
+
for i in range(0, len(E), 2):
|
|
95
|
+
G.add_edge(Set([int_to_vertex[j] for j in V[E[i]]]), Set([int_to_vertex[j] for j in V[E[i+1]]]))
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
##############################################################
|
|
99
|
+
# ########## EXACT ALGORITHMS ################################
|
|
100
|
+
|
|
101
|
+
def treedecomposition_exact(G, lb=-1):
|
|
102
|
+
r"""
|
|
103
|
+
Compute a tree decomposition of exact width.
|
|
104
|
+
|
|
105
|
+
The returned tree decomposition is exact iff the given lower bound is not
|
|
106
|
+
greater than the treewidth of the input graph. Otherwise a tree
|
|
107
|
+
decomposition of a width than matches the given lower bound will be
|
|
108
|
+
computed.
|
|
109
|
+
|
|
110
|
+
INPUT:
|
|
111
|
+
|
|
112
|
+
- ``G`` -- a generic graph
|
|
113
|
+
|
|
114
|
+
- ``lb`` -- integer (default: -1); a lower bound to the treewidth of G,
|
|
115
|
+
e.g. computed by lower_bound
|
|
116
|
+
|
|
117
|
+
OUTPUT:
|
|
118
|
+
|
|
119
|
+
A tree decomposition of ``G`` of ``tw(G)``, if the lower bound was not
|
|
120
|
+
greater than ``tw(G)``, otherwise a tree decomposition of ``width = lb``.
|
|
121
|
+
|
|
122
|
+
.. WARNING::
|
|
123
|
+
|
|
124
|
+
The computation can take a lot of time for a graph `G` on more than
|
|
125
|
+
about 30 vertices and `tw(G) > 3`.
|
|
126
|
+
|
|
127
|
+
EXAMPLES::
|
|
128
|
+
|
|
129
|
+
sage: # optional - tdlib
|
|
130
|
+
sage: import sage.graphs.graph_decompositions.tdlib as tdlib
|
|
131
|
+
sage: G = graphs.HouseGraph()
|
|
132
|
+
sage: T = tdlib.treedecomposition_exact(G)
|
|
133
|
+
sage: T.show(vertex_size=2000) # needs sage.plot
|
|
134
|
+
|
|
135
|
+
TESTS::
|
|
136
|
+
|
|
137
|
+
sage: # optional - tdlib
|
|
138
|
+
sage: import sage.graphs.graph_decompositions.tdlib as tdlib
|
|
139
|
+
sage: G = graphs.HouseGraph()
|
|
140
|
+
sage: T = tdlib.treedecomposition_exact(G)
|
|
141
|
+
sage: G = graphs.PetersenGraph()
|
|
142
|
+
sage: T = tdlib.treedecomposition_exact(G)
|
|
143
|
+
"""
|
|
144
|
+
cdef vector[unsigned int] V_G, E_G, E_T
|
|
145
|
+
cdef vector[vector[int]] V_T
|
|
146
|
+
|
|
147
|
+
cdef list int_to_vertex = list(G)
|
|
148
|
+
cdef dict vertex_to_int = {v: i for i, v in enumerate(G)}
|
|
149
|
+
|
|
150
|
+
make_tdlib_graph(G, vertex_to_int, V_G, E_G)
|
|
151
|
+
|
|
152
|
+
cdef int c_lb = lb
|
|
153
|
+
|
|
154
|
+
sig_on()
|
|
155
|
+
sage_exact_decomposition(V_G, E_G, V_T, E_T, c_lb)
|
|
156
|
+
sig_off()
|
|
157
|
+
|
|
158
|
+
T = Graph(name="Tree decomposition")
|
|
159
|
+
make_sage_decomp(T, V_T, E_T, int_to_vertex)
|
|
160
|
+
|
|
161
|
+
return T
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def get_width(T):
|
|
165
|
+
"""
|
|
166
|
+
Return the width of a given tree decomposition.
|
|
167
|
+
|
|
168
|
+
The width of a tree decompositions is the maximal size of a bag minus one.
|
|
169
|
+
|
|
170
|
+
INPUT:
|
|
171
|
+
|
|
172
|
+
- ``T`` -- a tree decomposition
|
|
173
|
+
|
|
174
|
+
OUTPUT: the width of ``T``
|
|
175
|
+
|
|
176
|
+
EXAMPLES::
|
|
177
|
+
|
|
178
|
+
sage: # optional - tdlib
|
|
179
|
+
sage: import sage.graphs.graph_decompositions.tdlib as tdlib
|
|
180
|
+
sage: G = graphs.PetersenGraph()
|
|
181
|
+
sage: T = tdlib.treedecomposition_exact(G)
|
|
182
|
+
sage: tdlib.get_width(T)
|
|
183
|
+
4
|
|
184
|
+
"""
|
|
185
|
+
return (max(len(x) for x in T) - 1) if T else -1
|