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

Python networkx.graphviz_layout函数代码示例

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

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



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

示例1: plot_graph

    def plot_graph(self, run_name, condor_path):
        # Graph one plots the memory utilization of various steps
        plt.figure(1, figsize=(30, 30))
        plt.axis("off")
        plt.title(run_name + "/" + "Condor Memory Utilization Scheme")
        pos = nx.graphviz_layout(self.G)
        nx.draw_networkx(self.G, pos, k=10, with_labels=False, node_size=1500, node_color=self.memory_colors())
        nx.draw_networkx_labels(self.G, pos, labels=self.memory_labels())
        plt.savefig(condor_path + run_name + "/" + "CondorMemoryUtilization.png")
        plt.clf()

        # Graph two plots the CPU utilization of various steps
        plt.figure(2, figsize=(30, 30))
        plt.axis("off")
        plt.title("Condor CPU Utilization Scheme")
        pos = nx.graphviz_layout(self.G)
        nx.draw_networkx(self.G, pos, k=10, with_labels=False, node_size=1500, node_color=self.cpu_colors())
        nx.draw_networkx_labels(self.G, pos, self.cpu_labels())
        plt.savefig(condor_path + run_name + "/" + "CondorCpuUtilization.png")
        plt.clf()

        # Graph three plots the GPU utilization of various steps
        plt.figure(3, figsize=(30, 30))
        plt.axis("off")
        plt.title("Condor GPU Utilization Scheme")
        pos = nx.graphviz_layout(self.G)
        nx.draw_networkx(self.G, pos, k=10, with_labels=False, node_size=1500, node_color=self.gpu_colors())
        nx.draw_networkx_labels(self.G, pos, self.gpu_labels())
        plt.savefig(condor_path + run_name + "/" + "CondorGpuUtilization.png")
        plt.clf()
开发者ID:MichaelLampe,项目名称:GLSeq2,代码行数:30,代码来源:CommandAssembler.py


示例2: position_friends

def position_friends(request, engine, width, height, widthoffset=0, auto = False):
	print "Positioning friends"
	width = width-widthoffset
	ratio = float(width)/float(height)
	dajax = Dajax()
	s = request.session
	user = s['fbuser']
	print "Got fbuser object"
	p = Person.objects.get(id = user.id)
	print "AJAX checking if connections_ready = " +str(p.connections_ready)
	#Check if the connections are ready to be returned; if not tell client to wait 5s
	if (not p.connections_ready):
		print "Connections not ready"
		dajax.add_data({'time':3000, 'auto':auto}, 'grapher.waitToPosition')
		return dajax.json()
	nodes = user.get_friend_ids()
	print "Got nodes"
	links = user.get_friends_links()
	print "Got links"
	#print links
	G_wrapper = GraphWrapper(nodes, links)
	G = G_wrapper.G
	print "Producing layout"
	if (engine=="sfdp"):
		layout=nx.graphviz_layout(G, prog='sfdp', args="-Gratio=%f -GK=1.5" % (ratio))
	elif (engine=="twopi"):
		layout=nx.graphviz_layout(G, prog='twopi', args="-Gratio=%f" % ratio)
	else:
		#Invalid layout engine?
		return dajax.json()
	x_coords = [p[0] for p in layout.values()]
	y_coords = [p[1] for p in layout.values()]
	min_x = min(x_coords)
	max_x = max(x_coords)
	min_y = min(y_coords)
	max_y = max(y_coords)
	x_shift = -1 * min_x
	y_shift = -1*min_y
	x_scale = float(width-20)/float(max_x-min_x)
	y_scale = float(height-20)/float(max_y-min_y)
	scaled_layout = {}
	for node in layout:
		x = int((layout[node][0] + x_shift) * x_scale)+10+widthoffset
		y = int((layout[node][1] + y_shift) * y_scale)+10
		scaled_layout[node] = (x,y)
	#print scaled_layout
	if auto:
		dajax.add_data(scaled_layout, 'grapher.auto_set_positions')
	else:
		dajax.add_data(scaled_layout, 'grapher.set_positions')
	return dajax.json()
开发者ID:databanana,项目名称:SeniorProject,代码行数:51,代码来源:ajax.py


