示例#1
0
    def __init__(self, t=None, index_set=None, odd_isotropic_roots=[],
                 **options):
        """
        Initialize ``self``.

        EXAMPLES::

            sage: d = DynkinDiagram(["A", 3])
            sage: TestSuite(d).run()
        """
        if isinstance(t, DiGraph):
            if isinstance(t, DynkinDiagram_class):
                self._cartan_type = t._cartan_type
                self._odd_isotropic_roots = tuple(odd_isotropic_roots)
            else:
                self._cartan_type = None
                self._odd_isotropic_roots = ()
            DiGraph.__init__(self, data=t, **options)
            return

        DiGraph.__init__(self, **options)
        self._cartan_type = t
        self._odd_isotropic_roots = tuple(odd_isotropic_roots)
        if index_set is not None:
            self.add_vertices(index_set)
        elif t is not None:
            self.add_vertices(t.index_set())
示例#2
0
 def __init__(self, data = None, arcs = None, edges = None,
              multiedges = True, loops = True, **kargs):
     init = True
     if data is None:
         if edges is None:
             edges = []
         if arcs is None:
             arcs = []
     else:
         if isinstance(data, MixedGraph):
             if edges is not None or arcs is not None:
                 raise ValueError("Edges or arcs should not be specified with a MixedGraph")
             self._edges = data._edges
             self._arcs = data._arcs
             init = False
         elif isinstance(data, Graph):
             if edges is not None:
                 raise ValueError("Edges should not be specified with a Graph")
             edges = data.edges(labels=False)
             if arcs is None:
                 arcs = []
         elif isinstance(data, DiGraph):
             if arcs is not None:
                 raise ValueError("Arcs should not be specified with a DiGraph")
             arcs = data.edges(labels=False)
             if edges is None:
                 edges = []
         elif arcs is not None and edges is None:
             edges = data
             data = None
         else:
             if edges is not None or arcs is not None:
                 raise ValueError("Edges or arcs should not be specified with other data")
             self._edges = []
             self._arcs = []
             for i, e in enumerate(data):
                 u, v = e
                 if isinstance(e, (set, frozenset, Set_generic)):
                     self._edges.append((u, v, i))
                 else:
                     self._arcs.append((u, v, i))
             init = False
     if init:
         n = len(edges)
         self._edges = [(u, v, i) for i, (u, v) in enumerate(edges)]
         self._arcs = [(u, v, i+n) for i, (u, v) in enumerate(arcs)]
     DiGraph.__init__(self, self._edges + self._arcs,
                      multiedges = multiedges, loops = loops, **kargs)
     if isinstance(data, GenericGraph) and data._pos is not None and \
         kargs.setdefault('pos', None) is None and len(data) == len(self):
             self._pos = data._pos
示例#3
0
    def __init__(self, t = None):
        """
        INPUT:

        - ``t`` -- a Cartan type or ``None``

        EXAMPLES::

            sage: d = DynkinDiagram(["A", 3])
            sage: d == loads(dumps(d))
            True

        Implementation note: if a Cartan type is given, then the nodes
        are initialized from the index set of this Cartan type.
        """
        DiGraph.__init__(self)
        self._cartan_type = t
        if t is not None:
            self.add_vertices(t.index_set())
示例#4
0
    def __init__(self, t = None):
        """
        INPUT:

         - ``t`` - a Cartan type or None

        EXAMPLES::

            sage: d = DynkinDiagram(["A", 3])
            sage: d == loads(dumps(d))
            True

        Implementation note: if a Cartan type is given, then the nodes
        are initialized from the index set of this Cartan type.
        """
        DiGraph.__init__(self)
        self._cartan_type = t
        if t is not None:
            self.add_vertices(t.index_set())
