• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python dot.write函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pygraph.readwrite.dot.write函数的典型用法代码示例。如果您正苦于以下问题:Python write函数的具体用法?Python write怎么用?Python write使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了write函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: write_graphs_to_dots

    def write_graphs_to_dots(self):
        assert self.build_graph
        self._load_packages()

        from pygraph.readwrite import dot

        base = self.output_dir

        with open(join(base, 'digraph.dot'), 'w') as f:
            data = dot.write(self.digraph)
            f.write(data)

        with open(join(base, 'bfs.dot'), 'w') as f:
            (st, order) = breadth_first_search(self.digraph)
            bfs = digraph()
            bfs.add_spanning_tree(st)
            data = dot.write(bfs)
            f.write(data)

        with open(join(base, 'dfs.dot'), 'w') as f:
            (st, pre, post) = depth_first_search(self.digraph)
            dfs = digraph()
            dfs.add_spanning_tree(st)
            data = dot.write(dfs)
            f.write(data)
开发者ID:Studiogit,项目名称:conda,代码行数:25,代码来源:cran.py


示例2: test_dot_for_hypergraph

 def test_dot_for_hypergraph(self):
     gr = testlib.new_hypergraph()
     dotstr = dot.write(gr)
     gr1 = dot.read_hypergraph(dotstr)
     dotstr = dot.write(gr1)
     gr2 = dot.read_hypergraph(dotstr)  
     graph_equality(gr1, gr2)
开发者ID:soeltjen,项目名称:python-graph,代码行数:7,代码来源:unittests-readwrite.py


示例3: test_dot_for_digraph

 def test_dot_for_digraph(self):
     gr = testlib.new_digraph()
     dotstr = dot.write(gr)
     gr1 = dot.read(dotstr)
     dotstr = dot.write(gr1)
     gr2 = dot.read(dotstr)  
     graph_equality(gr1, gr2)
     assert len(gr.nodes()) == len(gr1.nodes())
     assert len(gr.edges()) == len(gr1.edges())
开发者ID:soeltjen,项目名称:python-graph,代码行数:9,代码来源:unittests-readwrite.py


示例4: test_output_names_in_dot

 def test_output_names_in_dot(self):
     gr1 = testlib.new_graph()
     gr1.name = "Some name 1"
     gr2 = testlib.new_digraph()
     gr2.name = "Some name 2"
     gr3 = testlib.new_hypergraph()
     gr3.name = "Some name 3"
     assert "Some name 1" in dot.write(gr1)
     assert "Some name 2" in dot.write(gr2)
     assert "Some name 3" in dot.write(gr3)
开发者ID:soeltjen,项目名称:python-graph,代码行数:10,代码来源:unittests-readwrite.py


示例5: run

	def run(self):
		#print "save graph in dir"
		gr = digraph()
		for x in self.nodes:
			gr.add_node(x.name)
		
		for x in self.nodes:
			x.addEdges(gr)
		
		dirLck.acquire()
		if not os.path.isdir(self.dir):
			if -1 == os.getcwd().find(self.dir):
				os.mkdir(self.dir)
		dirLck.release()
			
		if -1 == os.getcwd().find(self.dir):
			os.chdir(self.dir)

		dot = write(gr)
		f = open(self.filename, 'w')
		f.write(dot)
		f.close()

		proc = subprocess.Popen('dot -Tjpg ' + self.filename +' -o ' +  self.filename + '.jpg', shell=True, stdout=subprocess.PIPE,)
		r = proc.communicate()[0]
		print ""
开发者ID:burner,项目名称:probabilisticGuess,代码行数:26,代码来源:Graph.py


示例6: draw

    def draw(self, filename):
        print "initial state:", self.initial_state
        print "final states", self.final_state	
        print "transition table:", self.transition_table 

        vertexes = self.transition_table.keys()
        edges = self._edges()

        gr = digraph()        
        #gr.add_nodes([str(vertex) for vertex in vertexes])
        for vertex in vertexes:
            attrs = []
            
            if ((isinstance(self.final_state, list) and vertex in self.final_state) or
                    (isinstance(self.final_state, int) and vertex == self.final_state)):
                attrs.append('final')
            gr.add_node(str(vertex), attrs=attrs)

        for edge, label in edges.items():
            label = ', '.join(label)
            gr.add_edge(edge=edge, label=label)

        dot = write(gr)
        gvv = gv.readstring(dot)
        gv.layout(gvv, 'dot')
        gv.render(gvv, 'png', '%s.png' % filename)
