the graph in sage

168 views Asked by At

I want define new graph in sage. Let G be finite group. The graph's vertices are subgroup and two vertices are adjacent if and only if sum of two subgroup is G.

I have trouble with define this graph in sage. Any suggestion? I have idea in gap but I don't have idea what can I change in sage?

Summands := function(G) 

local n, i, sgl, l, A, B, D;

obtain a list of all subgroups

sgl := List(LatticeSubgroups(G)!.conjugacyClassesSubgroups, Representative);

n is the number of divisors of |G|

n := Size(DivisorsInt(Size(G)));

D := [];

if IsOddInt(n) then l := QuoInt(n + 1, 2);
           else l := QuoInt(n, 2);
fi;

for i in [1..l] do
  for A in Filtered(sgl, function(g) return Size(g) = DivisorsInt(Size(G))[i]; end) do
    for B in Filtered(sgl, function(g) return Size(g) = DivisorsInt(Size(G))[n+1-i]; end) do
        Add(D, [A, B]);
    od;
  od;
od;

return D;
end;
1

There are 1 answers

2
kcrisman On

Here are Sage equivalents to some of these commands. Incidentally, we use GAP for the group calculations!

sage: D = DihedralGroup(5)
sage: D.subgroups()
[Permutation Group with generators [()], Permutation Group with generators [(2,5)(3,4)], Permutation Group with generators [(1,2)(3,5)], Permutation Group with generators [(1,3)(4,5)], Permutation Group with generators [(1,4)(2,3)], Permutation Group with generators [(1,5)(2,4)], Permutation Group with generators [(1,2,3,4,5)], Permutation Group with generators [(1,5,4,3,2), (1,5)(2,4)]]
sage: divisors(D.cardinality())
[1, 2, 5, 10]

To make graphs in Sage, you can pass dictionaries of lists or other things; see

sage: Graph?

for more information on that.

Edit - left in to make comments comprehensible:

By the way, it looks like you are trying to make a list of pairs of subgroups A and B such that |A||B|=ord(G). Is that necessarily the same as groups whose sum (whatever you mean by that - direct sum?) is the original group? I'm thinking for instance of even a group of order four; summing any two subgroups of order two may not be isomorphic to the original group - for instance, if the two subgroups are the same one if you mean some sort of ambient sum (does this even make sense?), or if you use direct sum but the group is the cyclic group of order 4, not the Klein four group.