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


Python Graph.node方法代码示例

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


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

示例1: __init__

# 需要导入模块: from graphviz import Graph [as 别名]
# 或者: from graphviz.Graph import node [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

示例2: graph_data

# 需要导入模块: from graphviz import Graph [as 别名]
# 或者: from graphviz.Graph import node [as 别名]
def graph_data(pkg_name):
    if not pkg_name:
        abort(404)

    filepath = os.path.join(cache_dir, pkg_name.lower())
    if not os.path.exists(filepath + '.png'):
        nodes, edges = reqs_graph(pkg_name)

        if not nodes:
            return redirect(url_for('static', filename='img/blank.png'))

        dot = Graph()
        dot.format = 'png'
        dot.node('0', nodes[0], fillcolor='#fbb4ae', style='filled', shape='box')
        for i, pkg_name in enumerate(nodes[1:]):
            dot.node(str(i+1), pkg_name, fillcolor='#ccebc5', style='filled')

        dot.edges([
            [str(i[0]), str(i[1])]
            for i in edges
        ])

        dot.render(filepath)

    return send_file(filepath + '.png')
开发者ID:sargo,项目名称:python-package-requirements,代码行数:27,代码来源:main.py

示例3: create_interactions_graph

# 需要导入模块: from graphviz import Graph [as 别名]
# 或者: from graphviz.Graph import node [as 别名]
def create_interactions_graph(clauses, f):
    dot = GGraph(comment='Interactions graph', engine='sfdp')
    seen_vars = set()
    edges_between_vars = defaultdict(int)

    for clause in clauses:
        for lit in clause:
            var = f(lit)
            if var not in seen_vars:
                seen_vars.add(var)
                dot.node(str(var), label=str(var))
    for clause in clauses:
        l = len(clause)
        for i in xrange(l):
            for j in xrange(i+1, l):
                edges_between_vars[(str(f(clause[i])), str(f(clause[j])))] += 1

    for interacting_vars, weight in edges_between_vars.iteritems():
        dot.edge(interacting_vars[0], interacting_vars[1], weight=str(weight))

    print edges_between_vars

    dot = _apply_styles(dot, styles)
    # print dot.source
    dot.render(os.path.join('images', 'interactions_graph.gv'), view=True)   
开发者ID:michal3141,项目名称:sat,代码行数:27,代码来源:interactions_graph.py

示例4: visualize_countries_together_in_item

# 需要导入模块: from graphviz import Graph [as 别名]
# 或者: from graphviz.Graph import node [as 别名]
def visualize_countries_together_in_item(data, start_time_str=None, end_time_str=None, newspaper_str='*'):
    countries_together_dict = _get_countries_together_in_items(data)
    # print 'countries_together_dict:', countries_together_dict
    dot = Graph(comment='Countries together in item graph', engine='sfdp')
    seen_countries = set()
    edges_between_countries = defaultdict(int)

    ## Building the graph
    for ID_and_feed, countries in countries_together_dict.iteritems():
        countries_list = list(countries)
        for country in countries_list:
            if country != '' and country not in seen_countries:
                dot.node(country, label=country)
                seen_countries.add(country)
        for i in xrange(len(countries)):
            for j in xrange(i+1, len(countries)):
                fst = min(countries_list[i], countries_list[j])
                snd = max(countries_list[i], countries_list[j])
                edges_between_countries[(fst, snd)] += 1

    for edge_endpoints, edge_weight in edges_between_countries.iteritems():
        dot.edge(edge_endpoints[0], edge_endpoints[1], weight=str(edge_weight))

    print 'seen_countries:', seen_countries
    print 'edges_between_countries:', edges_between_countries

    
    dot = _apply_styles(dot, styles)
    # print dot.source
    out_dirname = newspaper_str.replace('*', '').replace('!', '').replace('[', '').replace(']', '')
    out_filename = ('countries_together_in_item_%s_%s.gv' % (start_time_str, end_time_str)).replace(':', '-')
    dot.render(os.path.join('images', out_dirname, out_filename), view=False)