开发者ID:afrolovskiy,项目名称:compilers_labs,代码行数:26,代码来源:fa.py


示例7: drawGraph

 def drawGraph(self, inputs):
     
     fileName = 'planetModel.png'
     gr = graph()
     self.addGraphNode(1,gr, inputs)
 # Draw as PNG
     #with open("./planetModel.viz", 'wb') as f:
         #dot = write(gr,f)
         #f.write(dot)
         #gvv = gv.readstring(dot)
         #gv.layout(gvv,'dot')
         #gv.render(gvv,'png', fileName)
         #f.close()
         
     gst = digraph()
     self.addGraphNode(1,gst, inputs)            
     with open("./planetModel.viz", 'wb') as f:            
         #st, order = breadth_first_search(gst, root=1)
         #gst2 = digraph()
         #gst2.add_spanning_tree(gst.nodes())
         #gst2.(1, 'post')
         dot = write(gst,f)
         f.write(dot)
         gvv = gv.readstring(dot)
         gv.layout(gvv,'dot')
         gv.render(gvv,'png', fileName)   
         f.close()         
         
         
          
     return fileName
开发者ID:jsrawan-mobo,项目名称:mrbigdata,代码行数:31,代码来源:planetModel.py


示例8: GraficarGrafo

	def GraficarGrafo(self, grafo, proy):
		grafof = self.GraficoProyecto(proy)
		dot = write(grafof)
		_gvv = _gv.readstring(dot)
		_gv.layout(_gvv,'dot')
		_gv.render(_gvv,'png',"sgs/public/images/grafo.png")
		return dict()
开发者ID:majito,项目名称:is2grupo06,代码行数:7,代码来源:item.py


示例9: graph_to_file

def graph_to_file(graph, filename='graph.png', delete_single=False):
    """Exports a graph to a image file.

    Params:
    graph - The graph to export.
    filename - The destination of the output. The filename should
               include an extention, the format of the file will always
               be PNG no matter what the extention is.
    delete_single - If set to true then all nodes without any neighbours
                    will be deleted prior to exporting the graph.
    """
    logger = logging.getLogger('.'.join((__name__, 'graph_to_file')))
    logger.info("Exporting a graph to %s", filename)

    # Delete nodes that don't have any neighbours
    if delete_single:
        del_nodes = [node for node in graph.nodes() if not graph.neighbors(node)]
        logger.info("Deleting %d nodes without neighbours", len(del_nodes))
        for node in del_nodes:
            graph.del_node(node)

    # Write the graph
    dot = graphtodot.write(graph)
    gvgraph = graphviz.graph_from_dot_data(dot)
    gvgraph.write(filename, format='png')
开发者ID:XeryusTC,项目名称:mapbots,代码行数:25,代码来源:exportimage.py


示例10: plot_graph

def plot_graph(gr):
    """
    draws the graph to file
    """
    p = 100.0 / (len(gr.nodes())+1)
    gr_ext = graph()

    
    for node in gr.nodes():
        if coin(p):
            if not gr_ext.has_node(node):
                gr_ext.add_node(node,attrs=gr.node_attributes(node))
            for n in [ ed[0] for ed in gr.edges() if ed[1] == node ]:
                if coin(0.3):
                    if not gr_ext.has_node(n):
                        gr_ext.add_node(n,attrs=gr.node_attributes(n))
                    #print "Edges:",gr_ext.edges()
                    if not gr_ext.has_edge((node,n)):
                        gr_ext.add_edge((node,n)) 
    dot = write(gr_ext)
    gvv = gv.readstring(dot)
    gv.layout(gvv,'dot')    
    if args[1]== 'karate.txt':
        gv.render(gvv,'png','community1.png') 
    elif args[1] == 'email.txt':
        gv.render(gvv,'png','community2.png')
    elif args[1] == 'hep-th-citations.txt':
        gv.render(gvv,'png','community3.png')
    elif args[1] == 'amazon1.txt':
        gv.render(gvv,'png','community4.png')
    elif args[1] == 'p2p-Gnutella30.txt':
        gv.render(gvv,'png','community5.png')
开发者ID:sarojinigarapati,项目名称:community-detection,代码行数:32,代码来源:main1.py


示例11: drawGraphFromSM

