本文整理汇总了Python中sage.graphs.graph.Graph.is_connected方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.is_connected方法的具体用法?Python Graph.is_connected怎么用?Python Graph.is_connected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.graphs.graph.Graph
的用法示例。
在下文中一共展示了Graph.is_connected方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: is_connected
# 需要导入模块: from sage.graphs.graph import Graph [as 别名]
# 或者: from sage.graphs.graph.Graph import is_connected [as 别名]
def is_connected(self, force_computation=False):
if not force_computation and self._connected:
return True
from sage.graphs.graph import Graph
G = Graph(loops=True, multiedges=True)
for i in xrange(self._total_darts):
if self._active_darts[i]:
G.add_edge(i,self._vertices[i])
G.add_edge(i,self._edges[i])
G.add_edge(i,self._faces[i])
return G.is_connected()
示例2: _check
# 需要导入模块: from sage.graphs.graph import Graph [as 别名]
# 或者: from sage.graphs.graph.Graph import is_connected [as 别名]
def _check(self):
r"""
Check that the data of the Ribbon graph is coherent
"""
from sage.graphs.graph import Graph
G = Graph()
if len(self._active_darts) != self._total_darts:
raise ValueError, "the length of active darts is not total_darts"
if self._active_darts.count(True) != self._num_darts:
raise ValueError, "the number of darts do not coincide with active darts"
for i in xrange(self._total_darts):
if self._active_darts[i]:
G.add_edge(i,self._vertices[i])
G.add_edge(i,self._edges[i])
G.add_edge(i,self._faces[i])
if self._vertices[i] is None or self._vertices_inv[i] is None:
raise ValueError, "dart %d is active but has no vertex" %i
if self._edges[i] is None or self._edges_inv[i] is None:
raise ValueError, "dart %d is active but has no edge" %i
if self._faces[i] is None or self._faces_inv[i] is None:
raise ValueError, "dart %d is active but has no face" %i
if self._vertices[self._vertices_inv[i]] != i:
raise ValueError, "vertices is not the inverse of vertices_inv"
if self._edges[self._edges_inv[i]] != i:
raise ValueError, "edges is not the inverse of edges_inv"
if self._faces[self._faces_inv[i]] != i:
raise ValueError, "faces is not the inverse of faces_inv"
if self._faces[self._edges[self._vertices[i]]] != i:
raise ValueError, "the Ribbon graph condition vef=() is not satisfied for %d" %i
if self._edges[i] == i or self._edges[self._edges[i]] != i:
raise ValueError, "edges is not an involution without fixed point for %d" %i
else:
if self._vertices[i] is not None or self._vertices_inv[i] is not None:
raise ValueError, "dart %d is not active but has a vertex" %i
if self._edges[i] is not None or self._edges_inv[i] is not None:
raise ValueError, "dart %d is not active but has an edge" %i
if self._faces[i] is not None or self._faces_inv[i] is not None:
raise ValueError, "dart %d is not active but has a face" %i
if not G.is_connected():
raise ValueError, "the graph is not connected"