当前位置: 首页>>代码示例>>Python>>正文


Python Graph.view方法代码示例

本文整理汇总了Python中graphviz.Graph.view方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.view方法的具体用法?Python Graph.view怎么用?Python Graph.view使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在graphviz.Graph的用法示例。


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

示例1: main

# 需要导入模块: from graphviz import Graph [as 别名]
# 或者: from graphviz.Graph import view [as 别名]
def main():
    SIZE = 20
    PLOIDY = 2
    MUTATIONS = 2

    indices = range(SIZE)
    # Build fake data
    seqA = list("0" * SIZE)
    allseqs = [seqA[:] for x in range(PLOIDY)]  # Hexaploid
    for s in allseqs:
        for i in [choice(indices) for x in range(MUTATIONS)]:
            s[i] = "1"

    allseqs = [make_sequence(s, name=name) for (s, name) in \
                zip(allseqs, [str(x) for x in range(PLOIDY)])]

    # Build graph structure
    G = Graph("Assembly graph", filename="graph")
    G.attr(rankdir="LR", fontname="Helvetica", splines="true")
    G.attr(ranksep=".2", nodesep="0.02")
    G.attr('node', shape='point')
    G.attr('edge', dir='none', penwidth='4')

    colorset = get_map('Set2', 'qualitative', 8).mpl_colors
    colorset = [to_hex(x) for x in colorset]
    colors = sample(colorset, PLOIDY)
    for s, color in zip(allseqs, colors):
        sequence_to_graph(G, s, color=color)
    zip_sequences(G, allseqs)

    # Output graph
    G.view()
开发者ID:tanghaibao,项目名称:jcvi,代码行数:34,代码来源:graph.py

示例2: __init__

# 需要导入模块: from graphviz import Graph [as 别名]
# 或者: from graphviz.Graph import view [as 别名]
class render:

	def __init__(self,our_graph,wt_dist,colour_list,tup=[-1,-1]):
		self.G = Graph(format='png')
		self.edgeList = []
		#i=0

		
		for vertex in our_graph.vertList:
			self.G.node(str(vertex),label='INF' if wt_dist[vertex]==10000000 else str(wt_dist[vertex]),color='red' if colour_list[vertex] else 'black')
			for adjvertices in our_graph.vertList[vertex].connectedTo:
				if tup==[vertex,adjvertices] or tup==[adjvertices,vertex]: 
					cl='green'  
				else: 
					cl='black'

				#print vertex.connectedTo[adjvertices] 
				if our_graph.vertList[vertex].connectedTo[adjvertices][1] in self.edgeList:
					pass
				else:
					self.G.edge(str(vertex),str(adjvertices),str(our_graph.vertList[vertex].connectedTo[adjvertices][0]),color=cl)
					self.edgeList.append(our_graph.vertList[vertex].connectedTo[adjvertices][1])
			#self.G.edge(str(vertex),str((vertex+1)%10),label='edge',color='green')


		self.G.view()
开发者ID:seshagiri96,项目名称:graphVisualization,代码行数:28,代码来源:render.py

示例3: graph_draw

# 需要导入模块: from graphviz import Graph [as 别名]
# 或者: from graphviz.Graph import view [as 别名]
def graph_draw(nodes, edges, name):
    g = Graph(name, format="png")
    for node in nodes:
        g.node(str(node))
    for edge in edges:
        x = edge.split(' ')[0]
        y = edge.split(' ')[1]
        g.edge(x, y)
    g.view()
开发者ID:AntonBobrovsky,项目名称:modeling,代码行数:11,代码来源:lab2.py

示例4: renderiza_grafo

# 需要导入模块: from graphviz import Graph [as 别名]
# 或者: from graphviz.Graph import view [as 别名]
 def renderiza_grafo(self, lugar_para_gerar, nome_grafo):
     A = Graph(comment=nome_grafo, filename=(lugar_para_gerar + '/Grafo.gv'), engine='dot')
     for vertice in self.meuGrafo.nodes_iter(data=False):
         A.node(vertice.encode("utf8"))
     for aresta_A, aresta_B, dados_aresta in self.meuGrafo.edges_iter(data=True):
         peso_aresta = dict((chave, str(valor)) for chave, valor in dados_aresta.items())
         peso_aresta['label'] = peso_aresta['weight']
         del peso_aresta['weight']
         A.edge(aresta_A, aresta_B, **peso_aresta)
     A.view()
