polytope-graph 0.0.1__tar.gz
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.
- polytope_graph-0.0.1/PKG-INFO +242 -0
- polytope_graph-0.0.1/README.md +221 -0
- polytope_graph-0.0.1/VERSION +1 -0
- polytope_graph-0.0.1/polytope_graph/__init__.py +7 -0
- polytope_graph-0.0.1/polytope_graph/polytope_graph.py +998 -0
- polytope_graph-0.0.1/polytope_graph/rauzy.py +291 -0
- polytope_graph-0.0.1/polytope_graph.egg-info/PKG-INFO +242 -0
- polytope_graph-0.0.1/polytope_graph.egg-info/SOURCES.txt +12 -0
- polytope_graph-0.0.1/polytope_graph.egg-info/dependency_links.txt +1 -0
- polytope_graph-0.0.1/polytope_graph.egg-info/requires.txt +1 -0
- polytope_graph-0.0.1/polytope_graph.egg-info/top_level.txt +1 -0
- polytope_graph-0.0.1/requirements.txt +1 -0
- polytope_graph-0.0.1/setup.cfg +4 -0
- polytope_graph-0.0.1/setup.py +71 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: polytope_graph
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Polytope graphs in Sagemath
|
|
5
|
+
Home-page: https://gitlab.com/davidsiukaev/polytopegraphs-in-sagemath
|
|
6
|
+
Author: Paul Mercat and David Siukaev
|
|
7
|
+
Author-email: paul.mercat@univ-amu.fr
|
|
8
|
+
License: GPL-3.0-or-later
|
|
9
|
+
Keywords: Polytope graphs in SageMath
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
Requires-Dist: badic>=0.1.2
|
|
12
|
+
Dynamic: author
|
|
13
|
+
Dynamic: author-email
|
|
14
|
+
Dynamic: description
|
|
15
|
+
Dynamic: description-content-type
|
|
16
|
+
Dynamic: home-page
|
|
17
|
+
Dynamic: keywords
|
|
18
|
+
Dynamic: license
|
|
19
|
+
Dynamic: requires-dist
|
|
20
|
+
Dynamic: summary
|
|
21
|
+
|
|
22
|
+
# PolytopeGraphs in SageMath
|
|
23
|
+
|
|
24
|
+
This package allows to represent multi-dimensional continued fraction algorithms as polytopes graphs.
|
|
25
|
+
It implements the Coulbois's and Fougeron's criterion to determine if there exists a unique ergodic invariant measure absolutely continuous with respect to Lebesgue.
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
You will need to install first [Sagemath](https://www.sagemath.org/).
|
|
30
|
+
Then, you can install the polytope_graph package:
|
|
31
|
+
```
|
|
32
|
+
$ sage -pip install git+https://gitlab.com/davidsiukaev/polytopegraphs-in-sagemath.git
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
It can take a long time to compile since this package need first to install the [badic package](https://gitlab.com/mercatp/badic).
|
|
36
|
+
It should be installed automatically with the previous command line.
|
|
37
|
+
|
|
38
|
+
## Examples
|
|
39
|
+
|
|
40
|
+
### Ergodic example
|
|
41
|
+
|
|
42
|
+
Define and plot a polytope graph:
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
sage: from polytope_graph import *
|
|
46
|
+
sage: m1 = matrix([[1,0,1],[0,1,1],[0,0,1]]).transpose()
|
|
47
|
+
sage: m2 = matrix([[1,0,0],[0,1,0],[0,0,1]]).transpose()
|
|
48
|
+
sage: m3 = matrix([[1,0,0],[0,1,0],[1,0,1]]).transpose()
|
|
49
|
+
sage: m4 = matrix([[1,0,1],[0,1,0],[0,1,1]]).transpose()
|
|
50
|
+
sage: m5 = matrix([[0,0,1],[1,0,0],[0,1,0]]).transpose()
|
|
51
|
+
sage: m6 = matrix([[1,1,0],[0,1,0],[0,1,1]]).transpose()
|
|
52
|
+
sage: s1_mat = matrix([[1,0,0],[0,1,0],[0,0,1]])
|
|
53
|
+
sage: s2_mat = matrix([[1,0,0,1],[0,1,1,0],[0,0,1,1]])
|
|
54
|
+
sage: b = PolytopeGraph([s1_mat, s2_mat, s1_mat], [(0,0,m1),(0,1,m2),(1,0,m3),(1,2,m4),(2,1,m5),(2,2,m6)])
|
|
55
|
+
sage: b.plot()
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+

|
|
59
|
+
|
|
60
|
+
Compute a degenerate subgraph for a face with only one vertex:
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
sage: state = 2 # choose a state
|
|
64
|
+
sage: lf = b.faces(state) # compute list of faces of the polytope of this state
|
|
65
|
+
sage: face = lf[4] # choose one face
|
|
66
|
+
sage: b2 = b.degenerate_subgraph(state, face) # compute the degenerate subgraph for this face of this state
|
|
67
|
+
sage: b2.plot() # plot it
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+

|
|
71
|
+
|
|
72
|
+
Compute another degenerate subgraph for a face of projective dimension 1:
|
|
73
|
+
```
|
|
74
|
+
sage: state = 2
|
|
75
|
+
sage: lf = b.faces(state)
|
|
76
|
+
sage: face = lf[2]
|
|
77
|
+
sage: b2 = b.degenerate_subgraph(state, face)
|
|
78
|
+
sage: b2.plot()
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+

|
|
82
|
+
|
|
83
|
+
Check the Coulbois-Fougeron's criterion:
|
|
84
|
+
```
|
|
85
|
+
sage: b.Fougeron_Coulbois_criterion()
|
|
86
|
+
True
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Non-ergodic example
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
sage: from polytope_graph import *
|
|
93
|
+
sage: m1 = matrix([[1,0,1],[0,1,0],[0,1,1]])
|
|
94
|
+
sage: m2 = matrix([[1,0,0],[0,1,1],[0,0,1]])
|
|
95
|
+
sage: m3 = matrix([[1,0,0],[0,1,0],[1,1,1]])
|
|
96
|
+
sage: m4 = matrix([[1,0,0],[0,1,0],[0,0,1]])
|
|
97
|
+
sage: s1 = matrix([[1,0,0,1],[0,1,1,0],[0,0,1,1]])
|
|
98
|
+
sage: s2 = matrix([[1,0,0],[0,1,0],[0,0,1]])
|
|
99
|
+
sage: a = PolytopeGraph([s1, s2], [(0,1,m1),(0,1,m2),(1,1,m3),(1,0,m4)])
|
|
100
|
+
sage: a.plot()
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+

|
|
104
|
+
|
|
105
|
+
Check the Coulbois-Fougeron's criterion:
|
|
106
|
+
```
|
|
107
|
+
sage: a.Fougeron_Coulbois_criterion(verb = 1)
|
|
108
|
+
The criterion fails for the state 0 and the face:
|
|
109
|
+
[1]
|
|
110
|
+
[0]
|
|
111
|
+
[0]
|
|
112
|
+
False
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
sage: state = 0
|
|
117
|
+
sage: lf = a.faces(state)
|
|
118
|
+
sage: face = lf[6]
|
|
119
|
+
sage: face
|
|
120
|
+
[1]
|
|
121
|
+
[0]
|
|
122
|
+
[0]
|
|
123
|
+
sage: a2 = a.degenerate_subgraph(state, face)
|
|
124
|
+
sage: a2.plot()
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+

|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
sage: a2.Fougeron_Coulbois_criterion_for_subgraph(verb=2)
|
|
131
|
+
[0, 1]
|
|
132
|
+
several outgoing edges from state 0
|
|
133
|
+
check inequality An inequality (0, -1, 1) x + 0 >= 0
|
|
134
|
+
check inequality An inequality (1, 0, 0) x + 0 >= 0
|
|
135
|
+
check inequality An inequality (0, 0, 1) x + 0 >= 0
|
|
136
|
+
check inequality An inequality (0, 1, -1) x + 0 >= 0
|
|
137
|
+
State 0 does not satisfies the criterion
|
|
138
|
+
|
|
139
|
+
False
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Another ergodic example, with non non-negative matrices
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
sage: from polytope_graph import *
|
|
146
|
+
sage: s2 = matrix([[1,0,0],[0,1,0],[-1,1,1],[0,0,1]]).transpose()
|
|
147
|
+
sage: s1 = identity_matrix(3)
|
|
148
|
+
sage: m1 = matrix([[1,0,1],[0,1,1],[0,0,1]]).transpose()
|
|
149
|
+
sage: m2 = matrix([[1,0,0],[0,1,0],[1,0,1]]).transpose()
|
|
150
|
+
sage: m3 = matrix([[0,1,0],[-1,1,1],[0,0,1]]).transpose()
|
|
151
|
+
sage: a = PolytopeGraph([s1, s2], [(0,0,m1), (0,1,m2), (1,0,s1), (1,0,m3)])
|
|
152
|
+
sage: a.plot(colors='Set2')
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+

|
|
156
|
+
|
|
157
|
+
Iterations of the partition on each state:
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
sage: a.plot_state_partition2(1, 12)
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+

|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
sage: a.plot_state_partition2(0, 12)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+

|
|
170
|
+
|
|
171
|
+
```
|
|
172
|
+
sage: s1 = identity_matrix(3)
|
|
173
|
+
sage: s2 = matrix([[1,0,0],[0,1,0],[0,1,1],[1,0,1]]).transpose()
|
|
174
|
+
sage: m1 = matrix([[0,0,1],[1,0,1],[0,1,1]]).transpose()
|
|
175
|
+
sage: m2 = matrix([[1,0,0],[1,1,0],[1,0,1]]).transpose()
|
|
176
|
+
sage: m3 = matrix([[1,1,0],[0,1,0],[0,1,1]]).transpose()
|
|
177
|
+
sage: m4 = matrix([[1,1,0],[0,1,1],[1,0,1]]).transpose()
|
|
178
|
+
sage: a = PolytopeGraph([s1, s2], [(0,0,m1), (0,1,s1), (1,0,m2), (1,0,m3), (1,0,m4)])
|
|
179
|
+
sage: a.plot_state_partition2(0, 13)
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+

|
|
183
|
+
|
|
184
|
+
### Change color, dark mode
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
sage: from polytope_graph import *
|
|
188
|
+
sage: set_dark_mode(2) # transparent mode (set to 1 for dark mode, 0 for light mode)
|
|
189
|
+
sage: m1 = matrix([[1,0,1],[0,1,1],[0,0,1]]).transpose()
|
|
190
|
+
sage: m2 = matrix([[1,0,0],[0,1,0],[0,0,1]]).transpose()
|
|
191
|
+
sage: m3 = matrix([[1,0,0],[0,1,0],[1,0,1]]).transpose()
|
|
192
|
+
sage: m4 = matrix([[1,0,1],[0,1,0],[0,1,1]]).transpose()
|
|
193
|
+
sage: m5 = matrix([[0,0,1],[1,0,0],[0,1,0]]).transpose()
|
|
194
|
+
sage: m6 = matrix([[1,1,0],[0,1,0],[0,1,1]]).transpose()
|
|
195
|
+
sage: s1_mat = matrix([[1,0,0],[0,1,0],[0,0,1]])
|
|
196
|
+
sage: s2_mat = matrix([[1,0,0,1],[0,1,1,0],[0,0,1,1]])
|
|
197
|
+
sage: b = PolytopeGraph([s1_mat, s2_mat, s1_mat], [(0,0,m1),(0,1,m2),(1,0,m3),(1,2,m4),(2,1,m5),(2,2,m6)])
|
|
198
|
+
sage: b.plot(colors='Set2') # choose a color map
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+

|
|
202
|
+
|
|
203
|
+
### Convert win-lose or matrices graphs to PolytopeGraph
|
|
204
|
+
|
|
205
|
+
```
|
|
206
|
+
sage: from polytope_graph import *
|
|
207
|
+
sage: a = PolytopeGraph(dag.CassaigneWinLose())
|
|
208
|
+
sage: a.plot()
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+

|
|
212
|
+
|
|
213
|
+
### Compute the dual algorithm
|
|
214
|
+
|
|
215
|
+
```
|
|
216
|
+
sage: ad = a.dual()
|
|
217
|
+
sage: ad.plot()
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+

|
|
221
|
+
|
|
222
|
+
### Convert a general algo to PolytopeGraph
|
|
223
|
+
|
|
224
|
+
```
|
|
225
|
+
sage: from polytope_graph import *
|
|
226
|
+
sage: a = dag.JacobiPerron()
|
|
227
|
+
sage: a = PolytopeGraph(a)
|
|
228
|
+
sage: a.plot()
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+

|
|
232
|
+
|
|
233
|
+
The graph is not strongly connected, so we need to restrict to a strongly connected component:
|
|
234
|
+
|
|
235
|
+
```
|
|
236
|
+
sage: c = a.strongly_connected_components()[0] # choose the main strongly connected component
|
|
237
|
+
sage: a = a.subgraph(c) # take the subgraph
|
|
238
|
+
sage: a.plot()
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+

|
|
242
|
+
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
# PolytopeGraphs in SageMath
|
|
2
|
+
|
|
3
|
+
This package allows to represent multi-dimensional continued fraction algorithms as polytopes graphs.
|
|
4
|
+
It implements the Coulbois's and Fougeron's criterion to determine if there exists a unique ergodic invariant measure absolutely continuous with respect to Lebesgue.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
You will need to install first [Sagemath](https://www.sagemath.org/).
|
|
9
|
+
Then, you can install the polytope_graph package:
|
|
10
|
+
```
|
|
11
|
+
$ sage -pip install git+https://gitlab.com/davidsiukaev/polytopegraphs-in-sagemath.git
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
It can take a long time to compile since this package need first to install the [badic package](https://gitlab.com/mercatp/badic).
|
|
15
|
+
It should be installed automatically with the previous command line.
|
|
16
|
+
|
|
17
|
+
## Examples
|
|
18
|
+
|
|
19
|
+
### Ergodic example
|
|
20
|
+
|
|
21
|
+
Define and plot a polytope graph:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
sage: from polytope_graph import *
|
|
25
|
+
sage: m1 = matrix([[1,0,1],[0,1,1],[0,0,1]]).transpose()
|
|
26
|
+
sage: m2 = matrix([[1,0,0],[0,1,0],[0,0,1]]).transpose()
|
|
27
|
+
sage: m3 = matrix([[1,0,0],[0,1,0],[1,0,1]]).transpose()
|
|
28
|
+
sage: m4 = matrix([[1,0,1],[0,1,0],[0,1,1]]).transpose()
|
|
29
|
+
sage: m5 = matrix([[0,0,1],[1,0,0],[0,1,0]]).transpose()
|
|
30
|
+
sage: m6 = matrix([[1,1,0],[0,1,0],[0,1,1]]).transpose()
|
|
31
|
+
sage: s1_mat = matrix([[1,0,0],[0,1,0],[0,0,1]])
|
|
32
|
+
sage: s2_mat = matrix([[1,0,0,1],[0,1,1,0],[0,0,1,1]])
|
|
33
|
+
sage: b = PolytopeGraph([s1_mat, s2_mat, s1_mat], [(0,0,m1),(0,1,m2),(1,0,m3),(1,2,m4),(2,1,m5),(2,2,m6)])
|
|
34
|
+
sage: b.plot()
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+

|
|
38
|
+
|
|
39
|
+
Compute a degenerate subgraph for a face with only one vertex:
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
sage: state = 2 # choose a state
|
|
43
|
+
sage: lf = b.faces(state) # compute list of faces of the polytope of this state
|
|
44
|
+
sage: face = lf[4] # choose one face
|
|
45
|
+
sage: b2 = b.degenerate_subgraph(state, face) # compute the degenerate subgraph for this face of this state
|
|
46
|
+
sage: b2.plot() # plot it
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+

|
|
50
|
+
|
|
51
|
+
Compute another degenerate subgraph for a face of projective dimension 1:
|
|
52
|
+
```
|
|
53
|
+
sage: state = 2
|
|
54
|
+
sage: lf = b.faces(state)
|
|
55
|
+
sage: face = lf[2]
|
|
56
|
+
sage: b2 = b.degenerate_subgraph(state, face)
|
|
57
|
+
sage: b2.plot()
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+

|
|
61
|
+
|
|
62
|
+
Check the Coulbois-Fougeron's criterion:
|
|
63
|
+
```
|
|
64
|
+
sage: b.Fougeron_Coulbois_criterion()
|
|
65
|
+
True
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Non-ergodic example
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
sage: from polytope_graph import *
|
|
72
|
+
sage: m1 = matrix([[1,0,1],[0,1,0],[0,1,1]])
|
|
73
|
+
sage: m2 = matrix([[1,0,0],[0,1,1],[0,0,1]])
|
|
74
|
+
sage: m3 = matrix([[1,0,0],[0,1,0],[1,1,1]])
|
|
75
|
+
sage: m4 = matrix([[1,0,0],[0,1,0],[0,0,1]])
|
|
76
|
+
sage: s1 = matrix([[1,0,0,1],[0,1,1,0],[0,0,1,1]])
|
|
77
|
+
sage: s2 = matrix([[1,0,0],[0,1,0],[0,0,1]])
|
|
78
|
+
sage: a = PolytopeGraph([s1, s2], [(0,1,m1),(0,1,m2),(1,1,m3),(1,0,m4)])
|
|
79
|
+
sage: a.plot()
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+

|
|
83
|
+
|
|
84
|
+
Check the Coulbois-Fougeron's criterion:
|
|
85
|
+
```
|
|
86
|
+
sage: a.Fougeron_Coulbois_criterion(verb = 1)
|
|
87
|
+
The criterion fails for the state 0 and the face:
|
|
88
|
+
[1]
|
|
89
|
+
[0]
|
|
90
|
+
[0]
|
|
91
|
+
False
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
sage: state = 0
|
|
96
|
+
sage: lf = a.faces(state)
|
|
97
|
+
sage: face = lf[6]
|
|
98
|
+
sage: face
|
|
99
|
+
[1]
|
|
100
|
+
[0]
|
|
101
|
+
[0]
|
|
102
|
+
sage: a2 = a.degenerate_subgraph(state, face)
|
|
103
|
+
sage: a2.plot()
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+

|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
sage: a2.Fougeron_Coulbois_criterion_for_subgraph(verb=2)
|
|
110
|
+
[0, 1]
|
|
111
|
+
several outgoing edges from state 0
|
|
112
|
+
check inequality An inequality (0, -1, 1) x + 0 >= 0
|
|
113
|
+
check inequality An inequality (1, 0, 0) x + 0 >= 0
|
|
114
|
+
check inequality An inequality (0, 0, 1) x + 0 >= 0
|
|
115
|
+
check inequality An inequality (0, 1, -1) x + 0 >= 0
|
|
116
|
+
State 0 does not satisfies the criterion
|
|
117
|
+
|
|
118
|
+
False
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Another ergodic example, with non non-negative matrices
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
sage: from polytope_graph import *
|
|
125
|
+
sage: s2 = matrix([[1,0,0],[0,1,0],[-1,1,1],[0,0,1]]).transpose()
|
|
126
|
+
sage: s1 = identity_matrix(3)
|
|
127
|
+
sage: m1 = matrix([[1,0,1],[0,1,1],[0,0,1]]).transpose()
|
|
128
|
+
sage: m2 = matrix([[1,0,0],[0,1,0],[1,0,1]]).transpose()
|
|
129
|
+
sage: m3 = matrix([[0,1,0],[-1,1,1],[0,0,1]]).transpose()
|
|
130
|
+
sage: a = PolytopeGraph([s1, s2], [(0,0,m1), (0,1,m2), (1,0,s1), (1,0,m3)])
|
|
131
|
+
sage: a.plot(colors='Set2')
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+

|
|
135
|
+
|
|
136
|
+
Iterations of the partition on each state:
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
sage: a.plot_state_partition2(1, 12)
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+

|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
sage: a.plot_state_partition2(0, 12)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+

|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
sage: s1 = identity_matrix(3)
|
|
152
|
+
sage: s2 = matrix([[1,0,0],[0,1,0],[0,1,1],[1,0,1]]).transpose()
|
|
153
|
+
sage: m1 = matrix([[0,0,1],[1,0,1],[0,1,1]]).transpose()
|
|
154
|
+
sage: m2 = matrix([[1,0,0],[1,1,0],[1,0,1]]).transpose()
|
|
155
|
+
sage: m3 = matrix([[1,1,0],[0,1,0],[0,1,1]]).transpose()
|
|
156
|
+
sage: m4 = matrix([[1,1,0],[0,1,1],[1,0,1]]).transpose()
|
|
157
|
+
sage: a = PolytopeGraph([s1, s2], [(0,0,m1), (0,1,s1), (1,0,m2), (1,0,m3), (1,0,m4)])
|
|
158
|
+
sage: a.plot_state_partition2(0, 13)
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+

|
|
162
|
+
|
|
163
|
+
### Change color, dark mode
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
sage: from polytope_graph import *
|
|
167
|
+
sage: set_dark_mode(2) # transparent mode (set to 1 for dark mode, 0 for light mode)
|
|
168
|
+
sage: m1 = matrix([[1,0,1],[0,1,1],[0,0,1]]).transpose()
|
|
169
|
+
sage: m2 = matrix([[1,0,0],[0,1,0],[0,0,1]]).transpose()
|
|
170
|
+
sage: m3 = matrix([[1,0,0],[0,1,0],[1,0,1]]).transpose()
|
|
171
|
+
sage: m4 = matrix([[1,0,1],[0,1,0],[0,1,1]]).transpose()
|
|
172
|
+
sage: m5 = matrix([[0,0,1],[1,0,0],[0,1,0]]).transpose()
|
|
173
|
+
sage: m6 = matrix([[1,1,0],[0,1,0],[0,1,1]]).transpose()
|
|
174
|
+
sage: s1_mat = matrix([[1,0,0],[0,1,0],[0,0,1]])
|
|
175
|
+
sage: s2_mat = matrix([[1,0,0,1],[0,1,1,0],[0,0,1,1]])
|
|
176
|
+
sage: b = PolytopeGraph([s1_mat, s2_mat, s1_mat], [(0,0,m1),(0,1,m2),(1,0,m3),(1,2,m4),(2,1,m5),(2,2,m6)])
|
|
177
|
+
sage: b.plot(colors='Set2') # choose a color map
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+

|
|
181
|
+
|
|
182
|
+
### Convert win-lose or matrices graphs to PolytopeGraph
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
sage: from polytope_graph import *
|
|
186
|
+
sage: a = PolytopeGraph(dag.CassaigneWinLose())
|
|
187
|
+
sage: a.plot()
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+

|
|
191
|
+
|
|
192
|
+
### Compute the dual algorithm
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
sage: ad = a.dual()
|
|
196
|
+
sage: ad.plot()
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+

|
|
200
|
+
|
|
201
|
+
### Convert a general algo to PolytopeGraph
|
|
202
|
+
|
|
203
|
+
```
|
|
204
|
+
sage: from polytope_graph import *
|
|
205
|
+
sage: a = dag.JacobiPerron()
|
|
206
|
+
sage: a = PolytopeGraph(a)
|
|
207
|
+
sage: a.plot()
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+

|
|
211
|
+
|
|
212
|
+
The graph is not strongly connected, so we need to restrict to a strongly connected component:
|
|
213
|
+
|
|
214
|
+
```
|
|
215
|
+
sage: c = a.strongly_connected_components()[0] # choose the main strongly connected component
|
|
216
|
+
sage: a = a.subgraph(c) # take the subgraph
|
|
217
|
+
sage: a.plot()
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+

|
|
221
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.0.1
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
from sage.misc.lazy_import import lazy_import
|
|
2
|
+
from badic import *
|
|
3
|
+
|
|
4
|
+
lazy_import('polytope_graph.polytope_graph', ['PolytopeGraph'])
|
|
5
|
+
|
|
6
|
+
lazy_import('polytope_graph.rauzy', ['rauzy_graph', 'rauzy_graphs', 'rauzy_polytope_graph2', 'rauzy_polytope_graph', 'rauzy_to_polytope_graph2', 'rauzy_to_polytope_graph'])
|
|
7
|
+
|