當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。