开发者ID:fernandopasse,项目名称:grafos_capitais,代码行数:12,代码来源:Grafo.py

示例5: outputToPdf

# 需要导入模块: from graphviz import Graph [as 别名]
# 或者: from graphviz.Graph import view [as 别名]
def outputToPdf(graph, fileName,sourceLables):
    e = Graph('NYC', filename=fileName, engine='dot')
    e.body.extend(['rankdir=LR', 'size="100,100"'])
    e.attr('node', shape='ellipse')
    e.attr("node",color='green', style='filled')
    edgeExists={}
    for label in sourceLables:
        e.node(str(label))
    e.attr("node",color='lightblue2', style='filled')
    for node in graph.nodeIter():
        for edge in node.neighborsIter():
            if not edge[1] in edgeExists:
                e.attr("edge",labelcolor="blue")
                e.edge(str(node.label()),edge[1],str(int(edge[0]))+"m")
        edgeExists[node.label()]=1
    edgeExists=None

    e.body.append(r'label = "\nIntersections in New York City\n"')
    e.body.append('fontsize=100')
    e.view()
开发者ID:mchaiken,项目名称:CS136_finalProject,代码行数:22,代码来源:Main.py

示例6: gen_graph_from_nodes

# 需要导入模块: from graphviz import Graph [as 别名]
# 或者: from graphviz.Graph import view [as 别名]
def gen_graph_from_nodes(nodes, type_fail=None):
    graph = Graph(format='png', strict=True)
    graph.node_attr['fontname'] = 'Courier New'
    graph.edge_attr['fontname'] = 'Courier New'
    for node in nodes:
        graph.node(_type_str(node.type),
                   '{type: %s|ast_node: %s|parent\'s type: %s}' %
                   (_type_str(node.type),
                    node.ast_node.as_string().replace('<', '\\<').replace('>', '\\>')
                        if node.ast_node else 'None',
                    _type_str(node.parent.type) if node.parent else 'NA'),
                   shape='record', style='rounded')
        for neighb, ctx_node in node.adj_list:
            graph.edge(_type_str(node.type), _type_str(neighb.type),
                       label=(f' {ctx_node.as_string()}' if ctx_node else ''))
    if type_fail:
        graph.node('tf',
                   '{TypeFail|src_node: %s}' %
                   (type_fail.src_node.as_string().replace('<', '\\<').replace('>', '\\>')
                        if type_fail.src_node else 'None'), shape='record')
        graph.edge('tf', _type_str(type_fail.tnode1.type), style='dashed')
        graph.edge('tf', _type_str(type_fail.tnode2.type), style='dashed')
    graph.view('tnode_graph')
开发者ID:pyta-uoft,项目名称:pyta,代码行数:25,代码来源:draw_tnodes.py

示例7: Graph

# 需要导入模块: from graphviz import Graph [as 别名]
# 或者: from graphviz.Graph import view [as 别名]
#!/usr/bin/env python
# process.py - http://www.graphviz.org/content/process

from graphviz import Graph

g = Graph('G', filename='process.gv', engine='sfdp')

g.edge('run', 'intr')
g.edge('intr', 'runbl')
g.edge('runbl', 'run')
g.edge('run', 'kernel')
g.edge('kernel', 'zombie')
g.edge('kernel', 'sleep')
g.edge('kernel', 'runmem')
g.edge('sleep', 'swap')
g.edge('swap', 'runswap')
g.edge('runswap', 'new')
g.edge('runswap', 'runmem')
g.edge('new', 'runmem')
g.edge('sleep', 'runmem')

g.view()
开发者ID:alorenzo175,项目名称:graphviz,代码行数:24,代码来源:process.py

示例8:

# 需要导入模块: from graphviz import Graph [as 别名]
# 或者: from graphviz.Graph import view [as 别名]
e.attr('node', shape='ellipse')
e.node('name0', label='name')
e.node('name1', label='name')
e.node('name2', label='name')
e.node('code')
e.node('grade')
e.node('number')

e.attr('node', shape='diamond', style='filled', color='lightgrey')
e.node('C-I')
e.node('S-C')
e.node('S-I')

e.edge('name0', 'course')
e.edge('code', 'course')
e.edge('course', 'C-I', label='n', len='1.00')
e.edge('C-I', 'institute', label='1', len='1.00')
e.edge('institute', 'name1')
e.edge('institute', 'S-I', label='1', len='1.00')
e.edge('S-I', 'student', label='n', len='1.00')
e.edge('student', 'grade')
e.edge('student', 'name2')
e.edge('student', 'number')
e.edge('student', 'S-C', label='m', len='1.00')
e.edge('S-C', 'course', label='n', len='1.00')

