xxxxxxxxxx
# load library. Evaluate this cell first. The other cells can then be evaluated in any order.
load('https://jan.ucc.nau.edu/ns46/invariant/invariant.sage')
xxxxxxxxxx
M1=Matrix([[2,0,-2],[0,1,0],[0,0,0]])
M2=Matrix([[1,0,-1],[0,1,0],[0,0,0]])
M3=Matrix([[1,-1,0,0,0,0],[-1,2,-1,0,0,0],[0,-1,2,-1,0,0],[0,0,-1,2,-1,0],[0,0,0,-1,2,-1],[0,0,0,0,-1,1]])
Â
Mlist=[M1,M2]
Mlist=[M3] # Last list defined is used. Move lines or comment them out to adjust.
show(Mlist)
Â
% time cols=AllInvariant(Mlist)
for i,col in enumerate(cols):
print(i,":",col) # coloring vectors are listed, starting with color 0
poset(cols).show(figsize=[2,2]) # The lattice of invariant subspaces
xxxxxxxxxx
# edge is (tail, head, color). Use comments or move edge list to choose digraph.
#edges=[(1,2,1), (1,2,1), (3,2,2)] # partition code works but 4 arrows are plotted instead of 2. Double arrow gives 2 in Adjacency matrix, as it should.
#edges=[(1,2,1),(2,1,1),(1,3,2),(3,1,3),(3,2,3)] # Stewart et al [3] Fig. 3
#edges=[(4,3,1),(3,5,1),(5,4,1),(5,6,2),(5,7,2),(5,8,2),(3,1,3),(4,2,3),(8,1,4),(7,2,4),(1,2,5),(2,1,5),(1,6,6),(2,7,6),(2,8,6)] # Figure 2 in Aguiar and Dias [1]
#edges = [(1,5,1),(2,1,1),(2,4,1),(2,6,1),(3,6,2),(4,5,1),(5,2,1),(5,3,1),(5,7,1),(5,8,1),(6,5,1),(7,4,1),(8,4,2),(8,6,2),(8,9,2),(9,5,1)] # Kamei and Cock [2] Figure 13(b)
edges = [(1,2,1),(1,3,2),(1,4,1),(1,4,2),(1,5,2),(2,1,1),(2,1,2),(2,4,1),(3,3,1),(3,5,1),(4,1,1),(4,2,1),(4,2,2),(5,3,1),(5,5,1)] # Kamei and Cock [2] graph G_5 in Table 1, with lattice in Figure 8
Â
g=DiGraph(edges,multiedges=True,loops=True)
Mlist=computeAdjacencyMlist(g) # A for balanced partitions
#Mlist=computeLaplacianMlist(g) # L for exo-balanced partitions. Comment out to get balanced
show(Mlist)
show(g.plot(save_pos=True,figsize=[3,3],vertex_size=420,color_by_label=True))
Â
% time cols=AllInvariant(Mlist)
for i,col in enumerate(cols):
print(i,":",col) # coloring vectors are listed, starting with color 0
poset(cols).show(figsize=[2,2]) # The lattice of invariant subspaces
#orbit_poset(g.automorphism_group(),cols).show(figsize=[2,2]) # Poset of group orbits of invariant subspaces
xxxxxxxxxx
edges=[(1,2),(2,3),(4,3),(5,4)]
edges=[(1,2),(2,3),(3,1),(3,4),(4,5),(5,6),(6,7)] # Stewart et al [3] Fig. 6
edges=[(1,4),(1,5),(2,1),(2,5),(3,2),(4,3),(5,1),(5,2),(5,3),(5,4)] # Stewart et al [3] Fig. 15, and Golubitsky, Stewart and Torok Fig 7
edges=[(1,1),(1,2),(1,5),(2,2),(2,3),(2,3),(3,1),(3,4),(5,4),(5,5)] # Aguiar and Dias [1] Fig. 6,7.
Â
g=DiGraph(edges,multiedges=True,loops=True)
Mlist=computeAdjacencyMlist(g)
Mlist=computeLaplacianMlist(g) # comment out to get balanced
# show(Mlist)
show(g.plot(save_pos=True,figsize=[3,3],vertex_size=420))
Â
% time cols=AllInvariant(Mlist)
for i,col in enumerate(cols):
print(i,":",col) # coloring vectors are listed, starting with color 0
poset(cols).show(figsize=[2,2]) # The lattice of invariant subspaces
#orbit_poset(g.automorphism_group(),cols).show(figsize=[2,2]) # Poset of group orbits of invariant subspaces
xxxxxxxxxx
# For edge colored graphs, use edge colored digraph cell and list both arrows for each edge.
edges=[(1,2), (1,3), (1, 9), (2,3), (3,4), (4,5), (4,6), (5,6), (6,7), (7,8), (7,9), (8,9)] # Sierpinski pre-gasket
edges = [(1,1),(1,2),(2,3),(3,4),(4,5),(5,6),(6,6)] # balanced of this graph with loops are same as exo-balanced of P_6
edges = graphs.PathGraph(6).edges() # P_n is path with n vertices.
edges = [(1,2),(1,3),(2,3),(3,4),(4,5),(5,6),(6,7),(6,8), (7,8)] # McKay graph
edges = graphs.CycleGraph(6).edges() # C_n. Search "Sage Common Graphs" on web for more pre-defined graphs
Â
g=Graph(edges,multiedges=True,loops=True)
Mlist=[g.adjacency_matrix()] # A-invariant, balanced, or equitable partitions
Mlist=[g.laplacian_matrix()] # L-invariant, exo-balanced, or almost equitable partitions.
# show(Mlist)
show(g.plot(save_pos=True,figsize=[2,2]))
Â
% time cols=AllInvariant(Mlist)
for i,col in enumerate(cols):
print(i,":",col) # coloring vectors are listed, starting with color 0
poset(cols).show(figsize=[4,4]) # The lattice of invariant subspaces
orbit_poset(g.automorphism_group(),cols).show(figsize=[3,3]) # Poset of group orbits of invariant subspaces
xxxxxxxxxx
G = QuaternionGroup() # Q_8
G = CyclicPermutationGroup(3) # Z3
G = direct_product_permgroups([CyclicPermutationGroup(2),CyclicPermutationGroup(2)])
G = DihedralGroup(3) # DihedralGroup(n) has order 2n
Â
g = G.cayley_graph(generators = G.gens())
Mlist=computeAdjacencyMlist(g)
# show(Mlist)
show(g.plot(save_pos=True,figsize=[3,3],vertex_size=420,color_by_label=True))
Â
% time cols=AllInvariant(Mlist)
for i,col in enumerate(cols):
print(i,":",col) # coloring vectors are listed, starting with color 0
poset(cols).show(figsize=[3,3]) # The lattice of invariant subspaces
orbit_poset(g.automorphism_group(),cols).show(figsize=[2,2]) # Poset of group orbits of invariant subspaces