cpp-pd-code-simplify-interface 0.1.6__py3-none-any.whl → 0.1.7__py3-none-any.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.
@@ -87,13 +87,6 @@ struct RandomInflationResult {
87
87
  int type_ii_moves = 0;
88
88
  };
89
89
 
90
- struct ReidemeisterSimplificationResult {
91
- PDCode code;
92
- std::size_t crossingless_components = 0;
93
- int type_i_moves = 0;
94
- int type_ii_moves = 0;
95
- };
96
-
97
90
  struct PDSimplificationResult {
98
91
  PDCode code;
99
92
  std::size_t crossingless_components = 0;
@@ -153,10 +146,6 @@ PDCODE_SIMPLIFY_API RandomInflationResult randomly_increase_crossings(
153
146
  const PDCode& code,
154
147
  const RandomInflationOptions& options = RandomInflationOptions{});
155
148
 
156
- PDCODE_SIMPLIFY_API ReidemeisterSimplificationResult simplify_reidemeister_i_ii(
157
- const PDCode& code,
158
- std::size_t known_crossingless_components = 0);
159
-
160
149
  PDCODE_SIMPLIFY_API PDSimplificationResult simplify_pd_code(
161
150
  const PDCode& code,
162
151
  std::size_t known_crossingless_components = 0);
@@ -110,31 +110,6 @@ void replace_label(PDCode& code, int old_label, int new_label) {
110
110
  }
111
111
  }
112
112
 
113
- void erase_crossings(PDCode& code, int first, int second = -1) {
114
- if (second >= 0 && first > second) {
115
- std::swap(first, second);
116
- }
117
- if (second >= 0) {
118
- code.erase(code.begin() + second);
119
- }
120
- code.erase(code.begin() + first);
121
- }
122
-
123
- int label_occurrences_outside(const PDCode& code, int label, const std::set<int>& removed_crossings) {
124
- int count = 0;
125
- for (int crossing_index = 0; crossing_index < static_cast<int>(code.size()); ++crossing_index) {
126
- if (removed_crossings.count(crossing_index) != 0) {
127
- continue;
128
- }
129
- for (int strand = 0; strand < 4; ++strand) {
130
- if (code[crossing_index][strand] == label) {
131
- ++count;
132
- }
133
- }
134
- }
135
- return count;
136
- }
137
-
138
113
  int unique_label_count(const Crossing& crossing) {
139
114
  return static_cast<int>(std::set<int>(crossing.begin(), crossing.end()).size());
140
115
  }
@@ -2040,106 +2015,6 @@ bool apply_reverse_type_ii(PDCode& code, std::mt19937& rng) {
2040
2015
  return false;
2041
2016
  }
2042
2017
 
