当前位置: 首页>>代码示例>>Python>>正文


Python DiGraph.__init__方法代码示例

本文整理汇总了Python中sage.graphs.digraph.DiGraph.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python DiGraph.__init__方法的具体用法?Python DiGraph.__init__怎么用?Python DiGraph.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sage.graphs.digraph.DiGraph的用法示例。


在下文中一共展示了DiGraph.__init__方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from sage.graphs.digraph import DiGraph [as 别名]
# 或者: from sage.graphs.digraph.DiGraph import __init__ [as 别名]
    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())
开发者ID:sagemath,项目名称:sage,代码行数:29,代码来源:dynkin_diagram.py

示例2: __init__

# 需要导入模块: from sage.graphs.digraph import DiGraph [as 别名]
# 或者: from sage.graphs.digraph.DiGraph import __init__ [as 别名]
 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
开发者ID:jaanos,项目名称:mixedgraph,代码行数:53,代码来源:mixed_graph.py

示例3: __init__

# 需要导入模块: from sage.graphs.digraph import DiGraph [as 别名]
# 或者: from sage.graphs.digraph.DiGraph import __init__ [as 别名]
    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())
开发者ID:odellus,项目名称:sage,代码行数:21,代码来源:dynkin_diagram.py

示例4: __init__

# 需要导入模块: from sage.graphs.digraph import DiGraph [as 别名]
# 或者: from sage.graphs.digraph.DiGraph import __init__ [as 别名]
    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())
开发者ID:biasse,项目名称:sage,代码行数:41,代码来源:dynkin_diagram.py


注:本文中的sage.graphs.digraph.DiGraph.__init__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。