def drawGraphFromSM(SM, names, outFile):
	fig = plt.figure(1)
	plot1 = plt.imshow(SM, origin='upper', cmap=cm.gray, interpolation='nearest')
	plt.show()
		
	gr = graph()

	namesNew = []
	for i,f in enumerate(names):	
		if sum(SM[i,:])>0:
			gr.add_nodes([f])
			namesNew.append(f)
			
	Max = SM.max()
	Mean = mean(SM)

	Threshold = Mean * 1.5
	for i in range(len(names)):
		for j in range(len(names)):
			if i<j:
				if SM[i][j] > 0:
					gr.add_edge((names[i], names[j]))
	# Draw as PNG
	dot = write(gr)
	gvv = gv.readstring(dot)
	gv.layout(gvv,'dot')
	gv.render(gvv,'png', outFile)
开发者ID:tyiannak,项目名称:pyOpenAireTextClassifier,代码行数:27,代码来源:textFeatureExtraction.py


示例12: pruner_bakeoff

def pruner_bakeoff(nPoints, nSeeds, r0, delta, spread, lumpage, outputNameRoot):
    """
    Generate a graph, then use all the CANDIDATE_PRUNERS to prune it, and save the results for later investigation.
    """
    from spiralPointDistribution import spiralPointDistribution
    from pointsToOutwardDigraph import graphFromPoints
    #import matplotlib.pyplot as plot
    #import matplotlib.tri as tri    
    import pygraph.readwrite.dot as dotIO
    
    points = spiralPointDistribution(nPoints, nSeeds, r0, delta, spread, lumpage)
    
    outdir = os.path.dirname(outputNameRoot)
    if not os.path.exists(outdir):
        os.makedirs(outdir)
    
    #x, y = zip(*points)
    #plot.figure()
    #plot.gca().set_aspect('equal')
    #plot.triplot(tri.Triangulation(x, y), 'r,:')
    #plot.scatter(x, y)
    #plot.show()
    
    #NOT YET FINISHED
    #save png as outputNameRoot.prunerName.png (once I get Python graphviz bindings working)
    
    for pruner in CANDIDATE_PRUNERS:
        graph = graphFromPoints(points, nSeeds)
        graph = friendly_rename(graph)
        graph = pruner.prune(graph)
        dotstring = dotIO.write(graph)
        dotname = "{0}.{1}.gv".format(outputNameRoot, pruner.__class__.__name__)
        with open(dotname, "w") as dotfile:
            dotfile.write(dotstring)
开发者ID:BackupGGCode,项目名称:fake-data-generator,代码行数:34,代码来源:candidate_test_pruners.py


示例13: main

def main(args):
    g = generate(args.nodes, args.edges, True)

    while not find_cycle(g):
        g = generate(args.nodes, args.edges, True)

    with open(args.output, 'w') as f:
        f.write(write(g))
开发者ID:sash-ko,项目名称:graph-cd,代码行数:8,代码来源:generate_random.py


示例14: draw_pretty

def draw_pretty(pl, output_filename):
    gr = pygraph_build_pipeline_graph(pl)
    dot = write(gr)

    G = pgv.AGraph(dot, name=pl.name)
    prettify_graph(pl, G)
    G.layout(prog='dot')
    G.draw(output_filename)
开发者ID:mrmh2,项目名称:impip,代码行数:8,代码来源:plotpipe.py


示例15: save_as_pdf

def save_as_pdf(gr,filename,show_weights=False):

    from pygraph.readwrite.dot import write
    import gv
    dot = write(gr, weighted=show_weights)
    gvv = gv.readstring(dot)
    gv.layout(gvv,'fdp')
    gv.render(gvv,'pdf',filename)
开发者ID:Derano,项目名称:PCV,代码行数:8,代码来源:graphcut.py


示例16: handle

    def handle(self, **options):
        gr = graph()

        cats_by_id = dict((c.id, c) for c in Category.objects.all())

        # Add nodes
        dups = count()
        for c in cats_by_id.itervalues():
            try:
                gr.add_node(c)
            except AdditionError:
                dups.next()
                parent = cats_by_id.get(c.parent_id)
                print 'WARNING: duplicate node :: <Category %i | %s>' % (c.id, c)
                print '\twith parent ' + '<Category %i | %s>' % (parent.id, parent) if parent else 'None'

        if dups.next() > 0: return

        # Add edges
        # gr.add_edge((CONCRETE_NODE, ROOT_NODE))
        for c in cats_by_id.itervalues():
            parent = cats_by_id.get(c.parent_id)
            if parent:
                gr.add_edge((c, parent))

        # import ipdb; ipdb.set_trace()
        # The whole tree from the root
        st, order = breadth_first_search(gr, root=Category.objects.get(title="Abstract"))
        gst = digraph()
        gst.add_spanning_tree(st)

        dot = write(gst)
        gvv = gv.readstring(dot)

        gv.layout(gvv, 'dot')
        gv.render(gvv, 'pdf', os.path.join(output_dir, 'abstract.pdf'))

        st, order = breadth_first_search(gr, root=Category.objects.get(title="Concrete"))
        gst = digraph()
        gst.add_spanning_tree(st)

        dot = write(gst)
        gvv = gv.readstring(dot)

        gv.layout(gvv, 'dot')
        gv.render(gvv, 'pdf', os.path.join(output_dir, 'concrete.pdf'))
