本文整理汇总了Python中sage.graphs.digraph.DiGraph.is_isomorphic方法的典型用法代码示例。如果您正苦于以下问题:Python DiGraph.is_isomorphic方法的具体用法?Python DiGraph.is_isomorphic怎么用?Python DiGraph.is_isomorphic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.graphs.digraph.DiGraph
的用法示例。
在下文中一共展示了DiGraph.is_isomorphic方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: find_cartan_type_from_matrix
# 需要导入模块: from sage.graphs.digraph import DiGraph [as 别名]
# 或者: from sage.graphs.digraph.DiGraph import is_isomorphic [as 别名]
def find_cartan_type_from_matrix(CM):
r"""
Find a Cartan type by direct comparison of Dynkin diagrams given from
the generalized Cartan matrix ``CM`` and return ``None`` if not found.
INPUT:
- ``CM`` -- a generalized Cartan matrix
EXAMPLES::
sage: from sage.combinat.root_system.cartan_matrix import find_cartan_type_from_matrix
sage: CM = CartanMatrix([[2,-1,-1], [-1,2,-1], [-1,-1,2]])
sage: find_cartan_type_from_matrix(CM)
['A', 2, 1]
sage: CM = CartanMatrix([[2,-1,0], [-1,2,-2], [0,-1,2]])
sage: find_cartan_type_from_matrix(CM)
['C', 3] relabelled by {1: 0, 2: 1, 3: 2}
sage: CM = CartanMatrix([[2,-1,-2], [-1,2,-1], [-2,-1,2]])
sage: find_cartan_type_from_matrix(CM)
"""
types = []
for S in CM.dynkin_diagram().connected_components_subgraphs():
S = DiGraph(S) # We need a simple digraph here
n = S.num_verts()
# Build the list to test based upon rank
if n == 1:
types.append(CartanType(['A', 1]))
continue
test = [['A', n]]
if n >= 2:
if n == 2:
test += [['G',2], ['A',2,2]]
test += [['B',n], ['A',n-1,1]]
if n >= 3:
if n == 3:
test.append(['G',2,1])
test += [['C',n], ['BC',n-1,2], ['C',n-1,1]]
if n >= 4:
if n == 4:
test.append(['F',4])
test += [['D',n], ['B',n-1,1]]
if n >= 5:
if n == 5:
test.append(['F',4,1])
test.append(['D',n-1,1])
if n == 6:
test.append(['E',6])
elif n == 7:
test += [['E',7], ['E',6,1]]
elif n == 8:
test += [['E',8], ['E',7,1]]
elif n == 9:
test.append(['E',8,1])
# Test every possible Cartan type and its dual
found = False
for x in test:
ct = CartanType(x)
T = DiGraph(ct.dynkin_diagram()) # We need a simple digraph here
iso, match = T.is_isomorphic(S, certificate=True, edge_labels=True)
if iso:
types.append(ct.relabel(match))
found = True
break
if ct == ct.dual():
continue # self-dual, so nothing more to test
ct = ct.dual()
T = DiGraph(ct.dynkin_diagram()) # We need a simple digraph here
iso, match = T.is_isomorphic(S, certificate=True, edge_labels=True)
if iso:
types.append(ct.relabel(match))
found = True
break
if not found:
return None
return CartanType(types)