本文整理汇总了Python中igraph.Graph.write_dot方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.write_dot方法的具体用法?Python Graph.write_dot怎么用?Python Graph.write_dot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类igraph.Graph
的用法示例。
在下文中一共展示了Graph.write_dot方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: outputDOT
# 需要导入模块: from igraph import Graph [as 别名]
# 或者: from igraph.Graph import write_dot [as 别名]
def outputDOT(self, tree, filename):
root = tree.getroot()
g = Graph(0)
names = list()
self.__drawTree__(root, g, -1, names)
g.vs["label"] = names
layout = g.layout("tree")
visual_style = {}
visual_style["vertex_size"] = [20] * g.vcount()
visual_style["vertex_color"] = ["white"] * g.vcount()
visual_style["vertex_label"] = g.vs["label"]
visual_style["edge_width"] = [1] * g.vcount()
visual_style["layout"] = layout
visual_style["bbox"] = (2000, 900)
visual_style["margin"] = 50
visual_style["vertex_label_angle"] = [3 * math.pi / 2] * g.vcount()
visual_style["vertex_label_size"] = [10] * g.vcount()
g.write_dot(filename)
示例2: __init__
# 需要导入模块: from igraph import Graph [as 别名]
# 或者: from igraph.Graph import write_dot [as 别名]
class Robot:
def __init__(self):
self.br = mechanize.Browser(factory=mechanize.RobustFactory())
self.br.set_handle_robots(False)
self.br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008\
071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]
self.graph = Graph(0, directed=True)
self.urls = {}
self.path = []
def draw(self, file_name):
self.graph.write_dot(file_name)
def add_node(self):
if self.br.viewing_html():
url = self.br.response().geturl()
title=self.br.title()
salida=open('salida3.txt','a')
if url not in self.urls:
node_label = len(self.graph.vs)
output=str(node_label)+"; "+str(title)+"; "+str(url)
print output
salida.write(output+'\n')
self.urls[url] = node_label
self.graph.add_vertices(1)
else:
node_label = self.urls[url]
self.path.append(node_label)
if len(self.path) > 2:
self.graph.add_edges([(self.path[-2], self.path[-1])])
print self.path[-2], '->', self.path[-1]
salida.write(str(self.path[-2])+', ->'+str(self.path[-1])+' \n')
salida.close()
def browse(self, url, n):
self.br.open(url)
self.add_node()
self.visit_node(n)
def visit_node(self, n):
prettify(self.br, self.br.response(), 'UTF-8')
self.add_node()
content(self.br, self.br.response())
if n > 1:
for link in self.br.links():
if link.url not in self.urls:
#print str(link.url)
#print "ojo"
if "wiki" in str(link.url) and not "#cite_" in str(link.url) and not "action=edit" in str(link.url):
#print link.url
#print "pes"
if self.br.viewing_html():
try:
self.br.follow_link(link)
self.visit_node(n-1)
except:
pass
if self.path:
self.path.pop()
if len(self.br._history._history[:]) > 0:
self.br.back()