|   | 1 |  initial version  | 
For #1:
sage: G = groups.permutation.Symmetric(3)
sage: for x in G:
....:       (do stuff with x)
For example:
sage: G = groups.permutation.Symmetric(3)
sage: d = {}
sage: for x in G:
....:     for y in G:
....:         if x*y != y*x:
....:             if x in d:
....:                 d[x].append(y)
....:             else:
....:                 d[x] = [y]
....:
At this point, d is a dictionary. The keys are the non-identity elements of G, and the value corresponding to x is the list of elements y that do not commute with x. So for #2:
sage: gr = Graph(d)
sage: view(gr)

 Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.
 
                
                Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.