Beispiel #1
0
    def cayley_digraph(self, gens, color=False):
        """ Returns dict of edges of Cayley digraph. If color=True,
            returns separate dicts for each color arcs, where one color
            corresponds to one generator.
        """
        M, elems = self.array, self.elems
        ind = self.index
        dgraphs = []
        xgens, elem = [gens], []

        for i in gens:
            for j in gens:
                xgens.append([M[i - ind, j - ind]])
        xgens = allelems(xgens)
        for i in xgens:
            elem.append(self.cycle(i))
        elem = allelems(elem)

        for i in gens:
            dgraph = {j: [] for j in elems}
            for j in elem:
                cyc = self.cycle(i, [j])
                if len(cyc) > 1:
                    dgraph[j].append(cyc[1])
            dgraphs.append(dgraph)

        if color:
            return tuple(dgraphs)
        return mergedicts(dgraphs)
Beispiel #2
0
 def __init__(self, matrix):
     if issquare(matrix):
         self.array = np.array(matrix)
         self.order = len(matrix[0])
         self.index = np.amin(self.array)
         self.elems = allelems(self.array.tolist())
         self.finite_set = self.elems
     else:
         raise TypeError('Input %s not a square matrix.' % (matrix))
Beispiel #3
0
 def __init__(self, n):
     self.perm_order = n
     self.order = factorial(n)
     self.op = None
     self.perms = list(permutations(range(n)))
     self.array = self._matrix()
     self.finite_set = allelems(self.array)
     self.index = 0
     self.identity = self._identity()
Beispiel #4
0
 def __init__(self, n):
     self.perm_order = n
     self.order = 2 * n
     self.op = None
     self.perms = self._gens()
     self.array = self._matrix()
     self.finite_set = allelems(self.array)
     self.index = 0
     self.identity = self._identity()
Beispiel #5
0
 def __init__(self, finite_set, op=None):
     if op is None:
         super().__init__(finite_set)
         self.finite_set = allelems(finite_set)
         self.identity = self._identity()
         self.op = op
     elif callable(op):
         self.finite_set, self.op = list(finite_set), op
         self.order = len(self.finite_set)
         self.index = min(self.finite_set)
         super().__init__(self._matrix())
         self.identity = self._identity()
     else:
         raise TypeError('Input %s not a function.' % (op))