本文整理汇总了Python中sage.graphs.digraph.DiGraph.plot方法的典型用法代码示例。如果您正苦于以下问题:Python DiGraph.plot方法的具体用法?Python DiGraph.plot怎么用?Python DiGraph.plot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.graphs.digraph.DiGraph
的用法示例。
在下文中一共展示了DiGraph.plot方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot
# 需要导入模块: from sage.graphs.digraph import DiGraph [as 别名]
# 或者: from sage.graphs.digraph.DiGraph import plot [as 别名]
def plot(self, label_elements=True, element_labels=None,
label_font_size=12,label_font_color='black', layout = "acyclic", **kwds):
"""
Returns a Graphics object corresponding to the Hasse diagram.
EXAMPLES::
sage: uc = [[2,3], [], [1], [1], [1], [3,4]]
sage: elm_lbls = Permutations(3).list()
sage: P = Poset(uc,elm_lbls)
sage: H = P._hasse_diagram
sage: levels = H.level_sets()
sage: heights = dict([[i, levels[i]] for i in range(len(levels))])
sage: type(H.plot(label_elements=True))
<class 'sage.plot.graphics.Graphics'>
::
sage: P = Posets.SymmetricGroupBruhatIntervalPoset([1,2,3,4], [3,4,1,2])
sage: P._hasse_diagram.plot()
"""
# Set element_labels to default to the vertex set.
if element_labels is None:
element_labels = range(self.num_verts())
# Create the underlying graph.
graph = DiGraph(self)
graph.relabel(element_labels)
return graph.plot(layout = layout, **kwds)
示例2: plot
# 需要导入模块: from sage.graphs.digraph import DiGraph [as 别名]
# 或者: from sage.graphs.digraph.DiGraph import plot [as 别名]
def plot(self, **kwargs):
"""
Return a graphics object representing the Kontsevich graph.
INPUT:
- ``edge_labels`` (boolean, default True) -- if True, show edge labels.
- ``indices`` (boolean, default False) -- if True, show indices as
edge labels instead of L and R; see :meth:`._latex_`.
- ``upright`` (boolean, default False) -- if True, try to plot the
graph with the ground vertices on the bottom and the rest on top.
"""
if not 'edge_labels' in kwargs:
kwargs['edge_labels'] = True # show edge labels by default
if 'indices' in kwargs:
del kwargs['indices']
KG = DiGraph(self)
for (k,e) in enumerate(self.edges()):
KG.delete_edge(e)
KG.add_edge((e[0], e[1], chr(97 + k)))
return KG.plot(**kwargs)
if len(self.ground_vertices()) == 2 and 'upright' in kwargs:
del kwargs['upright']
kwargs['save_pos'] = True
DiGraph.plot(self, **kwargs)
positions = self.get_pos()
# translate F to origin:
F_pos = vector(positions[self.ground_vertices()[0]])
for p in positions:
positions[p] = list(vector(positions[p]) - F_pos)
# scale F - G distance to 1:
G_len = abs(vector(positions[self.ground_vertices()[1]]))
for p in positions:
positions[p] = list(vector(positions[p])/G_len)
# rotate the vector F - G to (1,0)
from math import atan2
theta = -atan2(positions[self.ground_vertices()[1]][1], positions[self.ground_vertices()[1]][0])
for p in positions:
positions[p] = list(matrix([[cos(theta),-(sin(theta))],[sin(theta),cos(theta)]]) * vector(positions[p]))
# flip if most things are below the x-axis:
if len([(x,y) for (x,y) in positions.values() if y < 0])/len(self.internal_vertices()) > 0.5:
for p in positions:
positions[p] = [positions[p][0], -positions[p][1]]
return DiGraph.plot(self, **kwargs)
示例3: plot
# 需要导入模块: from sage.graphs.digraph import DiGraph [as 别名]
# 或者: from sage.graphs.digraph.DiGraph import plot [as 别名]
def plot(self, **kwds):
"""
EXAMPLES::
sage: X = gauge_theories.threeSU(3)
sage: print X.plot().description()
"""
g = DiGraph(loops=True, sparse=True, multiedges=True)
for G in self._gauge_groups:
g.add_vertex(G)
for field in self._fields:
if isinstance(field, FieldBifundamental):
g.add_edge(field.src, field.dst, field)
if isinstance(field, FieldAdjoint):
g.add_edge(field.node, field.node, field)
return g.plot(vertex_labels=True, edge_labels=True, graph_border=True)
示例4: sageView
# 需要导入模块: from sage.graphs.digraph import DiGraph [as 别名]
# 或者: from sage.graphs.digraph.DiGraph import plot [as 别名]
def sageView(self):
""" Visualise l'arbre dans sage """
from sage.graphs.digraph import DiGraph
g = DiGraph(self.sageGraph())
p = g.plot(layout='tree')
p.show()