Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 119
G.laplacian_matrix().eigenvectors_right()
[(6, [ (1, -1, -1, 1, -1, 1, 1, -1) ], 1), (0, [ (1, 1, 1, 1, 1, 1, 1, 1) ], 1), (4, [ (1, 0, 0, -1, -1, 0, 0, 1), (0, 1, 0, -1, -1, 0, 1, 0), (0, 0, 1, -1, -1, 1, 0, 0) ], 3), (2, [ (1, 0, 0, -1, 1, 0, 0, -1), (0, 1, 0, 1, -1, 0, -1, 0), (0, 0, 1, 1, -1, -1, 0, 0) ], 3)]
G.eigenvectors()
[(3, [ (1, 1, 1, 1, 1, 1, 1, 1) ], 1), (-3, [ (1, -1, -1, 1, -1, 1, 1, -1) ], 1), (1, [ (1, 0, 0, -1, 1, 0, 0, -1), (0, 1, 0, 1, -1, 0, -1, 0), (0, 0, 1, 1, -1, -1, 0, 0) ], 3), (-1, [ (1, 0, 0, -1, -1, 0, 0, 1), (0, 1, 0, -1, -1, 0, 1, 0), (0, 0, 1, -1, -1, 1, 0, 0) ], 3)]
G = graphs.CubeGraph(3)
G.show3d(edge_size=0.01, color_by_label=True)
3D rendering not yet implemented
A5 = AlternatingGroup(5); A5 A5g = A5.cayley_graph(); A5.gens()
Alternating group of order 5!/2 as a permutation group [(3,4,5), (1,2,3,4,5)]
A5g.show3d(color_by_label=True, edge_size=0.01, edge_size2=0.02, vertex_size=0.03, iterations=2000)
3D rendering not yet implemented
S4 = SymmetricGroup(4); S4g = S4.cayley_graph() S4g.show3d(vertex_size=0.03, edge_size=0.01, edge_size2=0.02, color_by_label=True, iterations=200)
3D rendering not yet implemented
S4.gens()
[(1,2,3,4), (1,2)]
G = A5.cayley_graph(generators=[(1,3,5),(1,2,3),(3,4,5)])
Error in lines 1-1 Traceback (most recent call last): File "/projects/sage/sage-7.6/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 995, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in <module> NameError: name 'A5' is not defined
G.show3d(color_by_label=True, edge_size=0.01, vertex_size=0.03, iterations=2000)
Error in lines 1-1 Traceback (most recent call last): File "/projects/sage/sage-7.6/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 995, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in <module> NameError: name 'G' is not defined
A5.gens()
[(3,4,5), (1,2,3,4,5)]
def MyGroup(n,grp_type="Cyclic"): if grp_type == "Cyclic" or grp_type == "cyclic": Z = CyclicPermutationGroup(n) elif grp_type == "Dihedral" or grp_type == "dihedral": Z = DihedralGroup(n) elif grp_type == "Alternating" or grp_type == "alternating": Z = AlternatingGroup(n) elif grp_type == "Symmetric" or grp_type == "symmetric": Z = SymmetricGroup(n) else: print("The group type supplied is unknown") return -1 print len(Z.list()), Z.gens() Zg = Z.cayley_graph() return Zg.show3d(color_by_label=True, edge_size=0.01, edge_size2=0.02, vertex_size=0.03, iterations=1000)
MyGroup(6, "Dihedral")
12 [(1,2,3,4,5,6), (1,6)(2,5)(3,4)]
3D rendering not yet implemented
# Define group and generate list of subgroups of the group G = AlternatingGroup(6) subgroups = G.conjugacy_classes_subgroups() # Define f(h,k) = True iff h is a subgroup of k f = lambda h,k: h.is_subgroup(k) label = {subgroups[i]: " "*floor(i/2) + subgroups[i].structure_description() + " "*i for i in range(len(subgroups))} # Define and display the poset P = Poset((subgroups, f)) P.plot(element_labels = label, vertex_shape="o", vertex_size = 500, layout="acyclic")
Error in lines 6-7 Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/smc_sagews/sage_server.py", line 905, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in <module> File "", line 1, in <dictcomp> File "/projects/sage/sage-dev/local/lib/python2.7/site-packages/sage/groups/generic.py", line 1408, in structure_description raise RuntimeError("You must install the optional database_gap package first.") RuntimeError: You must install the optional database_gap package first.
from collections import defaultdict def subgroup_conj_classes(G): """ Returns [cc_1, cc_2, ... cc_n] : each cc_i is a list containing subgroups of G that belong to the same conjugacy class. """ ccs = G._gap_().ConjugacyClassesSubgroups() return [tuple([G.subgroup(gap_group = H) for H in cc.Elements()]) for cc in ccs] def are_subgroups(cc1,cc2): """ Returns True if some element of cc1 is a subgroup of an element of cc2. """ # Choose the shorter list to iterate over if len(cc1) <= len(cc2): h2 = cc2[0] for h1 in cc1: if h1.is_subgroup(h2): return True else: h1 = cc1[0] for h2 in cc2: if h1.is_subgroup(h2): return True return False @interact def subgroup_class_lattices(Cardinality= 6): group_list = {Cardinality: {}} for G_gap in gap.AllSmallGroups(Cardinality): G = PermutationGroup(list(gap.GeneratorsOfGroup(G_gap.AsPermGroup()))) group_list[Cardinality][G.structure_description()] = str(G.gens()) @interact def group_select(Group = selector(values = group_list[Cardinality].keys())): # Generate group G = PermutationGroup(gap(group_list[Cardinality][Group])) # Poset of conjugacy classes sub_classes = subgroup_conj_classes(G) poset = Poset((sub_classes,are_subgroups)) @interact def display_options(Show = selector(values = ['Conjugacy classes of subgroups', 'All subgroups']), Vertex_Colors = selector(values = ['Normal (Green), Commutator (Pink), Center (Blue)','None'], label = 'Vertex colors'), Edge_Colors = selector(values = ['Is normal subgroup of','None',], label = 'Edge colors'), Edge_Labels = selector(values =['Contains','Contained by', 'Both','None',], label = 'Edge labels')): if Show == 'All subgroups': # Poset of all subgroups subgroups = [h for cc in sub_classes for h in cc ] covers = [] for cc1,cc2 in poset.cover_relations(): for h1 in cc1: for h2 in cc2: if h1.is_subgroup(h2): covers.append([h1,h2]) full_poset = Poset((subgroups,covers),cover_relations = True) # Define vertex colors if Vertex_Colors is not 'None': vertex_colors = defaultdict(list) for h in subgroups: # Color non-normal subgroups white if not h.is_normal(): vertex_colors['white'].append(h) else: # Color the commutator subgroup pink if h == G.subgroup(G.commutator().gens()): vertex_colors['pink'].append(h) # Color the center lightblue elif h == G.center(): vertex_colors['lightblue'].append(h) # Color all other normal subgroups green else: vertex_colors['lightgreen'].append(h) else: vertex_colors = 'white' # Define edge colors if Edge_Colors is not 'None': edge_colors = {'#60D6D6':[],'lightgray':[]} for h,k in full_poset.cover_relations(): if h.is_normal(k): edge_colors['#60D6D6'].append((h,k)) else: edge_colors['lightgray'].append((h,k)) else: edge_colors = None # Define vertex labels vertex_labels = {h : h.structure_description() for h in subgroups} #### END OF CUSTOM DISPLAY OPTIONS # Define heights, if poset is ranked rank_function = full_poset.rank_function() if rank_function: heights = defaultdict(list) for i in full_poset: heights[rank_function(i)].append(i) else: heights = None # Generate Hasse diagram graph = full_poset.hasse_diagram() # Generate graph_plot object gplot = graph.graphplot(vertex_labels=None,layout='acyclic',vertex_colors = vertex_colors, edge_colors = edge_colors, vertex_size = 1000) # Set vertex labels gplot._plot_components['vertex_labels'] = [] for v in gplot._nodelist: gplot._plot_components['vertex_labels'].append(text(vertex_labels[v], gplot._pos[v], rgbcolor=(0,0,0), zorder=8)) # Display! gplot.show(figsize=(10,10)) else: # Show = 'Conjugacy classes of subgroups' # Define vertex colors if Vertex_Colors is not 'None': vertex_colors = defaultdict(list) for cc in sub_classes: # Color non-normal subgroups white if not cc[0].is_normal(): vertex_colors['white'].append(cc) else: # Color the commutator subgroup pink if cc[0] == G.subgroup(G.commutator().gens()): vertex_colors['pink'].append(cc) # Color the center lightblue elif cc[0] == G.center(): vertex_colors['lightblue'].append(cc) # Color all other normal subgroups green else: vertex_colors['lightgreen'].append(cc) else: vertex_colors = 'white' # Define edge colors if Edge_Colors is not 'None': edge_colors = {'#60D6D6':[],'lightgray':[]} for cc1,cc2 in poset.cover_relations(): h1 = cc1[0] # Color by whether elts of cc1 are normal subgroups of elts of cc2 is_normal = False for h2 in cc2: if h1.is_subgroup(h2) and h1.is_normal(h2): edge_colors['#60D6D6'].append((cc1,cc2)) is_normal = True break if not is_normal: edge_colors['lightgray'].append((cc1,cc2)) else: edge_colors = None # Define vertex labels vertex_labels = {cc : cc[0].structure_description() for cc in sub_classes} #### END OF CUSTOM DISPLAY OPTIONS # Define heights, if poset is ranked rank_function = poset.rank_function() if rank_function: heights = defaultdict(list) for i in poset: heights[rank_function(i)].append(i) else: heights = None # Generate Hasse diagram graph = poset.hasse_diagram() # Set edge labels label_edges = True if Edge_Labels == 'Contained by': for cc1,cc2,label in graph.edges(): # Count number of subgroups in cc2 that a fixed representative of cc1 is contained by count = sum([cc1[0].is_subgroup(h2) for h2 in cc2]) if count == 1: graph.set_edge_label(cc1,cc2,'') else: graph.set_edge_label(cc1,cc2,' ' + str(count)) elif Edge_Labels == 'Contains': for cc1,cc2,label in graph.edges(): # Count number of subgroups in cc1 that a fixed representative of cc2 contains count = sum([h1.is_subgroup(cc2[0]) for h1 in cc1]) if count == 1: graph.set_edge_label(cc1,cc2,'') else: graph.set_edge_label(cc1,cc2,' ' + str(count)) elif Edge_Labels == 'Both': for cc1,cc2,label in graph.edges(): # Both of the above count1 = sum([cc1[0].is_subgroup(h2) for h2 in cc2]) count2 = sum([h1.is_subgroup(cc2[0]) for h1 in cc1]) if count1 == 1 and count2 == 1: graph.set_edge_label(cc1,cc2,'') else: graph.set_edge_label(cc1,cc2,' ' + '{},{}'.format(count1,count2)) else: label_edges = False # Generate graph_plot object gplot = graph.graphplot(vertex_labels=None,layout='acyclic',vertex_colors = vertex_colors, edge_colors = edge_colors, edge_labels = label_edges, vertex_size = 1000) # Set vertex labels gplot._plot_components['vertex_labels'] = [] for v in gplot._nodelist: gplot._plot_components['vertex_labels'].append(text(vertex_labels[v], gplot._pos[v], rgbcolor=(0,0,0), zorder=8)) # Display! gplot.show(figsize=(7,7))
Interact: please open in CoCalc
rd = polytopes.rhombic_dodecahedron()
r.PolyhePolyhedPolyhePolyhedron