示例3: as_path_plot

    def as_path_plot(self,as_path, prefix):
        '''This method accpets the list of as-path to plot for the
           selected prefix as per the GUI. It uses networkx module.
           The Nodes represent the AS and the edges represent the
           AS connectivity.
        '''
        G = nx.Graph()
        l= as_path

        for i,a in enumerate(l):
            #print a, type(a), len(a)
            G.add_node(a[-1])
            for i in xrange(len(a)):
                if i == len(a)-1:
                    break
                G.add_node(a[i])
                G.add_edge(a[i],a[i+1])

#        plt.title("draw_networkx")
        
 #       plt.savefig('abcd.png',dpi=500, facecolor='w', edgecolor='w',orientation='landscape', papertype=None, format=None,transparent=False, bbox_inches=None, pad_inches=0.8)

        plt.title("AS Path for "+prefix)
        pos=nx.graphviz_layout(G,prog='dot')
        plt.figure(1,figsize=(10,8))
        #nx.draw_networkx(G,pos)
        nx.draw(G,pos,with_labels=True,arrows=True, font_size = 9,edge_color='r', node_color='b')
        plt.savefig(prefix+'_as_path.png',pad_inches = 0.8)
        
        plt.show()
开发者ID:dkn91,项目名称:learning,代码行数:30,代码来源:plotme.py


示例4: plot_func

def plot_func(play, stats):
    generation = stats["generation"]
    best = stats["generation_best"]
    every = play.config["live_plot"].get("every", 100)

    if generation == 0:
        plt.figure(figsize=(10, 8))

    if (generation % every) == 0:
        plt.clf()

        # create graph
        graph = nx.DiGraph()
        traverse_tree(best.root, graph)
        labels = dict((n, d["label"]) for n, d in graph.nodes(data=True))

        pos = nx.graphviz_layout(graph, prog='dot')
        nx.draw(
            graph,
            pos,
            with_labels=True,
            labels=labels,
            arrows=False,
            node_shape=None
        )

        # plot graph
        plt.draw()
        plt.pause(0.0001)  # very important else plot won't be displayed
开发者ID:leizhang,项目名称:playground,代码行数:29,代码来源:classifier_evaluation.py


示例5: draw

def draw(graph):
       pos = nx.graphviz_layout(graph, prog='sfdp', args='')
       list_nodes = graph.nodes()
       plt.figure(figsize=(20,10))
       nx.draw(graph, pos, node_size=20, alpha=0.4, nodelist=list_nodes, node_color="blue", with_labels=False)
       plt.savefig('graphNX.png')
       plt.show()
开发者ID:RafaelRemondes,项目名称:DistributedAggregationAlgorithmsSM,代码行数:7,代码来源:graphTest.py


示例6: plot_co_x

def plot_co_x(cox, start, end, size = (20,20), title = '', weighted=False, weight_threshold=10):

        """ Plotting function for keyword graphs

        Parameters
        --------------------
        cox: the coword networkx graph; assumes that nodes have attribute 'topic'
        start: start year
        end: end year
        """

        plt.figure(figsize=size)
        plt.title(title +' %s - %s'%(start,end), fontsize=18)
        if weighted:
            elarge=[(u,v) for (u,v,d) in cox.edges(data=True) if d['weight'] >weight_threshold]
            esmall=[(u,v) for (u,v,d) in cox.edges(data=True) if d['weight'] <=weight_threshold]
            pos=nx.graphviz_layout(cox) # positions for all nodes
            nx.draw_networkx_nodes(cox,pos,
                node_color= [s*4500 for s in nx.eigenvector_centrality(cox).values()],
                node_size = [s*6+20  for s in nx.degree(cox).values()],
                alpha=0.7)
            # edges
            nx.draw_networkx_edges(cox,pos,edgelist=elarge,
                                width=1, alpha=0.5, edge_color='black') #, edge_cmap=plt.cm.Blues
            nx.draw_networkx_edges(cox,pos,edgelist=esmall,
                                width=0.3,alpha=0.5,edge_color='yellow',style='dotted')
            # labels
            nx.draw_networkx_labels(cox,pos,font_size=10,font_family='sans-serif')
            plt.axis('off')
        else:
            nx.draw_graphviz(cox, with_labels=True,
                         alpha = 0.8, width=0.1,
                         fontsize=9,
                         node_color = [s*4 for s in nx.eigenvector_centrality(cox).values()],
                         node_size = [s*6+20 for s in nx.degree(cox).values()])
开发者ID:datapractice,项目名称:machinelearning,代码行数:35,代码来源:net_lit_anal.py


示例7: colorSubcomps

    def colorSubcomps(self, G, prog="neato", layout=None):
        C = nx.connected_component_subgraphs(G)
        pos = nx.graphviz_layout(G, prog=prog) if layout == None else layout

        for g in C:
            c = [random.random()] * nx.number_of_nodes(g)  # random color...
            nx.draw(g, pos, node_size=40, node_color=c, vmin=0.0, vmax=1.0, with_labels=False)
开发者ID:ravleen24,项目名称:NetworkAnomalyDetection,代码行数:7,代码来源:graph.py


示例8: Main

def Main():
    G = kw2Jd(searchterm)
    H = nx.Graph(G)
    font = {'fontname': 'Arial',
            'color': 'k',
            'fontweight': 'bold',
            'fontsize': 14}
    plt.rcParams['text.usetex'] = False
    plt.figure(figsize=(8, 8))
    plt.title("PZ", font)
    plt.axis('off')
    plt.text(0.5, .95, searchterm,
             horizontalalignment='center', transform=plt.gca().transAxes)
    try:
        pos = nx.graphviz_layout(H)
    except:
        pos = nx.spring_layout(H, iterations=20)

    nx.draw_networkx_edges(
        H, pos, alpha=0.1, node_size=0, edge_color='w', width=3)
    nx.draw_networkx_labels(H, pos, fontsize=12)

    nodesize = [salary.get(v, 0) ** 2 for v in H]

    colorcoding = [supply.get(v, 10000) / (openings.get(v, 1) + 1) for v in H]
    linewidths = [
        (abs(trends.get(v, 0)) - trends.get(v, 10000)) / 10 for v in H]
    nodes = H.nodes()

    nx.draw_networkx_nodes(H, pos, nodelist=nodes, node_size=nodesize, linewidths=linewidths, cmap=plt.cm.Blues, vmin=min(
        colorcoding), vmax=100, node_color=colorcoding)
    plt.savefig("pz-networkx.png", dpi=75)
    plt.show()
开发者ID:revizor1,项目名称:DMiner,代码行数:33,代码来源:DMiner.py


示例9: startGame

    def startGame(self):
        print "starting game", self.configuration

        self.startNode = [loadGame(self.configuration).toString()]

        threads = []
        for i in range(10):
            t = threading.Thread(target=self.ant, args=(i,))
            threads.append(t)
            t.start()

        print "Waiting..."
        for t in threads:
            t.join()
        print "Waiting done"

        # nx.draw(self.stateSpace)
        myBoard = loadGame(self.configuration).toString()
        pos=nx.graphviz_layout(self.stateSpace,prog='neato')
        nx.draw(self.stateSpace,pos=pos,node_size=20)
        nx.draw_networkx_nodes(self.stateSpace,pos,
                       nodelist=[myBoard],
                       node_color='g',
                       node_size=100)
        nx.draw_networkx_nodes(self.stateSpace,pos,
                       nodelist=list(self.winNodes),
                       node_color='b',
                       node_size=100)

        # A = nx.to_agraph(self.stateSpace)
        # A.layout(prog='neato', color='red')
        # A.draw('color.png')

        plt.show()
开发者ID:erikvanegmond,项目名称:RushHourACE,代码行数:34,代码来源:gameForAnts.py


示例10: prettyPlotter

 def prettyPlotter(self, l=None, filename=None):
     """
     Metod służy do rysowania grafu reprezentującego sieć, w którym węzły należące do tej samej grupy są oznaczone jednym kolorem.
     
     @type l: list
     @param l: lista list węzłów podzielonych na grupy
     @param filename: nazwa pliku PNG z wynikowym obrazem
     """
     nodeList = l
         
     colorList = [0] * self.graph.number_of_nodes()
     for nbunch in nodeList:
         for n in nbunch:
             colorList[self.graph.nodes().index(n)] = nodeList.index(nbunch)
     import matplotlib.pyplot as plt
     pos = nx.graphviz_layout(self.graph, prog='neato')
     
     plt.figure()
     plt.axis('off')
     nx.draw(self.graph, pos, node_color=colorList, with_labels=False)
     if filename:
         import config
         filename = config.PLOT_OUT_DIR+filename
         plt.savefig(filename)
     else:
         plt.show()
开发者ID:ymirpl,项目名称:networkx-thesis,代码行数:26,代码来源:sna.py


示例11: draw_graph

    def draw_graph(self, my_list=None):
        # pos = nx.spring_layout(self.G, iterations=20)
        pos = nx.graphviz_layout(self.G, prog='sfdp', root='downlod_0', args="-Grankdir=LR")
        #pos = nx.spring_layout(self.G,fixed = ['r1_c1'], scale=2)
        #print(pos)
        #pos = self.h_recur(self.G, 'download_0')
        #nx.draw(self.G, pos=pos, with_labels=True)
        for node in self.G.nodes():
            self.G.node[node]['category'] = 'type_A'
        if my_list:
            for my_nodes2 in my_list:
                self.G.node[my_nodes2]['category'] = 'critical_path'
        color_map = {'type_A':'y', 'critical_path':'#FFC266'}
        ## construct a list of colors then pass to node_color
        if my_list:
            nx.draw(self.G, pos=pos, node_size=200, node_color=[color_map[self.G.node[node]['category']] for node in self.G])
        else:
            nx.draw(self.G, pos=pos, node_size=200, node_color='y')

        node_labels = nx.get_node_attributes(self.G, 'id')
        nx.draw_networkx_labels(self.G, pos, labels=node_labels,  font_size=8, font_color='r', font_weight='bold',
                                font_family='sans-serif')
        """edge_labels = nx.get_edge_attributes(self.G, 'weight')
        for key, value in edge_labels.items():
            edge_labels[key] = round(value, 4)"""
        #print('edge lbl', edge_labels)
        #nx.draw_networkx_edge_labels(self.G, pos, labels=edge_labels)
        plt.show()
开发者ID:shreya668,项目名称:Fcn_Project_Wprof,代码行数:28,代码来源:json_dag.py


示例12: visualize

def visualize(tree, custom_alpha=0.5, labels=False):
    G = nx.Graph(tree)
    pos = nx.graphviz_layout(G, prog='twopi', args='', root='root')
    plt.figure(figsize=(10, 10))
    nx.draw(G, pos, node_size=0, alpha=custom_alpha, node_color="blue", with_labels=labels)
    plt.axis('equal')
    plt.show()
开发者ID:vitaly-emelianov,项目名称:dinsys2015,代码行数:7,代码来源:visualization.py


示例13: get

    def get(self, request, name="root", *args, **kwargs):
        import networkx as nx
        import matplotlib as mpl

        mpl.use("Agg")
        import matplotlib.pyplot as plt
        import nxedges

        plt.figure(figsize=(10, 8))

        g = nx.DiGraph()

        labels = {}
        for service in Service.objects.all():
            g.add_node(service.id)
            if len(service.name) > 8:
                labels[service.id] = service.name[:8] + "\n" + service.name[8:]
            else:
                labels[service.id] = service.name

        for tenant in CoarseTenant.objects.all():
            if (not tenant.provider_service) or (not tenant.subscriber_service):
                continue
            g.add_edge(tenant.subscriber_service.id, tenant.provider_service.id)

        pos = nx.graphviz_layout(g)
        nxedges.xos_draw_networkx_edges(g, pos, arrow_len=30)
        nx.draw_networkx_nodes(g, pos, node_size=5000)
        nx.draw_networkx_labels(g, pos, labels, font_size=12)
        # plt.axis('off')
        plt.savefig("/tmp/foo.png")

        return HttpResponse(open("/tmp/foo.png", "r").read(), content_type="image/png")
开发者ID:xuys50,项目名称:xos,代码行数:33,代码来源:services.py


示例14: draw

  def draw(self):
     if os.path.exists(self.service_dep_file_path):
       graph=nx.DiGraph()
       service_dep_file_handle=open(self.service_dep_file_path,'r')
       try:
      
          raw_connection_instance=service_dep_file_handle.readline()
          while  raw_connection_instance:
             connection_instance=raw_connection_instance.strip('\n')
             sub_str=connection_instance.split(' ')
             source_sub_str=sub_str[0]
             destination_sub_str=sub_str[1]
             localhost=sub_str[0].split(',')
             if len(destination_sub_str)==0:
                 destination_sub_str='remote process'
             graph.add_node(source_sub_str)
             graph.add_node(destination_sub_str)
             graph.add_edge(source_sub_str,destination_sub_str)
             graph.add_edge(source_sub_str,localhost[0])
             raw_connection_instance=service_dep_file_handle.readline()
#         Set the attributes of the grpah  
 #         pos=nx.spring_layout(graph,dim=2,iterations=5)
          pos=nx.graphviz_layout(graph,prog='dot')
          nx.draw(graph,pos,edge_color='b',font_size=15)
          
          plt.show()
       finally:
          service_dep_file_handle.close()
开发者ID:ydy007,项目名称:EagleEye,代码行数:28,代码来源:service_topology_graph.py


示例15: erd

    def erd(self, subset=None, prog='dot'):
        """
        plot the schema's entity relationship diagram (ERD).
        The layout programs can be 'dot' (default), 'neato', 'fdp', 'sfdp', 'circo', 'twopi'
        """
        if not subset:
            g = self.graph
        else:
            g = self.graph.copy()
            for i in g.nodes():
                if i not in subset:
                    g.remove_node(i)

        def tableList(tier):
            return [i for i in g if self.tables[i].tier==tier]

        pos=nx.graphviz_layout(g,prog=prog,args='')
        plt.figure(figsize=(8,8))
        nx.draw_networkx_edges(g, pos, alpha=0.3)
        nx.draw_networkx_nodes(g, pos, nodelist=tableList('manual'),
                               node_color='g', node_size=200, alpha=0.3)
        nx.draw_networkx_nodes(g, pos, nodelist=tableList('computed'),
                               node_color='r', node_size=200, alpha=0.3)
        nx.draw_networkx_nodes(g, pos, nodelist=tableList('imported'),
                               node_color='b', node_size=200, alpha=0.3)
        nx.draw_networkx_nodes(g, pos, nodelist=tableList('lookup'),
                               node_color='gray', node_size=120, alpha=0.3)
        nx.draw_networkx_labels(g, pos, nodelist = subset, font_weight='bold', font_size=9)
        nx.draw(g,pos,alpha=0,with_labels=False)
        plt.show()
开发者ID:peabody124,项目名称:DataJoint,代码行数:30,代码来源:schema.py


示例16: datatypes

    def datatypes(self, pattern='*', save=None):
        graph = self.get_graph.datatypes(pattern)

        plt.figure(figsize=(8,8))
        pos = nx.graphviz_layout(graph, prog='twopi', args='')

        cost = lambda v: float(graph.degree(v)) ** 3 + \
            graph.weights[v] ** 2

        node_size = [cost(v) for v in graph]
        # node_size = [graph.weights[v] ** 2 for v in graph]
        # node_color = [float(graph.degree(v)) for v in graph]
        node_color = [cost(v) for v in graph]

        nx.draw(graph, pos, 
                node_size=node_size, node_color=node_color,
                font_size=13, font_color='green', font_weight='bold'
                )
    
        plt.axis('off')

        if save is not None:
            plt.savefig(save)

        plt.show()
开发者ID:FredLoney,项目名称:pyxnat,代码行数:25,代码来源:help.py


示例17: KernelQuickShiftTreeEmbedding

def KernelQuickShiftTreeEmbedding(X, knn=10, knn_density=None, k_threshold=0.9, metric='linear', **args):
    if knn_density is None:
        knn_density = knn
    n_instances = X.shape[0]
    # extract pairwise similarity matrix with desired kernel
    from sklearn import metrics
    K = metrics.pairwise.pairwise_kernels(X, metric=metric, **args)
    # compute instance density as average pairwise similarity
    import numpy as np
    density = np.sum(K, 0) / n_instances
    # compute list of nearest neighbors
    Ka = np.argsort(-K)
    # make matrix of densities ordered by nearest neighbor
    Kad = density[Ka]
    parent_dict = {}
    # for all instances determine parent link
    for i, row in enumerate(Kad):
        i_density = row[0]
        # if a densed neighbor cannot be found then assign parent to the instance itself
        parent_dict[i] = i
        # for all neighbors from the closest to the furthest
        for jj, d in enumerate(row):
            # proceed until k neighbors have been explored
            if jj > knn_density:
                break
            j = Ka[i, jj]
            if jj > 0:
                j_density = d
                # if the density of the neighbor is higher than the density of the instance assign parent
                if j_density > i_density:
                    parent_dict[i] = j
                    break
    # make a graph with instances as nodes
    import networkx as nx
    G = nx.Graph()
    G.add_nodes_from(range(n_instances))
    # add edge between instance and parent
    for i in range(n_instances):
        j = parent_dict[i]
        G.add_edge(i, j, weight=1)
    # determine threshold as k-th quantile on pairwise similarity on the knn similarity
    knn_similarities = K[Ka[:, knn]]
    # vectorized_pairwise_similarity = np.ravel(K)
    k_quantile = np.percentile(knn_similarities, k_threshold * 100)
    # add edge between instance and k-th nearest neighbor if similarity > threshold
    for i in range(n_instances):
        # id of k-th nearest neighbor
        jd = Ka[i, knn]
        # similarity of k-th nearest neighbor
        kd = K[i, jd]
        if kd > k_quantile:
            G.add_edge(i, jd, weight=1)
    # use graph layout algorithm to determine coordinates
    X_ = nx.graphviz_layout(G, prog='sfdp', args='-Goverlap=scale')
    X_2D = []
    for i in range(K.shape[0]):
        X_2D.append(list(X_[i]))
    X_emb = np.array(X_2D)
    from sklearn.preprocessing import scale
    return scale(X_emb)
开发者ID:bgruening,项目名称:EDeN,代码行数:60,代码来源:display.py


示例18: plot

    def plot(self, graph_type):
        # pypy doesn't support matplotlib and networkx, :(
        import matplotlib.pyplot as plt
        import networkx as nx

        nx_graph = nx.Graph()

        for node in self.get_nodes().values():
            nx_graph.add_node(node.get_id(), type=node.get_type())

        for node in self.get_nodes().values():
            for link in node.get_links():
                end_point = link.get_end_points()
                neighbor = end_point[0] if node.get_id() != end_point[0] else end_point[1]
                nx_graph.add_edge(node.get_id(), neighbor, weight=100)

        hosts = [(u) for (u, v) in nx_graph.nodes(data = True) if v["type"] == "host"]
        switches = [(u) for (u, v) in nx_graph.nodes(data = True) if v["type"] == "switch"]

        pos = nx.graphviz_layout(nx_graph)

        # draw graph
        nx.draw_networkx_nodes(nx_graph, pos, nodelist=switches, node_size=100, label="x")
        nx.draw_networkx_nodes(nx_graph, pos, nodelist=hosts, node_size=50, node_color='b')
        nx.draw_networkx_edges(nx_graph, pos)

        plt.savefig("graphs/" + graph_type + '.png')
        plt.clf()
开发者ID:T3Fei,项目名称:network-scheduling-simulator,代码行数:28,代码来源:graph.py


示例19: image_from_graph

def image_from_graph(graph, layout_prog='dot', outpath=None):
    """
    Create an image from a :class:`NetworkX.DiGraph`.
    
    The standard image is a PNG image, with a standard *tree* look. 
    The image type is based on the extension of the file specified by 
    outpath.
    
    :param root_node: The root of the Hierarchy.
    :type root_node: GSGroup or GSHierarchy
    :param layout_prog: The graphviz layout program to use to layout 
        the Hierarchy AGraph before drawing.
    :type layout_prog: string
    
    """
    if outpath is None:
        outpath = "%s_nxgraph.svg" % root_node.get_name()


#
#    Commented out here is the code that creates the Image
#    by using the graphviz backend of NetworkX.
#
#    agraph = nx.to_agraph(graph)
#    agraph.graph_attr.update(**graph_wide_settings)
#    agraph.node_attr.update(**node_settings)
#    agraph.edge_attr.update(**edge_settings)
#    agraph.layout(prog=layout_prog)
#    agraph.draw('other_'+outpath)
    pos=nx.graphviz_layout(graph, prog=layout_prog)
    plt.figure(**figure_settings)
    nx.draw(graph, pos, node_color=range(graph.number_of_nodes()),
            **drawing_settings)
    plt.savefig(outpath)
开发者ID:dillonhicks,项目名称:ipymake,代码行数:34,代码来源:gsnetworkx.py


示例20: __init__

 def __init__(self, pipeline):
     self.pipeline = pipeline
     self.graph = pipeline.graph
     type2color = dict(file = "orange", topic="red", program="blue")
     self.colors = [type2color[self.graph.node[node]["type"]] for node in self.graph.nodes()]
     self.positions = nx.graphviz_layout(self.graph, prog="dot")
     self.labels = dict(zip(self.graph.nodes(), self.graph.nodes()))
开发者ID:benkehoe,项目名称:python,代码行数:7,代码来源:pipeline.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python networkx.grid_2d_graph函数代码示例发布时间:2022-05-27
下一篇:
Python networkx.goldberg_radzik函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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