开发者ID:danbretl,项目名称:mid-tier,代码行数:46,代码来源:graphcategories.py


示例17: search

 def search(self):
     st, order = breadth_first_search(self.net, "book")
     gst = digraph()
     gst.add_spanning_tree(st)
     dot = write(gst, True)
     out_file = open("file.gv", "w")
     out_file.write(dot)
     out_file.close()
开发者ID:alessioferrari,项目名称:workspaceAmbiguityDetection,代码行数:8,代码来源:SentenceNetVisitor.py


示例18: draw_graph

 def draw_graph(self):
     dot = write(self.graph)
     f = open('currencies.dot', 'a')
     f.write(dot)
     f.close()
     command = '/usr/local/bin/dot -Tpng currencies.dot > currencies.png'
     print "Generating graph with %s" % command
     os.system(command)
开发者ID:wzin,项目名称:crypto-trader,代码行数:8,代码来源:trader.py


示例19: sample_gene_interactions

def sample_gene_interactions(c, args, idx_to_sample):
    #fetch variant gene dict for all samples
    get_variant_genes(c, args, idx_to_sample)
    #file handle for fetching the hprd graph
    file_graph = os.path.join(path_dirname, 'hprd_interaction_graph')
    #load the graph using cPickle and close file handle
    gr = graph()
    f = open(file_graph, 'rb')
    gr = cPickle.load(f)
    f.close()
    k = []
    variants = []
    #calculate nodes from the graph
    hprd_genes = gr.nodes()
    if args.gene == None or args.gene not in hprd_genes:
        sys.stderr.write("gene name not given else not represented in the p-p interaction file\n")
    elif args.gene in hprd_genes:
        x, y = \
            breadth_first_search(gr,root=args.gene,filter=radius(args.radius))
        gst = digraph()
        gst.add_spanning_tree(x)
        dot = write(gst)
        out.write(dot)
        st, sd = shortest_path(gst, args.gene)
        
        if args.var_mode:
            for sample in sam.iterkeys():
                var = sam[str(sample)]
                #for each level return interacting genes if they are 
                # variants in the sample. 
                # 0th order would be returned if the user chosen 
                # gene is a variant in the sample        
                for x in range(0, (args.radius+1)):
                    for each in var:
                        for key, value in sd.iteritems():
                            if value == x and key == each[0]:
                                print "\t".join([str(sample),str(args.gene), \
                                          str(x), \
                                          str(key), \
                                          str(each[1]), \
                                          str(each[2]), \
                                          str(each[3])])        
        elif (not args.var_mode):
            for sample in sam.iterkeys():
                for each in sam[str(sample)]:
                    variants.append(each[0])
                for x in range(0, (args.radius+1)):
                    for key, value in sd.iteritems():
                        if value == x and key in set(variants):
                            k.append(key)
                    if k:
                        print "\t".join([str(sample), str(args.gene), \
                                 str(x)+"_order:", 
                                 ",".join(k)])
                    else:
                        print "\t".join([str(sample), str(args.gene), str(x)+"_order:", "none"])
                    #initialize keys for next iteration
                    k = []
开发者ID:hjanime,项目名称:gemini,代码行数:58,代码来源:tool_interactions.py


示例20: _dep_graph_dump

def _dep_graph_dump(dgr, filename):
    """Dump dependency graph to file, in specified format."""
    # write to file
    dottxt = dot.write(dgr)
    if os.path.splitext(filename)[-1] == '.dot':
        # create .dot file
        write_file(filename, dottxt)
    else:
        _dep_graph_gv(dottxt, filename)
开发者ID:jgphpc,项目名称:easybuild-framework,代码行数:9,代码来源:tools.py



注:本文中的pygraph.readwrite.dot.write函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pygraphviz.AGraph类代码示例发布时间:2022-05-25
下一篇:
Python hypergraph.hypergraph函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap