本文整理汇总了Python中sage.graphs.digraph.DiGraph.set_pos方法的典型用法代码示例。如果您正苦于以下问题:Python DiGraph.set_pos方法的具体用法?Python DiGraph.set_pos怎么用?Python DiGraph.set_pos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.graphs.digraph.DiGraph
的用法示例。
在下文中一共展示了DiGraph.set_pos方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Path
# 需要导入模块: from sage.graphs.digraph import DiGraph [as 别名]
# 或者: from sage.graphs.digraph.DiGraph import set_pos [as 别名]
def Path(self,n):
r"""
Returns a directed path on `n` vertices.
INPUT:
- ``n`` (integer) -- number of vertices in the path.
EXAMPLES::
sage: g = digraphs.Path(5)
sage: g.vertices()
[0, 1, 2, 3, 4]
sage: g.size()
4
sage: g.automorphism_group().cardinality()
1
"""
g = DiGraph(n)
g.name("Path")
if n:
g.add_path(range(n))
g.set_pos({i:(i,0) for i in range(n)})
return g
示例2: Path
# 需要导入模块: from sage.graphs.digraph import DiGraph [as 别名]
# 或者: from sage.graphs.digraph.DiGraph import set_pos [as 别名]
def Path(self,n):
r"""
Returns a directed path on `n` vertices.
INPUT:
- ``n`` (integer) -- number of vertices in the path.
EXAMPLES::
sage: g = digraphs.Path(5)
sage: g.vertices()
[0, 1, 2, 3, 4]
sage: g.size()
4
sage: g.automorphism_group().cardinality()
1
"""
if n<0:
raise ValueError("The number of vertices must be a positive integer.")
g = DiGraph()
g.name("Path on "+str(n)+" vertices")
if n:
g.add_path(range(n))
g.set_pos({i:(i,0) for i in range(n)})
return g