示例#1
0
    def graph(self):
        """ Return a graphical representation of self.

        OUTPUT:

        G, vert_dict,

        where G is a graph object and vert_dict is a dictionary associating
        to a vertex of G the corresponding vertex of self.
        """

        G = Graph()
        G.add_vertex(0)
        vert_dict = {}
        create_graph_recursive(self, G, vert_dict, 0)
        return G, vert_dict
示例#2
0
    def __init__(self, edges, loops, kappa):
        '''
        Construct a Labeled Stable Graph -- the canonical representative of the labeled stable graph given by edges, loops and           kappa, where:

        - ``edges``  -- tuple of triples, where a triple (v1,v2,m) means that the vertices v1 and v2 are connected by m edges
        - ``loops``  -- tuple, where an integer loops[i] is the number of loops associated to the vertex i
        - ``kappa``  -- tuple of tuples, a partition of stratum into subpartitions, where kappa[i] is a subpartition of orders of zeroes associated to the vertex i
        
        Lists can be used instead of tuples, as they will be automatically converted to be immutable.
        '''
        if not edges:
            graph = Graph(weighted=True, loops=False, multiedges=False)
            graph.add_vertex()
        else:
            graph = Graph(list(edges),
                          loops=False,
                          multiedges=False,
                          weighted=True)
        self.edges, self.loops, self.kappa, self.graph = canonical(
            graph.edges(), loops, kappa, graph)
        self.genera = [(sum(self.kappa[v]) - 2 * self.vertex_deg(v) -
                        4 * self.loops[v] + 4) / ZZ(4)
                       for v in self.graph.vertices()]
示例#3
0
    def __init__(self, strataG):
        #make the graph

        G = Graph()

        for v in range(1, strataG.num_vertices()):
            G.add_vertex(v)
            for expon, coef in strataG.M[v, 0].dict().items():
                if expon[0] == 1:
                    genus = coef
                else:
                    pass

        self.decorations = dict()

        dec_items = list(self.decorations.items())
        dec_items.sort(lambda x: x[1])

        parts = []
        prev = None
        dec_list = []

        for a in dec_items:
            if a != prev:
                dec_list.append(a[1])
                parts.append(new_part)
                new_part = [a[0]]
            else:
                new_part.append(a[0])

        self.dec_list = tuple(dec_list)

        self.graph, cert = graphUncan.canonical_labeling(parts).copy(
            immutable=True)

        self.parts = tuple(
            (tuple([cert[i] for i in part_j].sort) for part_j in parts))