示例#5
0
    def __init__(self, t = None, **options):
        """
        INPUT:

        - ``t`` -- a Cartan type or ``None``

        EXAMPLES::

            sage: d = DynkinDiagram(["A", 3])
            sage: TestSuite(d).run()

        Check that the correct type is returned when copied::

            sage: d = DynkinDiagram(["A", 3])
            sage: type(copy(d))
            <class 'sage.combinat.root_system.dynkin_diagram.DynkinDiagram_class'>

        We check that :trac:`14655` is fixed::

            sage: cd = copy(d)
            sage: cd.add_vertex(4)
            sage: d.vertices() != cd.vertices()
            True

        Implementation note: if a Cartan type is given, then the nodes
        are initialized from the index set of this Cartan type.
        """
        if isinstance(t, DiGraph):
            if isinstance(t, DynkinDiagram_class):
                self._cartan_type = t._cartan_type
            else:
                self._cartan_type = None
            DiGraph.__init__(self, data=t, **options)
            return

        DiGraph.__init__(self, **options)
        self._cartan_type = t
        if t is not None:
            self.add_vertices(t.index_set())
示例#6
0
    def __init__(self, t=None, **options):
        """
        INPUT:

        - ``t`` -- a Cartan type or ``None``

        EXAMPLES::

            sage: d = DynkinDiagram(["A", 3])
            sage: TestSuite(d).run()

        Check that the correct type is returned when copied::

            sage: d = DynkinDiagram(["A", 3])
            sage: type(copy(d))
            <class 'sage.combinat.root_system.dynkin_diagram.DynkinDiagram_class'>

        We check that :trac:`14655` is fixed::

            sage: cd = copy(d)
            sage: cd.add_vertex(4)
            sage: d.vertices() != cd.vertices()
            True

        Implementation note: if a Cartan type is given, then the nodes
        are initialized from the index set of this Cartan type.
        """
        if isinstance(t, DiGraph):
            if isinstance(t, DynkinDiagram_class):
                self._cartan_type = t._cartan_type
            else:
                self._cartan_type = None
            DiGraph.__init__(self, data=t, **options)
            return

        DiGraph.__init__(self, **options)
        self._cartan_type = t
        if t is not None:
            self.add_vertices(t.index_set())
示例#7
0
 def __init__(self, *args, **kwargs):
     reserved_edge_labels = kwargs.pop("reserved_edge_labels", None)
     EdgeLabelledMixin.__init__(self, reserved_edge_labels)
     DiGraph.__init__(self, *args, **kwargs)
示例#8
0
 def __init__(self,
              data=None,
              arcs=None,
              edges=None,
              multiedges=True,
              loops=True,
              **kargs):
     init = True
     if data is None:
         if edges is None:
             edges = []
         if arcs is None:
             arcs = []
     else:
         if isinstance(data, MixedGraph):
             if edges is not None or arcs is not None:
                 raise ValueError(
                     "Edges or arcs should not be specified with a MixedGraph"
                 )
             self._edges = data._edges
             self._arcs = data._arcs
             init = False
         elif isinstance(data, Graph):
             if edges is not None:
                 raise ValueError(
                     "Edges should not be specified with a Graph")
             edges = data.edges(labels=False)
             if arcs is None:
                 arcs = []
         elif isinstance(data, DiGraph):
             if arcs is not None:
                 raise ValueError(
                     "Arcs should not be specified with a DiGraph")
             arcs = data.edges(labels=False)
             if edges is None:
                 edges = []
         elif arcs is not None and edges is None:
             edges = data
             data = None
         else:
             if edges is not None or arcs is not None:
                 raise ValueError(
                     "Edges or arcs should not be specified with other data"
                 )
             self._edges = []
             self._arcs = []
             for i, e in enumerate(data):
                 u, v = e
                 if isinstance(e, (set, frozenset, Set_generic)):
                     self._edges.append((u, v, i))
                 else:
                     self._arcs.append((u, v, i))
             init = False
     if init:
         n = len(edges)
         self._edges = [(u, v, i) for i, (u, v) in enumerate(edges)]
         self._arcs = [(u, v, i + n) for i, (u, v) in enumerate(arcs)]
     DiGraph.__init__(self,
                      self._edges + self._arcs,
                      multiedges=multiedges,
                      loops=loops,
                      **kargs)
     if isinstance(data, GenericGraph) and data._pos is not None and \
         kargs.setdefault('pos', None) is None and len(data) == len(self):
         self._pos = data._pos