本文整理汇总了Python中sage.graphs.all.DiGraph.set_edge_label方法的典型用法代码示例。如果您正苦于以下问题:Python DiGraph.set_edge_label方法的具体用法?Python DiGraph.set_edge_label怎么用?Python DiGraph.set_edge_label使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.graphs.all.DiGraph
的用法示例。
在下文中一共展示了DiGraph.set_edge_label方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _dig6_to_digraph
# 需要导入模块: from sage.graphs.all import DiGraph [as 别名]
# 或者: from sage.graphs.all.DiGraph import set_edge_label [as 别名]
def _dig6_to_digraph( dig6 ):
"""
Returns the digraph obtained from the dig6 and edge data.
INPUT:
- ``dig6`` -- a pair ``(dig6, edges)`` where ``dig6`` is a string encoding a digraph and ``edges`` is a dict or tuple encoding edges
EXAMPLES::
sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _digraph_to_dig6
sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _dig6_to_digraph
sage: dg = ClusterQuiver(['A',4]).digraph()
sage: data = _digraph_to_dig6(dg)
sage: _dig6_to_digraph(data)
Digraph on 4 vertices
sage: _dig6_to_digraph(data).edges()
[(0, 1, (1, -1)), (2, 1, (1, -1)), (2, 3, (1, -1))]
"""
dig6, edges = dig6
dg = DiGraph( dig6 )
if not type(edges) == dict:
edges = dict( edges )
for edge in dg._backend.iterator_in_edges(dg,False):
if edge in edges:
dg.set_edge_label( edge[0],edge[1],edges[edge] )
else:
dg.set_edge_label( edge[0],edge[1], (1,-1) )
return dg