GroupsMath 0.7.1__tar.gz → 1.0.0__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: GroupsMath
3
- Version: 0.7.1
3
+ Version: 1.0.0
4
4
  Summary: The educational Python library for Group Theory
5
5
  Author-email: Mario Sultan Romero <mariosultan.uem@gmail.com>
6
6
  License: PolyForm Strict License 1.0.0.
@@ -20,37 +20,36 @@ Requires-Dist: matplotlib>=3.0.0
20
20
  Requires-Dist: numpy>=1.20.0
21
21
  Dynamic: license-file
22
22
 
23
- # GroupsMath – v0.7.1 – release candidate for v1.0.0
23
+ # GroupsMath – v1.0.0
24
24
 
25
25
  [![PyPI Downloads](https://img.shields.io/pypi/dm/groupsmath)](https://pypistats.org/packages/groupsmath)
26
26
  [![PyPI Version](https://img.shields.io/pypi/v/groupsmath?color=2A646E)](https://pypi.org/project/groupsmath/)
27
27
  [![Python Versions](https://img.shields.io/pypi/pyversions/groupsmath?color=2A646E)](https://pypi.org/project/groupsmath/)
28
28
  ![Last Commit](https://img.shields.io/github/last-commit/MarioSultan/groupsmath?color=2A646E)
29
- ![coverage](https://img.shields.io/badge/road%20to%20v1.0.0-95%25-yellowgreen?color=2A646E)
30
29
  <!-- ![GitHub Stars](https://img.shields.io/github/stars/MarioSultan/groupsmath?style=social) -->
31
30
 
32
31
 
33
32
  ![GroupsMath Logo](https://raw.githubusercontent.com/MarioSultan/GroupsMath/main/logo.png)
34
33
 
35
34
 
36
- **GroupsMath** is a Python module for constructing, studying, and manipulating finite and infinite groups.
35
+ **GroupsMath** is an open-source Python library for exploring and computing with mathematical groups. It lets you construct groups, perform operations on their elements, and study their structure through concepts such as subgroups, quotient groups, products, automorphisms, and conjugacy classes. Its goal is to make group theory **accessible, intuitive, and computational**, connecting abstract mathematics with hands-on experimentation in Python.
37
36
 
38
- The project aims to provide a **simple** and **intuitive** interface for working with groups and their algebraic properties.
39
37
 
40
38
  ![Examples](https://raw.githubusercontent.com/MarioSultan/GroupsMath/main/imgs/examples.png)
41
39
 
42
- [![Launch Binder](https://raw.githubusercontent.com/MarioSultan/GroupsMath/main/imgs/here.png)](https://mybinder.org/v2/gh/MarioSultan/GroupsMath/main?labpath=GroupsMath_demo.ipynb)
43
40
 
44
- > Visit here the [GroupsMath official documentation](https://groupsmath.readthedocs.io/en/latest/).
41
+ 📚 Visit here the [GroupsMath official documentation](https://groupsmath.readthedocs.io/en/latest/).
42
+
45
43
 
46
- > **⚠️ Notice:** Version v1.0.0 is nearing its official release.
44
+ ---
47
45
 
46
+ [![Launch Binder](https://raw.githubusercontent.com/MarioSultan/GroupsMath/main/imgs/here.png)](https://mybinder.org/v2/gh/MarioSultan/GroupsMath/main?labpath=GroupsMath_demo.ipynb)
48
47
 
49
48
  ---
50
49
 
51
50
  ## Installation
52
51
 
53
- GroupsMath is currently distributed through [PyPI](https://pypi.org/project/GroupsMath/) and [Github](https://github.com/MarioSultan/GroupsMath). To install the latest released version from PyPI, run:
52
+ GroupsMath is currently distributed through [PyPI](https://pypi.org/project/GroupsMath/) and [Github](https://github.com/MarioSultan/GroupsMath). To install the latest released version from PyPI, run the following in your preferred terminal (VS code, Jupyter, ...).
54
53
 
55
54
  ```bash
56
55
  pip install groupsmath
@@ -115,7 +114,7 @@ GroupsMath is designed to provide tools for working with finite (and infinite) g
115
114
  **GROUPS:**
116
115
  * Construction of finite groups with classes `CayleyGroup` and `ExplicitGroup`.
117
116
  * Determination of the order of a group and its elements.
118
- * Operation with group elements (multiplication, inverse, powers, ...)
117
+ * Operation with group elements (multiplication, inverse, powers, ...).
119
118
  * Computation of Cayley tables with `matplotlib.pyplot`.
120
119
  * Detection of algebraic properties such as cyclicity, commutativity and solubility.
121
120
  * Centralizers, conjugacy classes and conmutator.
@@ -128,7 +127,8 @@ GroupsMath is designed to provide tools for working with finite (and infinite) g
128
127
  * Normal subgroups.
129
128
  * Quotient groups $Q=G/H$.
130
129
  * Conmutator and derived subgroups $G'$.
131
- * Abelianization $G/G'$
130
+ * Abelianization $G/G'$.
131
+ * Hasse diagrams. (*experimental feature*)
132
132
 
133
133
  **AUTOMORPHISMS:**
134
134
  * Class `Automorphism` and automorphism functions.
@@ -147,6 +147,10 @@ GroupsMath is designed to provide tools for working with finite (and infinite) g
147
147
  **PRESENTED GROUPS**
148
148
  * Presentation of groups, generators and class `PresentedGroup`. (*experimental feature*)
149
149
 
150
+ **EDUCATION**
151
+ * Jupyter notebook [A swift introduction to group theory with *GroupsMath*](https://mybinder.org/v2/gh/MarioSultan/GroupsMath/main?labpath=GroupsMath_demo.ipynb) in Binder.
152
+
153
+
150
154
  The available functionality will expand as the project develops.
151
155
 
152
156
  ---
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: GroupsMath
3
- Version: 0.7.1
3
+ Version: 1.0.0
4
4
  Summary: The educational Python library for Group Theory
5
5
  Author-email: Mario Sultan Romero <mariosultan.uem@gmail.com>
6
6
  License: PolyForm Strict License 1.0.0.
@@ -20,37 +20,36 @@ Requires-Dist: matplotlib>=3.0.0
20
20
  Requires-Dist: numpy>=1.20.0
21
21
  Dynamic: license-file
22
22
 
23
- # GroupsMath – v0.7.1 – release candidate for v1.0.0
23
+ # GroupsMath – v1.0.0
24
24
 
25
25
  [![PyPI Downloads](https://img.shields.io/pypi/dm/groupsmath)](https://pypistats.org/packages/groupsmath)
26
26
  [![PyPI Version](https://img.shields.io/pypi/v/groupsmath?color=2A646E)](https://pypi.org/project/groupsmath/)
27
27
  [![Python Versions](https://img.shields.io/pypi/pyversions/groupsmath?color=2A646E)](https://pypi.org/project/groupsmath/)
28
28
  ![Last Commit](https://img.shields.io/github/last-commit/MarioSultan/groupsmath?color=2A646E)
29
- ![coverage](https://img.shields.io/badge/road%20to%20v1.0.0-95%25-yellowgreen?color=2A646E)
30
29
  <!-- ![GitHub Stars](https://img.shields.io/github/stars/MarioSultan/groupsmath?style=social) -->
31
30
 
32
31
 
33
32
  ![GroupsMath Logo](https://raw.githubusercontent.com/MarioSultan/GroupsMath/main/logo.png)
34
33
 
35
34
 
36
- **GroupsMath** is a Python module for constructing, studying, and manipulating finite and infinite groups.
35
+ **GroupsMath** is an open-source Python library for exploring and computing with mathematical groups. It lets you construct groups, perform operations on their elements, and study their structure through concepts such as subgroups, quotient groups, products, automorphisms, and conjugacy classes. Its goal is to make group theory **accessible, intuitive, and computational**, connecting abstract mathematics with hands-on experimentation in Python.
37
36
 
38
- The project aims to provide a **simple** and **intuitive** interface for working with groups and their algebraic properties.
39
37
 
40
38
  ![Examples](https://raw.githubusercontent.com/MarioSultan/GroupsMath/main/imgs/examples.png)
41
39
 
42
- [![Launch Binder](https://raw.githubusercontent.com/MarioSultan/GroupsMath/main/imgs/here.png)](https://mybinder.org/v2/gh/MarioSultan/GroupsMath/main?labpath=GroupsMath_demo.ipynb)
43
40
 
44
- > Visit here the [GroupsMath official documentation](https://groupsmath.readthedocs.io/en/latest/).
41
+ 📚 Visit here the [GroupsMath official documentation](https://groupsmath.readthedocs.io/en/latest/).
42
+
45
43
 
46
- > **⚠️ Notice:** Version v1.0.0 is nearing its official release.
44
+ ---
47
45
 
46
+ [![Launch Binder](https://raw.githubusercontent.com/MarioSultan/GroupsMath/main/imgs/here.png)](https://mybinder.org/v2/gh/MarioSultan/GroupsMath/main?labpath=GroupsMath_demo.ipynb)
48
47
 
49
48
  ---
50
49
 
51
50
  ## Installation
52
51
 
53
- GroupsMath is currently distributed through [PyPI](https://pypi.org/project/GroupsMath/) and [Github](https://github.com/MarioSultan/GroupsMath). To install the latest released version from PyPI, run:
52
+ GroupsMath is currently distributed through [PyPI](https://pypi.org/project/GroupsMath/) and [Github](https://github.com/MarioSultan/GroupsMath). To install the latest released version from PyPI, run the following in your preferred terminal (VS code, Jupyter, ...).
54
53
 
55
54
  ```bash
56
55
  pip install groupsmath
@@ -115,7 +114,7 @@ GroupsMath is designed to provide tools for working with finite (and infinite) g
115
114
  **GROUPS:**
116
115
  * Construction of finite groups with classes `CayleyGroup` and `ExplicitGroup`.
117
116
  * Determination of the order of a group and its elements.
118
- * Operation with group elements (multiplication, inverse, powers, ...)
117
+ * Operation with group elements (multiplication, inverse, powers, ...).
119
118
  * Computation of Cayley tables with `matplotlib.pyplot`.
120
119
  * Detection of algebraic properties such as cyclicity, commutativity and solubility.
121
120
  * Centralizers, conjugacy classes and conmutator.
@@ -128,7 +127,8 @@ GroupsMath is designed to provide tools for working with finite (and infinite) g
128
127
  * Normal subgroups.
129
128
  * Quotient groups $Q=G/H$.
130
129
  * Conmutator and derived subgroups $G'$.
131
- * Abelianization $G/G'$
130
+ * Abelianization $G/G'$.
131
+ * Hasse diagrams. (*experimental feature*)
132
132
 
133
133
  **AUTOMORPHISMS:**
134
134
  * Class `Automorphism` and automorphism functions.
@@ -147,6 +147,10 @@ GroupsMath is designed to provide tools for working with finite (and infinite) g
147
147
  **PRESENTED GROUPS**
148
148
  * Presentation of groups, generators and class `PresentedGroup`. (*experimental feature*)
149
149
 
150
+ **EDUCATION**
151
+ * Jupyter notebook [A swift introduction to group theory with *GroupsMath*](https://mybinder.org/v2/gh/MarioSultan/GroupsMath/main?labpath=GroupsMath_demo.ipynb) in Binder.
152
+
153
+
150
154
  The available functionality will expand as the project develops.
151
155
 
152
156
  ---
@@ -1,34 +1,33 @@
1
- # GroupsMath – v0.7.1 – release candidate for v1.0.0
1
+ # GroupsMath – v1.0.0
2
2
 
3
3
  [![PyPI Downloads](https://img.shields.io/pypi/dm/groupsmath)](https://pypistats.org/packages/groupsmath)
4
4
  [![PyPI Version](https://img.shields.io/pypi/v/groupsmath?color=2A646E)](https://pypi.org/project/groupsmath/)
5
5
  [![Python Versions](https://img.shields.io/pypi/pyversions/groupsmath?color=2A646E)](https://pypi.org/project/groupsmath/)
6
6
  ![Last Commit](https://img.shields.io/github/last-commit/MarioSultan/groupsmath?color=2A646E)
7
- ![coverage](https://img.shields.io/badge/road%20to%20v1.0.0-95%25-yellowgreen?color=2A646E)
8
7
  <!-- ![GitHub Stars](https://img.shields.io/github/stars/MarioSultan/groupsmath?style=social) -->
9
8
 
10
9
 
11
10
  ![GroupsMath Logo](https://raw.githubusercontent.com/MarioSultan/GroupsMath/main/logo.png)
12
11
 
13
12
 
14
- **GroupsMath** is a Python module for constructing, studying, and manipulating finite and infinite groups.
13
+ **GroupsMath** is an open-source Python library for exploring and computing with mathematical groups. It lets you construct groups, perform operations on their elements, and study their structure through concepts such as subgroups, quotient groups, products, automorphisms, and conjugacy classes. Its goal is to make group theory **accessible, intuitive, and computational**, connecting abstract mathematics with hands-on experimentation in Python.
15
14
 
16
- The project aims to provide a **simple** and **intuitive** interface for working with groups and their algebraic properties.
17
15
 
18
16
  ![Examples](https://raw.githubusercontent.com/MarioSultan/GroupsMath/main/imgs/examples.png)
19
17
 
20
- [![Launch Binder](https://raw.githubusercontent.com/MarioSultan/GroupsMath/main/imgs/here.png)](https://mybinder.org/v2/gh/MarioSultan/GroupsMath/main?labpath=GroupsMath_demo.ipynb)
21
18
 
22
- > Visit here the [GroupsMath official documentation](https://groupsmath.readthedocs.io/en/latest/).
19
+ 📚 Visit here the [GroupsMath official documentation](https://groupsmath.readthedocs.io/en/latest/).
20
+
23
21
 
24
- > **⚠️ Notice:** Version v1.0.0 is nearing its official release.
22
+ ---
25
23
 
24
+ [![Launch Binder](https://raw.githubusercontent.com/MarioSultan/GroupsMath/main/imgs/here.png)](https://mybinder.org/v2/gh/MarioSultan/GroupsMath/main?labpath=GroupsMath_demo.ipynb)
26
25
 
27
26
  ---
28
27
 
29
28
  ## Installation
30
29
 
31
- GroupsMath is currently distributed through [PyPI](https://pypi.org/project/GroupsMath/) and [Github](https://github.com/MarioSultan/GroupsMath). To install the latest released version from PyPI, run:
30
+ GroupsMath is currently distributed through [PyPI](https://pypi.org/project/GroupsMath/) and [Github](https://github.com/MarioSultan/GroupsMath). To install the latest released version from PyPI, run the following in your preferred terminal (VS code, Jupyter, ...).
32
31
 
33
32
  ```bash
34
33
  pip install groupsmath
@@ -93,7 +92,7 @@ GroupsMath is designed to provide tools for working with finite (and infinite) g
93
92
  **GROUPS:**
94
93
  * Construction of finite groups with classes `CayleyGroup` and `ExplicitGroup`.
95
94
  * Determination of the order of a group and its elements.
96
- * Operation with group elements (multiplication, inverse, powers, ...)
95
+ * Operation with group elements (multiplication, inverse, powers, ...).
97
96
  * Computation of Cayley tables with `matplotlib.pyplot`.
98
97
  * Detection of algebraic properties such as cyclicity, commutativity and solubility.
99
98
  * Centralizers, conjugacy classes and conmutator.
@@ -106,7 +105,8 @@ GroupsMath is designed to provide tools for working with finite (and infinite) g
106
105
  * Normal subgroups.
107
106
  * Quotient groups $Q=G/H$.
108
107
  * Conmutator and derived subgroups $G'$.
109
- * Abelianization $G/G'$
108
+ * Abelianization $G/G'$.
109
+ * Hasse diagrams. (*experimental feature*)
110
110
 
111
111
  **AUTOMORPHISMS:**
112
112
  * Class `Automorphism` and automorphism functions.
@@ -125,6 +125,10 @@ GroupsMath is designed to provide tools for working with finite (and infinite) g
125
125
  **PRESENTED GROUPS**
126
126
  * Presentation of groups, generators and class `PresentedGroup`. (*experimental feature*)
127
127
 
128
+ **EDUCATION**
129
+ * Jupyter notebook [A swift introduction to group theory with *GroupsMath*](https://mybinder.org/v2/gh/MarioSultan/GroupsMath/main?labpath=GroupsMath_demo.ipynb) in Binder.
130
+
131
+
128
132
  The available functionality will expand as the project develops.
129
133
 
130
134
  ---
@@ -21,7 +21,7 @@ from math import gcd
21
21
 
22
22
  #################### DEFINITIONS ####################
23
23
 
24
- __version__ = "0.7.1"
24
+ __version__ = "1.0.0"
25
25
  __errorcolor__ = "\033[31m"
26
26
 
27
27
  tgl_color = "#2A646E"
@@ -30,6 +30,8 @@ tgl = mcolors.LinearSegmentedColormap.from_list("tgl", ["white", tgl_color])
30
30
  rainbow = mcolors.LinearSegmentedColormap.from_list("rainbow", ["#FF0000","#FF9100","#F2DA00","#2CDB00","#00DAE9","#1869FF"])#,"#7648FF","#D12BFF"])
31
31
  rainbow8 = mcolors.LinearSegmentedColormap.from_list("rainbow8", ["#FF0000","#FF9100","#F2DA00","#2CDB00","#00DAE9","#1869FF","#7648FF","#FF1FF4"])
32
32
 
33
+ standard = ["#FF0000", "#1869FF", "#2CDB00", "#F2DA00", "#7648FF", "#FF9100", "#00DAE9", "#FF1FF4", "#000000", "#888888"]
34
+
33
35
  def groupsmath_info():
34
36
  print("———————————————————————————————————————————————————————————————————————————")
35
37
  print(" ")
@@ -45,7 +47,7 @@ def groupsmath_info():
45
47
  print("· GitHub \033[36mhttps://github.com/MarioSultan/GroupsMath \033[0m ")
46
48
  print(" ")
47
49
  print("The documentation of this library is in the following link: ")
48
- print("· Documentation \033[36mhttps://github.com/MarioSultan/GroupsMath/tree/main/docs \033[0m ")
50
+ print("· Documentation \033[36mhttps://groupsmath.readthedocs.io/en/latest/ \033[0m ")
49
51
  print(" ")
50
52
  print("———————————————————————————————————————————————————————————————————————————")
51
53
 
@@ -181,8 +183,11 @@ class ExplicitGroup(Group):
181
183
  def is_abelian(self):
182
184
  return self.order()==len(self.center())
183
185
 
184
- def cayley_table(self, title="", colormap=rainbow, names=None, math_mode=True):
185
- return self.toCayleyGroup().cayley_table(title=title, colormap=colormap, names=names, math_mode=math_mode)
186
+ def cayley_table(self, **kwargs):
187
+ return self.toCayleyGroup().cayley_table(**kwargs)
188
+
189
+ def cayley_graph(self, **kwargs):
190
+ return self.toCayleyGroup().cayley_graph(**kwargs)
186
191
 
187
192
  #–> SUBGROUPS
188
193
 
@@ -331,6 +336,9 @@ class ExplicitGroup(Group):
331
336
 
332
337
  def is_solvable(self):
333
338
  return len(self.derived_series()[-1]) == 1
339
+
340
+ def hasse_diagram(self):
341
+ self.toCayleyGroup().hasse_diagram()
334
342
 
335
343
  #–> AUTOMORPHISMS
336
344
 
@@ -361,6 +369,9 @@ class ExplicitGroup(Group):
361
369
  sub_indices = _subgroup_generated_by(cayley_grp.cayley, subset_indices)
362
370
  return len(sub_indices) == len(self)
363
371
 
372
+ def rank(self):
373
+ return len(self.generators())
374
+
364
375
  #-> ISOMORPHISMS
365
376
 
366
377
  def is_isomorphic_to(self, target):
@@ -561,6 +572,62 @@ class CayleyGroup(Group):
561
572
  def delete_names(self):
562
573
  self.elements = [i for i in range(len(self.elements))]
563
574
 
575
+ def cayley_graph(self, generators=None, title="", colormap=standard, names=None, edgenames=None, math_mode=True, node_size=1000):
576
+
577
+ import networkx as nx
578
+
579
+ if generators==None:
580
+ generators = self.generators()
581
+ else:
582
+ if not self.generates(generators):
583
+ raise ValueError(__errorcolor__+"The set provided does not generate the group.")
584
+
585
+ if names==None:
586
+ if len(self)<=20:
587
+ names=True
588
+ else:
589
+ names=False
590
+
591
+ if edgenames==None:
592
+ if len(self)<=20:
593
+ edgenames=True
594
+ else:
595
+ edgenames=False
596
+
597
+ gr = nx.DiGraph()
598
+
599
+ if math_mode:
600
+ for i in self.elements:
601
+ gr.add_node("$"+str(i)+"$")
602
+ for i in self.elements:
603
+ for j in range(len(generators)):
604
+ gr.add_edge("$"+str(i)+"$","$"+str(self.operation(i,generators[j]))+"$",label=generators[j], color=colormap[j])
605
+ else:
606
+ for i in self.elements:
607
+ gr.add_node(str(i))
608
+ for i in self.elements:
609
+ for j in range(len(generators)):
610
+ gr.add_edge(str(i),str(self.operation(i,generators[j])),label=generators[j], color=colormap[j])
611
+
612
+
613
+ colors = [gr.edges[u, v]["color"]for u, v in gr.edges]
614
+
615
+ if edgenames:
616
+ edge_labels = nx.get_edge_attributes(gr, "label")
617
+ else:
618
+ edge_labels = []
619
+
620
+ pos = nx.spring_layout(gr)
621
+
622
+ if names:
623
+ nx.draw(gr,pos,with_labels=True, node_color="white", edgecolors="black", edge_color=colors, width=3, node_size=node_size)
624
+ nx.draw_networkx_edge_labels(gr, pos, edge_labels=edge_labels)
625
+ else:
626
+ nx.draw(gr,pos,with_labels=False, node_color="black", edge_color=colors, width=3, node_size=250)
627
+
628
+ plt.title(title)
629
+ plt.show()
630
+
564
631
  #–> SUBGROUPS
565
632
 
566
633
  def proper_subgroups(self):
@@ -706,6 +773,124 @@ class CayleyGroup(Group):
706
773
  def is_solvable(self):
707
774
  return len(self.derived_series()[-1]) == 1
708
775
 
776
+ def hasse_diagram(self):
777
+
778
+ import networkx as nx
779
+ from groupsmath.structure import structure_description
780
+
781
+ S = self.subgroups()
782
+ N = [] # name
783
+ R = [] # ratio
784
+ for i in S:
785
+ N.append(structure_description(i.subgroup))
786
+ R.append(int(len(self)/len(i)))
787
+
788
+ o = []
789
+ i = 0
790
+ while i<len(R):
791
+ if R[i] not in o:
792
+ o.append(R[i])
793
+ i+=1
794
+
795
+ O = {o[i]:i for i in range(len(o))}
796
+
797
+ H = []
798
+ for i in range(len(o)):
799
+ H.append([])
800
+
801
+ for i in range(len(S)):
802
+ H[O[R[i]]].append(S[i])
803
+
804
+ #print(f"N = {N}",f"R = {R}",f"o = {o}",f"O = {O}",f"H = {H}",sep="\n")
805
+
806
+ ########## Nodos y aristas ##########
807
+
808
+ gr = nx.DiGraph()
809
+
810
+ for i in range(len(S)):
811
+ gr.add_node(i,label=structure_description(S[i].subgroup))
812
+
813
+ for i in range(len(S)):
814
+ for j in range(i,len(S)):
815
+ if S[i]._is_covered(S[j]):
816
+ gr.add_edge(i,j)
817
+
818
+ ########## Posiciones ##########
819
+
820
+ pos = {}
821
+
822
+ dx = 2
823
+ dy = 2
824
+ min_distance = dx
825
+
826
+ # 1. Posiciones iniciales, distribuidas uniformemente
827
+ for level, subgroups in enumerate(H):
828
+
829
+ n = len(subgroups)
830
+ offset = -(n - 1) * dx / 2
831
+
832
+ for k, subgroup in enumerate(subgroups):
833
+
834
+ node = S.index(subgroup)
835
+
836
+ pos[node] = (
837
+ offset + k * dx,
838
+ level * dy
839
+ )
840
+
841
+
842
+ # 2. Ajustar cada nodo según sus predecesores
843
+ for level in range(1, len(H)):
844
+
845
+ for subgroup in H[level]:
846
+
847
+ node = S.index(subgroup)
848
+
849
+ predecessors = list(gr.predecessors(node))
850
+
851
+ if not predecessors:
852
+ continue
853
+
854
+ # Posición ideal: media de los predecesores
855
+ ideal_x = np.mean([
856
+ pos[p][0]
857
+ for p in predecessors
858
+ ])
859
+
860
+ y = level * dy
861
+
862
+ # --------------------------------------------------
863
+ # Buscar una posición libre alrededor de ideal_x
864
+ # --------------------------------------------------
865
+
866
+ x = ideal_x
867
+
868
+ occupied = [
869
+ p[0]
870
+ for n, p in pos.items()
871
+ if p[1] == y
872
+ ]
873
+
874
+ # Si está demasiado cerca de otro nodo,
875
+ # desplazamos alternativamente izquierda/derecha.
876
+ k = 0
877
+
878
+ while any(abs(x - ox) < min_distance for ox in occupied):
879
+
880
+ k += 1
881
+
882
+ if k % 2 == 1:
883
+ x = ideal_x + ((k + 1) // 2) * dx
884
+ else:
885
+ x = ideal_x - (k // 2) * dx
886
+
887
+ pos[node] = (x, y)
888
+
889
+ labels = nx.get_node_attributes(gr, "label")
890
+ nx.draw(gr, pos, with_labels=True, labels=labels, node_shape="s", node_color="white", edgecolors="black", node_size=1000, arrows=False)
891
+ #nx.draw_networkx_edges(gr,pos,arrows=False)
892
+ plt.show()
893
+
709
894
  #–> AUTOMORPHISMS
710
895
 
711
896
  def is_automorphism(self, phi):
@@ -837,6 +1022,9 @@ class CayleyGroup(Group):
837
1022
  sub_indices = _subgroup_generated_by(self.cayley, subset_indices)
838
1023
  return len(sub_indices) == self.order()
839
1024
 
1025
+ def rank(self):
1026
+ return len(self.generators())
1027
+
840
1028
  #-> ISOMORPHISMS
841
1029
 
842
1030
  def is_isomorphic_to(self, target): #Revisar, pues es demasiado grande y algo puede salir mal
@@ -955,6 +1143,17 @@ class ExplicitSubgroup(ExplicitGroup, Subgroup):
955
1143
  def __lt__(self, group):
956
1144
  return group == self.group and self.subgroup.order() < self.group.order()
957
1145
 
1146
+ #-> GRAPHS
1147
+
1148
+ def cayley_table(self, **kwargs):
1149
+ return self.subgroup.cayley_table(**kwargs)
1150
+
1151
+ def cayley_graph(self, **kwargs):
1152
+ return self.subgroup.cayley_graph(**kwargs)
1153
+
1154
+ def hasse_diagram(self, **kwargs):
1155
+ return self.subgroup.hasse_diagram(**kwargs)
1156
+
958
1157
  #–> QUOTIENTS & COSETS
959
1158
 
960
1159
  def coset(self, element, side="left", return_names=True):
@@ -1063,6 +1262,40 @@ class CayleySubgroup(CayleyGroup, Subgroup):
1063
1262
  def __lt__(self, group):
1064
1263
  return group==self.group and self.subgroup.order()<self.group.order()
1065
1264
 
1265
+ def _isin(self, subgroup):
1266
+ if not isinstance(subgroup, CayleySubgroup):
1267
+ return False
1268
+
1269
+ return set(self._indices).issubset(set(subgroup._indices))
1270
+
1271
+ def _is_covered(self, other):
1272
+ if not self._isin(other):
1273
+ return False
1274
+
1275
+ if set(self._indices) == set(other._indices):
1276
+ return False
1277
+
1278
+ for intermediate in other.group.subgroups():
1279
+ # Comprobamos que no sea idéntico en contenido a self ni a other
1280
+ if set(intermediate._indices) == set(self._indices) or set(intermediate._indices) == set(other._indices):
1281
+ continue
1282
+
1283
+ if self._isin(intermediate) and intermediate._isin(other):
1284
+ return False
1285
+
1286
+ return True
1287
+
1288
+ #-> GRAPHS
1289
+
1290
+ def cayley_table(self, **kwargs):
1291
+ return self.subgroup.cayley_table(**kwargs)
1292
+
1293
+ def cayley_graph(self, **kwargs):
1294
+ return self.subgroup.cayley_graph(**kwargs)
1295
+
1296
+ def hasse_diagram(self, **kwargs):
1297
+ return self.subgroup.hasse_diagram(**kwargs)
1298
+
1066
1299
  #–> QUOTIENTS
1067
1300
 
1068
1301
  def coset(self, element, side="left", return_names=True):
@@ -1187,6 +1420,9 @@ class Element:
1187
1420
  inv = self.group.inverse(self.element)
1188
1421
  return Element(inv, self.group)
1189
1422
 
1423
+ def order(self):
1424
+ return self.group.element_orders()[self.index]
1425
+
1190
1426
  class Automorphism:
1191
1427
 
1192
1428
  def __init__(self,phi:tuple,group:CayleyGroup):
@@ -1226,12 +1462,6 @@ class AutomorphismFunction:
1226
1462
 
1227
1463
  #################### HIDDEN FUNCTIONS ####################
1228
1464
 
1229
- def _obtener_nombre(var_obj):
1230
- for nombre, valor in globals().items():
1231
- if valor is var_obj:
1232
- return nombre
1233
- return None
1234
-
1235
1465
  def _is_closed(tabla):
1236
1466
  n = len(tabla)
1237
1467
  E = _get_elements(tabla)
@@ -1372,24 +1602,6 @@ def _check_explicit_group(elements: list, operation) -> tuple[bool, str]:
1372
1602
 
1373
1603
  return True, "Valid Group"
1374
1604
 
1375
- def _identity(G):
1376
- neutro = None
1377
- for e in range(len(G)):
1378
- ok = True
1379
- for a in range(len(G)):
1380
- if G[e][a] != a:
1381
- ok = False
1382
- break
1383
- if G[a][e] != a:
1384
- ok = False
1385
- break
1386
- if ok:
1387
- neutro = e
1388
- break
1389
- if neutro is None:
1390
- return (False,"IndentityError – no identity element found")
1391
- return neutro
1392
-
1393
1605
  def _subset(G, elements):
1394
1606
  return [[G[r][c] for c in elements] for r in elements]
1395
1607
 
@@ -1517,24 +1729,6 @@ def _subgroup_generated_by(cayley, generators_indices):
1517
1729
 
1518
1730
  return sorted(list(generated))
1519
1731
 
1520
- def _order_preserving_permutations(orders):
1521
-
1522
- classes = {}
1523
-
1524
- for i, order in enumerate(orders):
1525
- classes.setdefault(order, []).append(i)
1526
-
1527
- classes = list(classes.values())
1528
-
1529
- for perms in product(*(permutations(c) for c in classes)):
1530
- result = list(range(len(orders)))
1531
-
1532
- for domain, image in zip(classes, perms):
1533
- for x, y in zip(domain, image):
1534
- result[x] = y
1535
-
1536
- yield tuple(result)
1537
-
1538
1732
 
1539
1733
  #################### PRODUCTS ####################
1540
1734
 
@@ -1801,53 +1995,7 @@ def icosahedral_group():
1801
1995
  return CayleyGroup((alternating_group(5) * cyclic_group(2)).cayley,_skip_validation=True)
1802
1996
 
1803
1997
 
1804
- #################### VISUALIZATION AND RENAMING HELPERS ####################
1805
-
1806
- def cayley_table(G, title="", colormap=rainbow, names="", renaming=[], math_mode=True):
1807
-
1808
- if title=="":
1809
- if _obtener_nombre(G)==None:
1810
- title = f"Cayley table"
1811
- else:
1812
- title = f"Cayley table of {_obtener_nombre(G)}"
1813
- if names=="":
1814
- if len(G)<=20:
1815
- names=True
1816
- else:
1817
- names=False
1818
- if renaming==[]:
1819
- if math_mode:
1820
- renaming = [rf"${e}$" for e in range(len(G))]
1821
- else:
1822
- renaming = [rf"{e}" for e in range(len(G))]
1823
-
1824
- elements = range(len(G))
1825
- fig, ax = plt.subplots(figsize=(6, 5))
1826
- im = ax.imshow(G, cmap=colormap)
1827
- ax.set_xticks(np.arange(len(elements)))
1828
- ax.set_yticks(np.arange(len(elements)))
1829
- ax.set_xticklabels(renaming)
1830
- ax.set_yticklabels(renaming)
1831
-
1832
- ax.xaxis.tick_top()
1833
-
1834
- if names:
1835
- for i in range(len(elements)):
1836
- for j in range(len(elements)):
1837
- color_texto = "black"
1838
- ax.text(
1839
- i,
1840
- j,
1841
- f"{renaming[G[j][i]]}",
1842
- ha="center",
1843
- va="center",
1844
- color=color_texto,
1845
- fontsize=12,
1846
- )
1847
-
1848
- plt.title(title)
1849
- plt.tight_layout()
1850
- plt.show()
1998
+ #################### RENAMING HELPERS ####################
1851
1999
 
1852
2000
  def _renaming_C(n):
1853
2001
  r = []
@@ -555,4 +555,4 @@ class PresentedGroup(Group):
555
555
 
556
556
 
557
557
  def __repr__(self):
558
- return self.__str__()
558
+ return self.__str__()
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "GroupsMath" # Nombre en PyPI
7
- version = "0.7.1"
7
+ version = "1.0.0"
8
8
  description = "The educational Python library for Group Theory"
9
9
  readme = "README.md" # Esta será la documentación visible en la portada de PyPI
10
10
  requires-python = ">=3.8"
File without changes
File without changes