pd-code-delete-nugatory 0.0.2__tar.gz → 0.1.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pd-code-delete-nugatory
3
- Version: 0.0.2
3
+ Version: 0.1.1
4
4
  Summary: delete all nugatory crossing from a pd_code (link or knot).
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -29,7 +29,7 @@ def dfs_1(node, nxt:dict[Any, set], vis:set):
29
29
  if node in vis:
30
30
  return
31
31
  vis.add(node)
32
- for nxt_node in nxt[node]:
32
+ for nxt_node in sorted(nxt[node]):
33
33
  dfs_1(nxt_node, nxt, vis)
34
34
 
35
35
  def graph_cc_cnt(weak_pd_code:list[list]):
@@ -85,18 +85,18 @@ def dfs_2(num, vis:set, nxt:dict, new_num:dict):
85
85
  raise AssertionError()
86
86
 
87
87
  # 遍历所有后继
88
- for nxt_num in nxt[num]:
88
+ for nxt_num in sorted(nxt[num]):
89
89
  if nxt_num not in vis:
90
90
  dfs_2(nxt_num, vis, nxt, new_num)
91
91
 
92
92
  # 从 1 开始重新给所有元素编号
93
93
  def renumber(pd_code:list[list]) -> list[list]:
94
94
  pd_code = json.loads(json.dumps(pd_code))
95
- num_set = set([
95
+ num_set = sorted(set([
96
96
  item
97
97
  for crossing in pd_code
98
98
  for item in crossing
99
- ])
99
+ ]))
100
100
 
101
101
  # 这里不能直接用 get_pre_nxt
102
102
  # 因为 renumber 之前有不连贯的编号
@@ -156,5 +156,5 @@ def erase_all_nugatory(pd_code:list[list]):
156
156
  return pd_code
157
157
 
158
158
  if __name__ == "__main__":
159
- pd_code = [[8, 11, 9, 12], [12, 9, 13, 10], [10, 13, 11, 14], [7, 14, 8, 1], [4, 1, 5, 2], [2, 5, 3, 6], [6, 3, 7, 4]]
159
+ pd_code = [[2, 9, 3, 10], [4, 7, 1, 8], [6, 11, 7, 12], [8, 3, 5, 4], [9, 2, 10, 1], [12, 5, 11, 6]]
160
160
  print(erase_all_nugatory(pd_code))
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pd-code-delete-nugatory"
3
- version = "0.0.2"
3
+ version = "0.1.1"
4
4
  description = "delete all nugatory crossing from a pd_code (link or knot)."
5
5
  authors = [
6
6
  {name = "GGN_2015",email = "neko@jlulug.org"}