e.attr(label=r'\n\nEntity Relation Diagram\ndrawn by NEATO')
e.attr(fontsize='20')

e.view()
开发者ID:xflr6,项目名称:graphviz,代码行数:32,代码来源:er.py

示例9: plot

# 需要导入模块: from graphviz import Graph [as 别名]
# 或者: from graphviz.Graph import view [as 别名]
    def plot(self):
        g = Graph(format='png')
        styles = {
            'graph': {
                'rankdir': self.direction,
                'splines': 'line',
                'label': 'Restricted Boltzmann Machine',
                'labelloc': 't', ## t: top, b: bottom, c: center
                'labeljust': 'c', ## l: left, r: right, c: center
            },
            'edge':{
                'color': 'black',
                # 'constraint': 'false',
                'style': 'filled',
            }
        }
        self.add_styles(g, styles)

        vLayer = Graph('cluster_0')
        styles = {
            'graph': {
                'rankdir': 'LR',
                'splines': 'line',
                'label': 'Visible Units',
                'labelloc': 't', ## t: top, b: bottom, c: center
                'labeljust': 'c', ## l: left, r: right, c: center
            },
            'node': {
                'shape': 'circle',
                'color': 'lightblue3',
                'label': '',
            },
            'edge':{
                'color': 'black',
                'constraint': 'false',
                'style': 'filled',
            }
        }
        self.add_styles(vLayer, styles)
        vNodes = ['v%d'%i for i in range(self.numVisible)]
        vNodes[-2] = (vNodes[-2], {'label': '...', 'style': '', 'shape': 'circle', 'color':'white'})
        self.add_nodes(vLayer, vNodes)


        hLayer = Graph('cluster_1')
        styles = {
            'graph': {
                'rankdir': 'LR',
                'splines': 'line',
                'label': 'Hidden Units',
                'labelloc': 'b', ## t: top, b: bottom, c: center
                'labeljust': 'c', ## l: left, r: right, c: center
            },
            'node': {
                'shape': 'circle',
                'color': 'red3',
                'label': '',
            },
            'edge':{
                'color': 'black',
                'constraint': 'false',
                'style': 'filled',
            }
        }
        self.add_styles(hLayer, styles)
        hNodes = ['h%d'%i for i in range(self.numHidden)]
        hNodes[-2] = (hNodes[-2], {'label': '...', 'style': '', 'shape': 'circle', 'color':'white'})
        self.add_nodes(hLayer, hNodes)

        g.subgraph(hLayer)
        g.subgraph(vLayer)
        edges = []
        for vn in vNodes:
            for hn in hNodes:
                if isinstance(vn, tuple):
                    if isinstance(hn, tuple):
                        edges.append(((vn[0], hn[0]), {'style':'invis'}))
                    else:
                        edges.append(((vn[0], hn), {'style': 'invis'}))
                else:
                    if isinstance(hn, tuple):
                        edges.append(((vn, hn[0]), {'style':'invis'}))
                    else:
                        edges.append((vn, hn))
        self.add_edges(g, edges)
        print (g.source)
        g.view()
开发者ID:AlgorithmFan,项目名称:PlotNeuralNetwork,代码行数:89,代码来源:RBM.py

示例10: print

# 需要导入模块: from graphviz import Graph [as 别名]
# 或者: from graphviz.Graph import view [as 别名]
from graphviz import Graph
import pandas as pd
from os.path import join


my_dir = 'C:\\Users\\John\\Documents\\2016\\Python\\JiraStates'
full_jira_df = pd.read_csv(join(my_dir, 'jira_states.csv'))
# print(df)

issue_list = pd.Series.unique(full_jira_df["IssueNo"])
print(issue_list)



mygraph = Graph('ER', filename='test.gv', engine='circo')

# FIRST SET UP THE NODES
mygraph.attr('node', shape='ellipse', width='10')
mygraph.node('name0', label='name', color='red', width='10')
mygraph.node('name1', label='name')


#NOW JOIN THE NODES WITH EDGES
mygraph.edge('name0', 'name1', color='blue', dir='forward', edgetooltip='a tool tip')



#FINALLY DISPLAY THE GRAPH
mygraph.view()
开发者ID:johnstinson99,项目名称:JiraGraphCreator,代码行数:31,代码来源:test.py


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