Exemplo n.º 1
0
    def __init__(
        self, data=None, zooid=None, props=None, graph=None, vertex_labels=None, name=None, cur=None, db=None, **kargs
    ):
        ZooObject.__init__(self, db)
        kargs["immutable"] = True
        kargs["data_structure"] = "static_sparse"
        if isinteger(data):
            zooid = Integer(data)
            data = None
        elif isinstance(data, GenericGraph):
            graph = data
            data = None
        elif isinstance(data, dict):
            props = data
            data = None
        if props is not None:
            if "id" in props:
                zooid = props["id"]
            if "data" in props:
                data = props["data"]
            props = {k: v for k, v in props.items() if k not in ["id", "data"]}

        if graph is not None:
            if not isinstance(graph, GenericGraph):
                raise TypeError("not a graph")
            data = graph
            if name is None:
                name = graph.name()
            if isinstance(graph, ZooGraph):
                zooid = graph._zooid
                self._props = graph._props
            if cur is not None:
                if self._props is None:
                    self._props = {}
                self._props["diameter"] = graph.diameter()
                self._props["girth"] = graph.girth()
                self._props["order"] = graph.order()
            elif zooid is None:
                raise IndexError("graph id not given")
        else:
            cur = None
            if props is not None:
                self._props = self._todict(props, skip=ZooGraph._spec["skip"], fields=ZooGraph._spec["fields"])

        self._zooid = zooid
        if data is None:
            data = self._db_read()["data"]
        if vertex_labels is not None:
            data = Graph(data).relabel(vertex_labels, inplace=False)
        Graph.__init__(self, data=data, name=name, **kargs)
        if cur is not None:
            self._db_write(cur)
Exemplo n.º 2
0
    def __init__(self, graph=None, **kwargs):
        r"""
        Constructor, based on the ``Graph`` constructor.

        TESTS:

        ::

            sage: c = graphs.ClebschGraph()
            sage: c.clique_polynomial()
            40*t^2 + 16*t + 1
            sage: from boolean_cayley_graphs.graph_improved import GraphImproved
            sage: ci = GraphImproved(c)
            sage: ci.stored_clique_polynomial
            40*t^2 + 16*t + 1
        """
        Graph.__init__(self, graph, **kwargs)
        self.stored_clique_polynomial = graph.clique_polynomial()
Exemplo n.º 3
0
 def __init__(self, *args, **kwargs):
     reserved_edge_labels = kwargs.pop("reserved_edge_labels", None)
     EdgeLabelledMixin.__init__(self, reserved_edge_labels)
     Graph.__init__(self, *args, **kwargs)