开发者ID:michal3141,项目名称:geomedia,代码行数:34,代码来源:analyze.py

示例5: render_graph

# 需要导入模块: from graphviz import Graph [as 别名]
# 或者: from graphviz.Graph import node [as 别名]
def render_graph(graph, name=None, directory=None, fill_infected='green3'):
    """ Render a user graph to an SVG file. Infected nodes are colored
    appropriately.

    Parameters:
    -----------
    graph : UserGraph
        The graph to render.

    name : str
        A name for the graph.

    directory : str
        The directory to render to.

    fill_infected : str
        The fill color for infected nodes.

    """
    dot = Graph(name=name, format='svg', strict=True)

    for user in graph.users():
        if user.metadata.get('infected', False):
            dot.attr('node', style='filled', fillcolor=fill_infected)

        dot.node(unicode(user.tag))
        dot.attr('node', style='')

    for user in graph.users():
        for neighbor in user.neighbors:
            dot.edge(unicode(user.tag), unicode(neighbor.tag))

    dot.render(directory=directory, cleanup=True)
开发者ID:brett-patterson,项目名称:ka-infection-interview,代码行数:35,代码来源:renderer.py

示例6: visualize

# 需要导入模块: from graphviz import Graph [as 别名]
# 或者: from graphviz.Graph import node [as 别名]
    def visualize(self):
        l = len(self.top_result)

        connections = dict()
        tags = dict()

        for i in range(l - 1):
            for j in range(1, l):
                if i != j:
                    key = (i, j)

                    message_list = self.get_message_list_between(self.top_result[i], self.top_result[j])
                    tag_cloud = self.subject.calculate_tag_cloud(message_list)

                    tags[key] = self.get_top_tag_cloud(tag_cloud, 5)

        # DOT language
        dot = GraphV(comment = "Information Flow - Enron")
        for i in range(l):
            dot.node(str(i), self.top_result[i] + " - " + self.company.get_role(self.top_result[i]))

        for (edge, tag) in tags.iteritems():
            node_1 = edge[0]
            node_2 = edge[1]
            note = ", ".join(tag)
            print note
            dot.edge(str(node_1), str(node_2), label=note)


        dot.render('test-output/round-table.gv', view=False)
开发者ID:npxquynh,项目名称:tts4,代码行数:32,代码来源:visualization.py

示例7: graph_draw

# 需要导入模块: from graphviz import Graph [as 别名]
# 或者: from graphviz.Graph import node [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

示例8: __str__

# 需要导入模块: from graphviz import Graph [as 别名]
# 或者: from graphviz.Graph import node [as 别名]
 def __str__(self):
     A = Graph()
     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.encode("utf8"), aresta_B.encode("utf8"), **peso_aresta)
     return A.source
开发者ID:fernandopasse,项目名称:grafos_capitais,代码行数:12,代码来源:Grafo.py

示例9: renderiza_grafo

# 需要导入模块: from graphviz import Graph [as 别名]
# 或者: from graphviz.Graph import node [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

示例10: plot

# 需要导入模块: from graphviz import Graph [as 别名]
# 或者: from graphviz.Graph import node [as 别名]
def plot(graph, engine='dot', filename='output/test'):
    """Possible engines: dot, neato, fdp, sfdp, twopi, circo"""
    g = Graph(format='png', engine=engine)
    for v in graph:
        g.node(str(index(v)))

    for v, w in graph.edges:
        g.edge(str(index(v)), str(index(w)))

    g.render(filename)
开发者ID:tennapel,项目名称:graph-problems,代码行数:12,代码来源:plot.py

示例11: getDot

# 需要导入模块: from graphviz import Graph [as 别名]
# 或者: from graphviz.Graph import node [as 别名]
 def getDot(self, color):
     dot = Graph(graph_attr = {'size':'3.5'})
     for node in self.G:
         if not node in color:
             dot.node(node)
         else:
             dot.node(node, style = 'filled', color = color[node])
     for n1 in self.G:
         for n2 in self.G[n1]:
             if n1 < n2:
                 dot.edge(n1, n2)
     return dot
开发者ID:LauraMolina,项目名称:IS2016-1,代码行数:14,代码来源:solution2.py

示例12: generateGraph

# 需要导入模块: from graphviz import Graph [as 别名]
# 或者: from graphviz.Graph import node [as 别名]
def generateGraph():
	G = Graph(
		engine = 'dot',
		filename = 'Btrfs-Graph.dot',
		name = 'BRTFS-Browser',
		comment = 'https://github.com/Zo0MER/BRTFS-Browser.git',
		graph_attr = {'rankdir': 'RL',
						'charset':'utf-8',
						'bgcolor':'#eeeeee',
						'labelloc':'t', 
						'splines':'compound',
						'nodesep':'0.7',
						'ranksep':'5'
					},
		node_attr = {'fontsize': '18.0',
					'shape':'box'
		}
	)

	#node with title and hyperlink on github
	G.node('meta', 
		label = 'Btrfs-debug-tree \nhttps://github.com/Zo0MER/BRTFS-Browser.git', 
		href = 'https://github.com/Zo0MER/BRTFS-Browser.git',
		fontcolor = '#4d2600',
		fontsize = '30.0'
		)

	first = inode[0]
	inode.remove(inode[0])

	if (inode):
		#link first item ROOT_TREE_DIR INODE_ITEM, INODE_REF with all INODE_ITEM EXTEND_DATA
		for pair in inode:
			G.edge(''.join([str(x) for x in first]), ''.join([str(x) for x in pair]))
	else:
		G.node(first)

	#save *.dot and others
	pathout = enterPath.get()
	filenameout = enterFilename.get()

	if (filenameout):
		filenameout = filenameout + '.gv.dot'
	else:
		filenameout = "btrfs-graph"

	G.filename = filenameout + '.gv.dot'
	G.directory = pathout

	G.save()
	for t in types:
		G.format = t
		G.render()
开发者ID:kekdck,项目名称:BRTFS-Browser,代码行数:55,代码来源:btrfs_graph.py

示例13: plot

# 需要导入模块: from graphviz import Graph [as 别名]
# 或者: from graphviz.Graph import node [as 别名]
def plot(graph, engine='dot', filename='output/test', vertex_names={}):
    """
    Possible engines: dot, neato, fdp, sfdp, twopi, circo
    Vertex_names is an optional dict from vertices to strings.
    """
    g = Graph(format='png', engine=engine)

    def vertex_to_string(v):
        return (vertex_names[v] if v in vertex_names else '') + ' ({})'.format(str(index(v)))

    for v in graph:
        g.node(vertex_to_string(v))

    for v, w in graph.edges:
        g.edge(vertex_to_string(v), vertex_to_string(w))

    g.render(filename)
开发者ID:Chiel92,项目名称:graph-problems,代码行数:19,代码来源:plot.py

示例14: create_conflicts_graph

# 需要导入模块: from graphviz import Graph [as 别名]
# 或者: from graphviz.Graph import node [as 别名]
def create_conflicts_graph(clauses):
    dot = GGraph(comment='Conflicts graph', engine='sfdp')

    for i in xrange(len(clauses)):
        dot.node(str(i), label=str(i))

    for i in xrange(len(clauses)):
        for j in xrange(i+1, len(clauses)):
            clause_i = clauses[i]
            clause_j = clauses[j]
            edge_labels = []
            for lit in clause_i:
                if -lit in clause_j:
                    var = abs(lit)
                    edge_labels.append(str(var))
            if len(edge_labels) > 0:
                dot.edge(str(i), str(j), label=','.join(edge_labels)) 

    dot = _apply_styles(dot, styles)
    dot.render(os.path.join('images', 'conflicts_graph.gv'), view=True)
开发者ID:michal3141,项目名称:sat,代码行数:22,代码来源:interactions_graph.py

示例15: outputToPdf

# 需要导入模块: from graphviz import Graph [as 别名]
# 或者: from graphviz.Graph import node [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


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