コード例 #1
0
ファイル: jsondata.py プロジェクト: foadnh/groups
#!/usr/bin/python
import sys
sys.path.insert(1, sys.path[0] + '/..')
from groups.read  import readName
from groups.about import printAbout

if len(sys.argv) < 2:
    sys.stderr.write("Usage: %s group ...\n" % (sys.argv[0],))
    sys.exit(2)
sys.stdout.write('[\n');
first = True
for gname in sys.argv[1:]:
    g = readName(gname)
    if first:
	first = False
    else:
	sys.stdout.write(',\n')
    sys.stdout.write('\n')
    printAbout(g, out=sys.stdout, indent=' ')
sys.stdout.write('\n\n]\n')
コード例 #2
0
ファイル: cayley.py プロジェクト: foadnh/groups
#!/usr/bin/python
import sys
sys.path.insert(1, sys.path[0] + '/..')
from groups.read import readName

if len(sys.argv) < 2 or (sys.argv[1] == '-a' and len(sys.argv) == 2):
    sys.stderr.write("Usage: %s [-a] group ...\n" % (sys.argv[0], ))
    sys.exit(2)

if sys.argv[1] == '-a':

    def showTbl(g):
        return g.cayley()

    del sys.argv[1]
else:

    def showTbl(g):
        return g.cayleyU().encode('utf-8')


for gname in sys.argv[1:]:
    g = readName(gname)
    sys.stdout.write(showTbl(g) + '\n')
コード例 #3
0
ファイル: lattice.py プロジェクト: mmeexx37/groups
   subgroups are represented as filled circles, while non-normal subgroups are
   empty circles."""

# TODO: It seems that, if two adjacent subgraphs have no lines between them
# (e.g., the 8 and 6 subgraphs in the S_4 lattice), then `dot` will draw them
# at the same height/rank.  Try to keep this from happening.

import sys
sys.path.insert(1, sys.path[0] + '/..')
from groups.read import readName
from groups      import lattice

if len(sys.argv) != 2:
    raise SystemExit("Usage: %s group\n" % (sys.argv[0],))

g = readName(sys.argv[1])
subsSet = g.subgroups()
subsDex = dict((s,i) for (i,s) in enumerate(subsSet))
byOrder = {}
for (i,s) in enumerate(subsSet):
    byOrder.setdefault(len(s), []).append(s)

print 'graph {'
for order in sorted(byOrder):
    print ' subgraph order%d {' % (order,)
    print '  rank = "same"'
    for s in byOrder[order]:
        print '  s%d [shape = "point"%s]' % (subsDex[s],
                                             '' if g.isNormal(s)
                                                else ', fillcolor = "white"')
    print ' }'