本文整理汇总了Python中pydot.graph_from_edges函数的典型用法代码示例。如果您正苦于以下问题:Python graph_from_edges函数的具体用法?Python graph_from_edges怎么用?Python graph_from_edges使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了graph_from_edges函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: modalsmap
def modalsmap(words,conditionals):
'''
given a speech list in the form of {'YOUNG SIWARD': ['What', 'is','thy',
'name','?'], } creates a graphviz map of conditionals per (important)
character
'''
import pydot
all = []
for char, words in conditionals.items():
for word in words:
all.append((char,word[0].lower()))
graphic = pydot.graph_from_edges(all)
for char in conditionals:
new = pydot.Node(char,color='green',shape='doubleoctagon',fontname='Arial',fontsize='12',rank='source', ranksep = '1.2')
graphic.add_node(new)
for char, word in all:
new = pydot.Node(word,color='purple',shape='note',fontname='Arial',fontsize='8')
graphic.add_node(new)
graphic.set_overlap('TRUE')
graphic.set_splines('True')
graphic.set_suppress_disconnected('TRUE')
graphic.write_png('/tmp/test.png',prog='twopi')
开发者ID:deeban25,项目名称:shakespeare,代码行数:27,代码来源:theaterplays.py
示例2: create_node_graph
def create_node_graph(output = "jpg"):
nodes = {}
switch_edge_ports = {}
edge_list = []
for link in discovery.adjacency_list:
node1_name = longlong_to_octstr(link[0])[6:].replace(':','')
node2_name = longlong_to_octstr(link[2])[6:].replace(':','')
nodes[node1_name] = True
nodes[node2_name] = True
edge_list.append((node1_name, node2_name))
switch_edge_ports[(node1_name, node2_name)] = (link[1], link[3])
g = pydot.graph_from_edges(edge_list, directed=True)
# for all edge inferred by discovery, set port labels
for linkt in switch_edge_ports:
edgel = g.get_edge(linkt[0], linkt[1])
if type(edgel) != type([]):
edgel.set('headlabel',str(switch_edge_ports[linkt][1]))
edgel.set('taillabel',str(switch_edge_ports[linkt][0]))
else:
for edge in edgel:
edge.set('headlabel',str(switch_edge_ports[linkt][1]))
edge.set('taillabel',str(switch_edge_ports[linkt][0]))
for node in g.get_node_list():
node.set('style', 'filled,setlinewidth(2)')
node.set('fillcolor', '#ffffcc')
node.set('color', '#99cc99')
node.set('tooltip', 'switch')
return dot_output(g, "pyapps/www/discovery."+output)
开发者ID:09beeihaq,项目名称:Coursera-SDN-Assignments,代码行数:33,代码来源:graph_topology.py
示例3: graph
def graph(x, name=None):
"""Display a directed graph of the Component structure of x
:param x: A Component or Manager to graph
:type x: Component or Manager
:param name: A name for the graph (defaults to x's name)
:type name: str
@return: A directed graph representing x's Component sturcture.
@rtype: str
"""
def getname(c):
return "%s-%s" % (c.name, md5(str(hash(c))).hexdigest()[-4:])
if HAS_PYDOT:
graph_edges = []
for (u, v) in edges(x):
graph_edges.append(("\"%s\"" % getname(u), "\"%s\"" % getname(v)))
g = pydot.graph_from_edges(graph_edges, directed=True)
g.write("%s.dot" % (name or x.name))
g.write("%s.png" % (name or x.name), format="png")
def printer(d, x):
return "%s* %s" % (" " * d, x)
return "\n".join(walk(x, printer))
开发者ID:A-K,项目名称:naali,代码行数:29,代码来源:__init__.py
示例4: graph_to_pydot
def graph_to_pydot(g, **kwds):
""" Return a pydot Graph from a graph.
:Parameters:
- `g`: a graph implementing :class:`openalea.container.interface.graph.IEdgeListGraph` interface.
-`prog`: default is dot. value must one of :
* dot for hierarchical layout of directed graph
* neato and fdp for spring model layouts
* twopi for radial layout
* circo for circular layout
:Returns:
- A pydot graph.
:Examples:
>>> dotg = graph_to_pydot(g)
>>> dotg.write_svg('toto.svg', prog='circo')
"""
edges = set((str(g.source(eid)), str(g.target(eid))) for eid in g.edges())
graph = pydot.graph_from_edges(edges, directed=True)
return graph
开发者ID:MarieLatutu,项目名称:openalea-components,代码行数:27,代码来源:graphviz.py
示例5: makebranchgrapsh
def makebranchgrapsh(data, commdct):
"""return the edges for the all branches"""
allgraphs = []
alledges = []
objkey = 'BRANCH'
cnamefield = "Component %s Name"
inletfield = "Component %s Inlet Node Name"
outletfield = "Component %s Outlet Node Name"
numobjects = len(data.dt[objkey])
cnamefields = loops.repeatingfields(data, commdct, objkey, cnamefield)
inletfields = loops.repeatingfields(data, commdct, objkey, inletfield)
outletfields = loops.repeatingfields(data, commdct, objkey, outletfield)
inlts = loops.extractfields(data, commdct,
objkey, [inletfields] * numobjects)
cmps = loops.extractfields(data, commdct,
objkey, [cnamefields] * numobjects)
otlts = loops.extractfields(data, commdct,
objkey, [outletfields] * numobjects)
zipped = list(zip(inlts, cmps, otlts))
tzipped = [transpose2d(item) for item in zipped]
for i in range(len(data.dt[objkey])):
tt = tzipped[i]
# branchname = data.dt[objkey][i][1]
edges = []
for t0 in tt:
edges = edges + [(t0[0], t0[1]), (t0[1], t0[2])]
g=pydot.graph_from_edges(edges, directed=True)
allgraphs.append(g)
alledges = alledges + edges
return alledges
开发者ID:Nobatek,项目名称:eppy,代码行数:34,代码来源:loopdiagram1.py
示例6: read_graph
def read_graph(fname):
g = pydot.graph_from_edges([])
# g = read_as_info(g, '%s.as_info' % fname)
g = read_edges(g, "%s.edges" % fname)
return g
开发者ID:Benocs,项目名称:core,代码行数:7,代码来源:core-topogen_node_pos.py
示例7: plot2d
def plot2d(g, image_name, scale=None, orientation=90 ):
"""Compute an image of the tree via graphviz.
:Parameters:
- `g` (int) : an MTG object
- `image_name` (str) : output filename e.g. test.png
:Optional parameters:
- `scale` (int): represents the MTG's scale to look at (default max)
- `orientation` (int): orientation angle (default 90)
"""
import pydot
if scale is None:
scale = max(g.scales_iter())
label = g.property('label')
edges = g.iteredges(scale=scale)
if label:
f = lambda id: label.get(id, str(id))
else:
f = str
pydot_graph = pydot.graph_from_edges(((f(x), f(y)) for x, y in g.iteredges(scale=scale)))
# Attributes
pydot_graph.set('orientation', orientation)
ext = os.path.splitext(image_name)[1].strip('.')
return pydot_graph.write(image_name, prog='dot',format=ext)
开发者ID:imane-aanna,项目名称:mtg-1,代码行数:31,代码来源:util.py
示例8: grph
def grph(edges,filename):
g=pydot.graph_from_edges(edges)
if filename:
f = filename + ".svg"
else:
f = "graph.svg"
g.write_svg(f, prog='dot')
开发者ID:vihari,项目名称:tiger-in-python,代码行数:7,代码来源:ast-gen.py
示例9: plot_graph
def plot_graph(rel, file_name):
import pydot # import pydot or you're not going to get anywhere my friend :D
# first you create a new graph, you do that with pydot.Dot()
#graph = pydot.Dot(graph_type='digraph')
graph = pydot.graph_from_edges(rel, directed = True)
graph.write_png(file_name)
开发者ID:dioh,项目名称:arplot,代码行数:8,代码来源:main.py
示例10: showGraph
def showGraph(chunkList): #chunkのリストを受け取って、そこからグラフを表示までやってくれる関数を作る
edges = []
for c in chunkList:
if c.dst != -1:
edges.append((c.getText().encode('utf-8'),chunkList[c.dst].getText().encode('utf-8'))) #cがかかりもと、chunkList[c.dst]がかかり先のchunkインスタンス
g = pydot.graph_from_edges(edges,directed = True)
g.write_jpeg('dot.jpg', prog='dot')
开发者ID:hassyGo,项目名称:NLP100knock2015,代码行数:8,代码来源:q44.py
示例11: graph
def graph(node, filename=None):
edges = descend(node)
g = pydot.graph_from_edges(edges)
if filename is not None:
f = filename + ".png"
else:
f = "graph.png"
g.write(f, prog="dot", format="png")
开发者ID:madcat1991,项目名称:Algol60TinyCompiler,代码行数:8,代码来源:graph.py
示例12: graph
def graph(node, filename):
edges = descend(node)
g=pydot.graph_from_edges(edges)
if filename:
f = filename + ".png"
else:
f = "graph.png"
g.write_png(f, prog='dot')
开发者ID:Mondego,项目名称:pyreco,代码行数:8,代码来源:allPythonContent.py
示例13: make_dot
def make_dot(self):
import pydot
edges = []
for node in self.toplevel_nodes:
for claimed in node.claimed_nodes:
edges.append((str(node), str(claimed)))
g = pydot.graph_from_edges(edges)
g.write_jpeg("graph_from_edges_dot.jpg", prog="dot")
开发者ID:ericholscher,项目名称:allfeeds,代码行数:9,代码来源:social.py
示例14: run
def run():
if len(sys.argv) != 2:
print >> sys.stderr, 'Usage: %s filename' % os.path.basename(sys.argv[0])
return 1
edges = [map(int, l[:-1].split()) for l in open(sys.argv[1])][1:]
g = pydot.graph_from_edges(edges)
basename = sys.argv[1][:sys.argv[1].rfind('.')]
g.write_png(basename + '.png')
开发者ID:Carlovan,项目名称:oii,代码行数:10,代码来源:graph2png.py
示例15: create_graph
def create_graph(edges, seq):
graph = pydot.graph_from_edges(edge_list=edges, directed=True)
# フォント設定
n = pydot.Node("node")
n.fontname = "Osaka.ttf"
n.fontsize = 9
graph.add_node(n)
# グラフを出力
graph.write_png("graph/graph_from_edges_dot_" + str(seq) + ".png", prog="dot")
开发者ID:N4CL,项目名称:NLP100,代码行数:12,代码来源:ch5_44.py
示例16: graph_title
def graph_title(self, title):
s = set()
l = []
for ref in self.refs:
if not ref[0].startswith("%s." % title):
continue
for to in ref[1]:
if not to.startswith("%s." % title):
continue
s.add((ref[0], to))
l.append((ref[0], to))
g = pydot.graph_from_edges(l, directed=True)
#g.write_jpeg("graphs/%s.jpg" % title)
g.write_pdf("graphs/default/%s.pdf" % title)
g = pydot.graph_from_edges(s, directed=True)
#g.write_jpeg("graphs/%s_no_dups.jpg" % title)
g.write_pdf("graphs/no_dups/%s.pdf" % title)
开发者ID:sunlightlabs,项目名称:coleslaw,代码行数:21,代码来源:graph_refs.py
示例17: view_dynkin_diagram
def view_dynkin_diagram(self, action):
"""
Draw the generalized Dynkin diagram associated to the current basis
"""
# TODO:
# 1) dialog to save jpeg file
# 2) better managment of temporary file
nq = self.__app.Groupoid.braid_for_basis(self.__app.Groupoid.Bases[self.__app.Groupoid.CurrentBasis])
nq = triang(self.__app.Groupoid.NumberOfParameters,nq,self.__app.Groupoid.Order)
edges = []
for i in xrange(self.__app.Groupoid.Rank):
edges.append((i+1,i+1))
for j in xrange(i+1,self.__app.Groupoid.Rank):
if notone(self.__app.Groupoid.NumberOfParameters, nq[i][j], self.__app.Groupoid.Order):
edges.append((i+1,j+1))
jpeg=pydot.graph_from_edges(edges)
for i in xrange(self.__app.Groupoid.Rank):
ei = jpeg.get_edge(str(i+1),str(i+1))
ei.set('headlabel',nq[i][i])
ei.set('color','transparent')
for j in xrange(i+1,self.__app.Groupoid.Rank):
try:
eij = jpeg.get_edge(str(i+1),str(j+1))
eij.set_label(nq[i][j])
except:
pass
nl = jpeg.get_node_list()
for n in nl:
n.set('style','filled')
n.set('fillcolor','red')
n.set('shape','circle')
n.set('fixedsize','true')
n.set('width',.3)
jpeg.write_jpeg('dynkin.jpg', prog='neato')
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.set_title('Dynkin diagram')
window.set_resizable(False)
window.set_border_width(10)
vbox = gtk.VBox(False, 0)
window.add(vbox)
vbox.show()
image = gtk.Image()
image.set_from_file("dynkin.jpg")
image.show()
vbox.pack_end(image, True, True, 2)
window.show()
开发者ID:vendramin,项目名称:sarna,代码行数:53,代码来源:GTK_gui.py
示例18: convert_dotlang
def convert_dotlang(tree):
i = 0
root = tree.getroot()
for depend in root.findall('.//dependencies'):
if depend.get('type') == "collapsed-dependencies":
data = []
for dep in depend.findall('dep'):
g = dep.find('governor').text
d = dep.find('dependent').text
data.append((g, d))
g = pydot.graph_from_edges(data)
g.write_jpeg('./fig/sen{}.jpg'.format(i), prog='dot')
i += 1
开发者ID:hassyGo,项目名称:NLP100knock2015,代码行数:13,代码来源:chap6_7.py
示例19: graph
def graph(self):
"""
Returns a pydot.Dot object representing the dependency graph.
Requires pydot to be available.
"""
import pydot
edges = set()
for p in self.packages.values():
for f in p.files:
for id in f.requires:
f2 = self.get(id)
edges.add( ("--".join([p.key, f.shortname]), "--".join([f2.package.key, f2.shortname])) )
return pydot.graph_from_edges(edges, directed=True)
开发者ID:abayer,项目名称:hue,代码行数:13,代码来源:core.py
示例20: draw_knode
def draw_knode(aknode,outfile=''):
"""draw a pretty figure of a knode
"""
import sets,pydot
edges = Edges()
aknode.traverse(edges)
g = pydot.graph_from_edges(edges.edges)
g.add_node(pydot.Node(name='node',color='lightblue2',style='filled'))
g.parent_graph.type = 'digraph'
if outfile == '':
g.write_jpeg('graph_output.jpg', prog='dot')
else:
g.write_jpeg(outfile, prog='dot')
开发者ID:YuJinhui,项目名称:kobas,代码行数:14,代码来源:ktree.py
注:本文中的pydot.graph_from_edges函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论