2043
- bool apply_type_i_simplification(
2044
- PDCode& code,
2045
- std::size_t& crossingless_components,
2046
- int& type_i_moves) {
2047
- for (int crossing_index = 0; crossing_index < static_cast<int>(code.size()); ++crossing_index) {
2048
- const Crossing crossing = code[crossing_index];
2049
- for (int i = 0; i < 4; ++i) {
2050
- if (crossing[i] != crossing[(i + 1) % 4]) {
2051
- continue;
2052
- }
2053
-
2054
- const ComponentAnalysis after_removal =
2055
- analyze_components_after_removing_crossings(
2056
- code, std::vector<int>{crossing_index}, crossingless_components);
2057
- const int keep_label = crossing[(i + 2) % 4];
2058
- const int merge_label = crossing[(i + 3) % 4];
2059
- const std::set<int> removed{crossing_index};
2060
- if (keep_label == merge_label) {
2061
- if (label_occurrences_outside(code, keep_label, removed) != 0) {
2062
- continue;
2063
- }
2064
- } else if (label_occurrences_outside(code, keep_label, removed) != 1 ||
2065
- label_occurrences_outside(code, merge_label, removed) != 1) {
2066
- continue;
2067
- }
2068
-
2069
- crossingless_components = after_removal.crossingless_components;
2070
- erase_crossings(code, crossing_index);
2071
- replace_label(code, merge_label, keep_label);
2072
- ++type_i_moves;
2073
- return true;
2074
- }
2075
- }
2076
- return false;
2077
- }
2078
-
2079
- bool apply_type_ii_simplification(
2080
- PDCode& code,
2081
- std::size_t& crossingless_components,
2082
- int& type_ii_moves) {
2083
- if (code.size() < 2) {
2084
- return false;
2085
- }
2086
-
2087
- const LabelMap labels = build_label_map(code);
2088
- for (int first_crossing = 0; first_crossing < static_cast<int>(code.size()); ++first_crossing) {
2089
- for (int a = 0; a < 4; ++a) {
2090
- const Endpoint first_mate =
2091
- mate_endpoint(code, labels, Endpoint{first_crossing, a});
2092
- const Endpoint second_mate =
2093
- mate_endpoint(code, labels, Endpoint{first_crossing, (a + 1) % 4});
2094
- const int second_crossing = first_mate.crossing;
2095
- if (second_crossing == first_crossing || second_crossing != second_mate.crossing) {
2096
- continue;
2097
- }
2098
-
2099
- const int b = first_mate.strand;
2100
- const int c = second_mate.strand;
2101
- if (positive_mod(b - 1, 4) != c || (a + b) % 2 != 0) {
2102
- continue;
2103
- }
2104
-
2105
- const Crossing first = code[first_crossing];
2106
- const Crossing second = code[second_crossing];
2107
- const int keep_first = first[(a + 2) % 4];
2108
- const int merge_first = second[(b + 2) % 4];
2109
- const int keep_second = first[(a + 3) % 4];
2110
- const int merge_second = second[(b + 1) % 4];
2111
- const std::set<int> boundary_labels{
2112
- keep_first,
2113
- merge_first,
2114
- keep_second,
2115
- merge_second};
2116
- const std::set<int> removed_crossings{first_crossing, second_crossing};
2117
- if (boundary_labels.size() != 4 ||
2118
- label_occurrences_outside(code, keep_first, removed_crossings) != 1 ||
2119
- label_occurrences_outside(code, merge_first, removed_crossings) != 1 ||
2120
- label_occurrences_outside(code, keep_second, removed_crossings) != 1 ||
2121
- label_occurrences_outside(code, merge_second, removed_crossings) != 1) {
2122
- continue;
2123
- }
2124
-
2125
- const ComponentAnalysis after_removal =
2126
- analyze_components_after_removing_crossings(
2127
- code,
2128
- std::vector<int>{first_crossing, second_crossing},
2129
- crossingless_components);
2130
- crossingless_components = after_removal.crossingless_components;
2131
-
2132
- erase_crossings(code, first_crossing, second_crossing);
2133
- replace_label(code, merge_first, keep_first);
2134
- replace_label(code, merge_second, keep_second);
2135
- ++type_ii_moves;
2136
- return true;
2137
- }
2138
- }
2139
-
2140
- return false;
2141
- }
2142
-
2143
2018
  RandomInflationResult randomly_increase_crossings(
2144
2019
  const PDCode& code,
2145
2020
  const RandomInflationOptions& options) {
@@ -2172,28 +2047,6 @@ RandomInflationResult randomly_increase_crossings(
2172
2047
  return result;
2173
2048
  }
2174
2049
 
2175
- ReidemeisterSimplificationResult simplify_reidemeister_i_ii(
2176
- const PDCode& code,
2177
- std::size_t known_crossingless_components) {
2178
- ReidemeisterSimplificationResult result;
2179
- result.code = code;
2180
- result.crossingless_components = known_crossingless_components;
2181
-
2182
- while (true) {
2183
- if (apply_type_i_simplification(
2184
- result.code, result.crossingless_components, result.type_i_moves)) {
2185
- continue;
2186
- }
2187
- if (apply_type_ii_simplification(
2188
- result.code, result.crossingless_components, result.type_ii_moves)) {
2189
- continue;
2190
- }
2191
- break;
2192
- }
2193
-
2194
- return result;
2195
- }
2196
-
2197
2050
  PDSimplificationResult simplify_pd_code(
2198
2051
  const PDCode& code,
2199
2052
  std::size_t known_crossingless_components) {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cpp-pd-code-simplify-interface
3
- Version: 0.1.6
3
+ Version: 0.1.7
4
4
  Summary: Python interface for cpp-pd-code-simplify with runtime C++ compilation.
5
5
  License-Expression: MIT
6
6
  Author: GGN_2015
@@ -2,10 +2,10 @@ cpp_pd_code_simplify_interface/__init__.py,sha256=aaNwD--zgQX13xiU1hpuvgXy8vVTFG
2
2
  cpp_pd_code_simplify_interface/__main__.py,sha256=fdA1QWBe5LNX0fbtaJXa1-dwEhrg_4sS_5UnjaajcMo,80
3
3
  cpp_pd_code_simplify_interface/main.py,sha256=_7dPNfbtUxAC8o9cZOOwicU04zIFIA55nHIzQ_UZunw,20624
4
4
  cpp_pd_code_simplify_interface/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
5
- cpp_pd_code_simplify_interface-0.1.6.dist-info/entry_points.txt,sha256=ThorC4Enxp317TKITsXm9pE0gUp7pt-pP6Dl5mEPUR8,91
6
- cpp_pd_code_simplify_interface-0.1.6.dist-info/METADATA,sha256=4BIBNsSZDVD7xJmcAankGYXazchNjFn6kT-McVlELQM,3275
7
- cpp_pd_code_simplify_interface-0.1.6.dist-info/WHEEL,sha256=eY7nduwzv-ldUxpzbRlxwvC693Hg6PX8bWDjEHjZ_dk,88
8
- cpp_pd_code_simplify_interface/data/include/pdcode_simplify/pdcode_simplify.hpp,sha256=P8XgFxLelCFesArCrKJ_UwqG7LlpoXiegNHLOV-DhG8,5162
5
+ cpp_pd_code_simplify_interface-0.1.7.dist-info/entry_points.txt,sha256=ThorC4Enxp317TKITsXm9pE0gUp7pt-pP6Dl5mEPUR8,91
6
+ cpp_pd_code_simplify_interface-0.1.7.dist-info/METADATA,sha256=oGdPQe0rRiBKXmmsfral9TcvMyEwcbygYrfVamdFW3M,3275
7
+ cpp_pd_code_simplify_interface-0.1.7.dist-info/WHEEL,sha256=eY7nduwzv-ldUxpzbRlxwvC693Hg6PX8bWDjEHjZ_dk,88
8
+ cpp_pd_code_simplify_interface/data/include/pdcode_simplify/pdcode_simplify.hpp,sha256=h5aob9gqRq8Gz2Hs4ePzyoRAXFCIGRBShlRw3TxQ7wQ,4843
9
9
  cpp_pd_code_simplify_interface/data/src/native_interface.cpp,sha256=yXUJ0LHZDqz7WgFTwsq0U9pddH0KFTiOPr5sNyj7o1Y,6549
10
- cpp_pd_code_simplify_interface/data/src/pdcode_simplify.cpp,sha256=ptDTjjSlx_Lq_2snHYWgjnIbr-mGsDG7rqTevuqoSEc,94195
11
- cpp_pd_code_simplify_interface-0.1.6.dist-info/RECORD,,
10
+ cpp_pd_code_simplify_interface/data/src/pdcode_simplify.cpp,sha256=hXBEDQQC3C2KlHlKTbmuKqC3l48XF5p76iODfMqolWQ,88691
11
+ cpp_pd_code_simplify_interface-0.1.7.dist-info/RECORD,,