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

Python networkx.draw_circular函数代码示例

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

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



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

示例1: simulateBears

def simulateBears(numYears):
  
  from BearClass import Bear
  from BearPopulationClass_tryNotN2 import BearPopulation
  import networkx as nx

  # Create the starting population
  # Make some "bear gods" to use as the parents for the progenitors
  beargod1 = Bear('bg1','M',None, None)
  beargod2 = Bear('bg2','M',None, None)
  beargod3 = Bear('bg3','F',None, None)
  adam = Bear('Adam', 'M',beargod1,beargod1)
  eve = Bear('Eve', 'F',beargod2,beargod2)
  mary = Bear('Mary', 'F',beargod3,beargod3)
  year = 0
  numBornInFirst100Years = 0
  
  # keep track of the number of males and females created
  #nMale = 1
  #nFemale = 2
  
  # Create a bear population from the progenitors
  progenitors = [adam, eve, mary]
  population = BearPopulation(progenitors)
  
  # Start stepping through time
  years = range(1,numYears+1)
  for year in years:
#    print "It is now the year: %s" %(year)
    # First things first: each bear gets a year older
    population.ageBears()
    # Now, what happens as the bears age
  
    # First, check if any bears died and add them to the part of the population
    # that has died
    population.checkForDead(year)
  #  for bear in population.allBears:
  #    print bear
    # Create a list of bears that are capable of procreating
    population.checkIfCanBang(year)
    numBornThisYear = population.generateOffspring(year)
    if year <= 100:
      numBornInFirst100Years += numBornThisYear
  #  nMale += newM
  #  nFemale += newF
    # Print the size of the population each year
#    print "Number of bears in population after %s years: %s" %(year, \
#          len(population.allBears) )
  #  for bear in population.canProcreate:
  #    print bear
  
  # Print the bear population
  #for bear in population.allBears:
  #  print bear
  
  print "Final Number of Bears after %i Years: %s" \
        %(numYears, len(population.allBears))
  if len(population.allBears) <= 1500:
    nx.draw_circular(population.tree)
  return numBornInFirst100Years, len(population.allBears)
开发者ID:rossbar,项目名称:AY250-HW,代码行数:60,代码来源:simulateBearPopulation.py


示例2: plot_starlike

def plot_starlike(pathway):
    pylab.figure()
    nx.draw_circular(pathway, labels=pathway.labels)
    pylab.title(pathway.title)
    title = pathway.title.replace('/', '-') # TODO: which is the proper way to remove / in a filename?
    pylab.savefig('./plots/' + title + '.png')
    pylab.show()
开发者ID:leonardolepus,项目名称:pubmad,代码行数:7,代码来源:parse_KGML.py


示例3: draw_circular_communities

 def draw_circular_communities(self):
     partition = self.find_partition()[1]
     node_color=[float(partition[v]) for v in partition]
     labels = self.compute_labels()
     nx.draw_circular(self.G,node_color=node_color, labels=labels)
     plt.show()
     plt.savefig("C:\\Users\\Heschoon\\Dropbox\\ULB\\Current trends of artificial intelligence\\Trends_project\\graphs\\graph_circular1.pdf")
开发者ID:HelainSchoonjans,项目名称:FacebookExperiments,代码行数:7,代码来源:social_graph.py


示例4: plot_graphs

    def plot_graphs(self):
        # draw lables
        # choose same layout as in drawing the rest of the graph
        pos_G=nx.circular_layout(self.g1)   # positions for all nodes for G (in this case circular)
        pos_H=nx.circular_layout(self.g2)   # positions for all nodes for H (in this case circular)
        labels_G = {}                 # create a dict with labels
        for item in self.g1.nodes():
            labels_G[item] = item

        labels_H = {}                 # create a dict with labels
        for item in self.g2.nodes():
            labels_H[item] = item

        # color-mapping via numpy
        # list of cmaps can be found here: http://matplotlib.org/examples/color/colormaps_reference.html
        # I chose this cmap because there are no dark colors in it so the labels stay readable regardless
        # the color of the label.
        plt.subplots_adjust(left=0,right=1,bottom=0,top=0.95,wspace=0.01,hspace=0.01)
        plt.subplot(121)
        plt.title("Graph G")
        nx.draw_circular(self.g1, cmap=plt.get_cmap('Set1'), node_color=self.nc1)
        nx.draw_networkx_labels(self.g1, pos_G, labels_G)

        plt.subplot(122)
        plt.title("Graph H")
        nx.draw_circular(self.g2, cmap=plt.get_cmap('Set1'), node_color=self.nc2)
        nx.draw_networkx_labels(self.g2, pos_H, labels_H)

        plt.show()
开发者ID:sanklamm,项目名称:Graph_Isomorphism,代码行数:29,代码来源:graph_iso.py


示例5: draw_networkx_ex

def draw_networkx_ex():
    G = nx.dodecahedral_graph()
    nx.draw(G)
    plt.show()
    nx.draw_networkx(G, pos=nx.spring_layout(G))
    limits = plt.axis('off')
    plt.show()
    nodes = nx.draw_networkx_nodes(G, pos=nx.spring_layout(G))
    plt.show()
    edges = nx.draw_networkx_edges(G, pos=nx.spring_layout(G))
    plt.show()
    labels = nx.draw_networkx_labels(G, pos=nx.spring_layout(G))
    plt.show()
    edge_labels = nx.draw_networkx_edge_labels(G, pos=nx.spring_layout(G))
    plt.show()
    print("Circular layout")
    nx.draw_circular(G)
    plt.show()
    print("Random layout")
    nx.draw_random(G)
    plt.show()
    print("Spectral layout")
    nx.draw_spectral(G)
    plt.show()
    print("Spring layout")
    nx.draw_spring(G)
    plt.show()
    print("Shell layout")
    nx.draw_shell(G)
    plt.show()
    print("Graphviz")
开发者ID:szintakacseva,项目名称:MLTopic,代码行数:31,代码来源:nxdrawing.py


示例6: plot_fragment_graph

def plot_fragment_graph(G, labels=None, to_file=None, dpi=300):
    
#    try:
#        from networkx import graphviz_layout
#    except ImportError:
#        raise ImportError("This example needs Graphviz and either PyGraphviz or Pydot")
#    
#    if len(G.nodes()) == 0:
#        raise ValueError('No fragments to plot!')
#    
#    pos = nx.graphviz_layout(G, prog="dot")
    fig = pl.figure(figsize=(10, 10))
    node_size = 300
    nx.draw_circular(G)
#    nx.draw(G, pos,
#            with_labels=True,
#            alpha=0.5,
#            node_size=node_size)
    
    ## adjust the plot limits
#    offset = node_size / 2
#    xmax = offset + max(xx for xx, yy in pos.values())
#    ymax = offset + max(yy for xx, yy in pos.values())
#    xmin = min(xx for xx, yy in pos.values()) - offset
#    ymin = min(yy for xx, yy in pos.values()) - offset
#    pl.xlim(xmin, xmax)
#    pl.ylim(ymin, ymax)
    
    if to_file != None:
        filename = to_file.split('/')[-1]
        pl.savefig((filename + "_graph"), dpi=dpi)
    else:
        pl.show()
        return fig
开发者ID:jhooge,项目名称:RAILIN,代码行数:34,代码来源:FragGraph.py


示例7: plot_graph

def plot_graph(G,circular=False):    
    #Desenha grafo e mostra na tela
    if not circular:
        nx.draw(G)
    else:
        nx.draw_circular(G)
    plt.show()
开发者ID:DiegoVallely,项目名称:data_mining,代码行数:7,代码来源:db_data_mining.py


示例8: draw_graph

def draw_graph(g, out_filename):
    nx.draw(g)
    nx.draw_random(g)
    nx.draw_circular(g)
    nx.draw_spectral(g)

    plt.savefig(out_filename)
开发者ID:lgadawski,项目名称:tass,代码行数:7,代码来源:tass.py


示例9: drawGraph

def drawGraph(nodes,peers,root):
	
	global G
	

	#root = root.replace(" ", "")
	root = root[11:13]
	

	if root == "9:" or root == "9 ":
		root = "9" 


	print root
	print root[11:13]
	G.add_node(root)
	
	#G.add_node(root.replace(" ", ""))

	for x in peers:
		for y in nodes:
			if str(x) in y:
				peer = y[1][11:13]
				if peer == "9:" or peer == "9 ":
					peer = "9" 
				G.add_node(peer)
				G.add_edge(root,peer)
		
	#for x in (nodes):
	#	G.add_node(x[1])
	
	if(env.host_string == '145.100.97.62'):
		nx.draw_circular(G,with_labels=True,font_size=15,node_color='yellow',node_size=1000)
		print G.nodes()
		plt.show()	
开发者ID:cheatas,项目名称:LIA-P2P,代码行数:35,代码来源:fabfile.py


示例10: displayControlImportances

 def displayControlImportances(self,nocontrolconnectionmatrix, controlconnectionmatrix ):
     """This method will create a graph containing the 
     connectivity and importance of the system being displayed.
     Edge Attribute: color for control connection
     Node Attribute: node importance
     
     It's easier to just create the no control connecion matrix here...
     
     """
     
     ncG = nx.DiGraph()
     n = len(self.variablelist)
     for u in range(n):
         for v in range(n):
             if nocontrolconnectionmatrix[u,v] == 1:
                 ncG.add_edge(self.variablelist[v], self.variablelist[u])
     
     edgelistNC = ncG.edges()
     
     self.controlG = nx.DiGraph()
     
     for u in range(n):
         for v in range(n):
             if controlconnectionmatrix[u,v] == 1:
                 if (self.variablelist[v], self.variablelist[u]) in edgelistNC:
                     self.controlG.add_edge(self.variablelist[v], self.variablelist[u], controlloop = 0)
                 else:
                     self.controlG.add_edge(self.variablelist[v], self.variablelist[u], controlloop = 1)
     
     
     for node in self.controlG.nodes():
         self.controlG.add_node(node, nocontrolimportance = self.blendedrankingNC[node] , controlimportance = self.blendedranking[node])
     
     plt.figure("The Controlled System")
     nx.draw_circular(self.controlG)
开发者ID:stelmo,项目名称:LoopRanking,代码行数:35,代码来源:controlranking.py


示例11: plot_network

def plot_network(res):
    """Plot network of multivariate TE between processes.

    Plot graph of the network of (multivariate) interactions between
    processes (e.g., multivariate TE). The function uses  the
    networkx class for directed graphs (DiGraph) internally.
    Plots a network and adjacency matrix.

    Args:
        res : dict
            output of multivariate_te.analyse_network()

    Returns:
        instance of a directed graph class from the networkx
        package (DiGraph)
    """
    try:
        res = res['fdr']
    except KeyError:
        print('plotting non-corrected network!')

    g = generate_network_graph(res)
    print(g.node)
    f, (ax1, ax2) = plt.subplots(1, 2)
    adj_matrix = nx.to_numpy_matrix(g)
    cmap = sns.light_palette('cadetblue', n_colors=2, as_cmap=True)
    sns.heatmap(adj_matrix, cmap=cmap, cbar=False, ax=ax1,
                square=True, linewidths=1, xticklabels=g.nodes(),
                yticklabels=g.nodes())
    ax1.xaxis.tick_top()
    plt.setp(ax1.yaxis.get_majorticklabels(), rotation=0)
    nx.draw_circular(g, with_labels=True, node_size=300, alpha=1.0, ax=ax2,
                     node_color='cadetblue', hold=True, font_weight='bold')
    plt.show()
    return g
开发者ID:finnconor,项目名称:IDTxl,代码行数:35,代码来源:visualise_graph.py


示例12: draw_graph

def draw_graph(graphDic, nodesStatus, imageName):
    node_colors = [] 
    #first writing the number of nodes 
    #nx.draw(G) 
    #select the color 
    newGraphDic = {} #without the status 
    for element in graphDic.keys():
        status = nodesStatus[element[0] - 1]
        if status == "INACTIVE":
            node_colors +=['white']
        if status == "ACTIVE":
            node_colors +=['red']
        if status == "SELECTED":
            node_colors +=['green']
    #generating the graph from the dictionary 
    G = nx.from_dict_of_lists(graphDic) 
    nx.draw_circular(G, node_color = node_colors, with_labels=True, node_size = 50)
    #G.text(3, 8, 'boxed italics text in data coords', style='italic', bbox={'facecolor':'red', 'alpha':0.5, 'pad':10})
#    plt.legend(handles=[ green_patch])
#    nx.draw_networkx(G, node_color=node_colors, with_labels=True)
    
    #nx.draw_networkx(G) 
    #save the result  semiSparseRep 
    print "image name is" + imageName 
    plt.savefig(imageName);
开发者ID:zaddan,项目名称:GPU_CPU_Sync_Optimization,代码行数:25,代码来源:generate_graph.py


示例13: show

    def show(self, filename=''):
        """
        Uses the networkx/matplotlib.pyplot modules to graphically show what network
        was created. Nodes should have labels. Shows the resultant graph in a temporary window.
        If [filename] is provided, instead saves result in [filename]
        """
        try:
            import networkx
        except ImportError:
            print "Please install networkx via 'easy_install networkx', 'pip install networkx' or some other method."
            print "You will not have access to the full functionality of this module until then"
            sys.exit(1)

        try:
            import matplotlib.pyplot as plt
        except ImportError:
            print "Please install matplotlib via 'easy_install matplotlib', 'pip install matplotlib' or some other method."
            print "You will not have access to the full functionality of this module until then"
            sys.exit(1)

        string_edges = map(lambda x: "%s %s" % (x[0], x[1]), self.edge_list)
        graph = networkx.parse_edgelist(string_edges)
        networkx.draw_circular(graph,prog='neato',width=1,node_size=300,font_size=14,overlap='scalexy')
        if filename:
            plt.savefig(filename)
        else:
            plt.show()
开发者ID:gtfierro,项目名称:ggraph,代码行数:27,代码来源:ggraph.py


示例14: test_build_networkx_graph

    def test_build_networkx_graph(self):
        url = 'http://localhost:8181/'
        output = sys.stdout
        bs = bs4.BeautifulSoup(requests.get(url).content)
        links = list(extract_links(url, bs))
        g = build_networkx_graph(url, links, output=output)
        self.assertTrue(g)

        output = StringIO.StringIO()
        write_nxgraph_to_dot(g, output)
        output.seek(0)
        print(output.read())
        output.seek(0)
        self.assertTrue(output.read())

        output = StringIO.StringIO()
        write_nxgraph_to_json(g, output)
        output.seek(0)
        print(output.read())
        output.seek(0)
        self.assertTrue(output.read())
        output.seek(0)
        with open('./force/force.json','w') as f:
            f.write(output.read())

        import matplotlib.pyplot as plt
        import networkx
        networkx.draw_circular(g)
        plt.savefig("awesome.svg")
开发者ID:BrendanMartin,项目名称:docs,代码行数:29,代码来源:crawl.py


示例15: draw_transmission_graph

    def draw_transmission_graph(self, positions=False):
        """
		This method draws the transmission graph to the screen using 
		matplotlib.

		INPUTS:
		-	BOOLEAN: positions
				If False: the circular layout will be drawn.

				If True: nodes will be restricted in the x-axis.

		"""

        # Step 1: Guarantee that transmission_graph is made.
        transmission_graph = deepcopy(self.relabeled_transmission_graph)

        # Step 2: Draw the graph according to the time-restricted layout or
        # circular layout.
        if positions == False:
            nx.draw_circular(transmission_graph)

        if positions == True:
            if self.node_draw_positions == None:
                positions = dict()
                for pathogen in self.pathogens:
                    positions[str(pathogen)] = (pathogen.creation_time, randint(0, 20))

                self.node_draw_positions = positions

            nx.draw(transmission_graph, pos=self.node_draw_positions)
开发者ID:ericmjl,项目名称:reassortment-simulation-and-reconstruction,代码行数:30,代码来源:simulator.py


示例16: draw_graph

    def draw_graph(self, G, node_list=None, edge_colour='k', node_size=15, node_colour='r', graph_type='spring',
                   back_bone=None, side_chains=None, terminators=None):
        # determine nodelist
        if node_list is None:
            node_list = G.nodes()
        # determine labels
        labels = {}
        for l_atom in G.nodes_iter():
            labels[l_atom] = l_atom.symbol

        # draw graphs based on graph_type
        if graph_type == 'circular':
            nx.draw_circular(G, with_labels=True, labels=labels, node_list=node_list, node_size=node_size,
                             edge_color=edge_colour, node_color=node_colour)
        elif graph_type == 'random':
            nx.draw_random(G, with_labels=True, labels=labels, node_list=node_list, node_size=node_size,
                           edge_color=edge_colour, node_color=node_colour)
        elif graph_type == 'spectral':
            nx.draw_spectral(G, with_labels=True, labels=labels, node_list=node_list, node_size=node_size,
                             edge_color=edge_colour, node_color=node_colour)
        elif graph_type == 'spring':
            nx.draw_spring(G, with_labels=True, labels=labels, node_list=node_list, node_size=node_size,
                           edge_color=edge_colour, node_color=node_colour)
        elif graph_type == 'shell':
            nx.draw_shell(G, with_labels=True, labels=labels, node_list=node_list, node_size=node_size,
                          edge_color=edge_colour, node_color=node_colour)
        # elif graph_type == 'protein':
        # self.draw_protein(G, with_labels=True, labels=labels, node_list=node_list, node_size=node_size,
        #                   edge_color=edge_colour, node_color=node_colour, back_bone, side_chains, terminators)
        else:
            nx.draw_networkx(G, with_labels=True, labels=labels, node_list=node_list, node_size=node_size,
                             edge_color=edge_colour, node_color=node_colour)
        plt.show()
开发者ID:cjforman,项目名称:pele,代码行数:33,代码来源:molecule.py


示例17: draw_helix_graph

 def draw_helix_graph(self):
     nx.draw_circular(self.graph, node_color="lightyellow", node_size=1000)
     pos = nx.circular_layout(self.graph)
     edge_labels = dict([((u,v,),d['label'])
                         for u,v,d in self.graph.edges(data=True)])
     nx.draw_networkx_edge_labels(self.graph, pos, edge_labels=edge_labels)
     plt.title("Crossover Locations for Staples")
开发者ID:akeshavan,项目名称:dnaworms,代码行数:7,代码来源:generator.py


示例18: A11

def A11():
    graph = generate_erdos_renyi(20, 10)
    nx.draw_circular(graph, edge_color = [e[2]['t'] for e in graph.edges(data=True)], 
                                 edge_cmap=plt.get_cmap("gray"), edge_vmax = 20, node_size=100)
    plt.figure()
    graph= generate_erdos_renyi(20, 10, graph)
    nx.draw_circular(graph, edge_color = [e[2]['t'] for e in graph.edges(data=True)], 
                                 edge_cmap=plt.get_cmap("gray"), edge_vmax = 20, node_size=100)
开发者ID:thomastaudt,项目名称:Network-Science,代码行数:8,代码来源:erdos_renyi.py


示例19: show

    def show(self):
        """ Plot the graph"""

        # nx.draw(self.G)
        #nx.draw_graphviz(self.G)
        #nx.draw_shell(self.G)
        nx.draw_circular(self.G)
        plt.draw()
        plt.show()
开发者ID:raphael0202,项目名称:dynamical_processes,代码行数:9,代码来源:network.py


示例20: main

def main():
    print("Graphing!")
    G = nx.Graph()
    G.add_nodes_from([1-3])
    G.add_edge(1, 2)

    nx.draw_random(G)
    nx.draw_circular(G)
    nx.draw_spectral(G)
    plt.show()
开发者ID:gorhack,项目名称:packet_malware,代码行数:10,代码来源:Grapher.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python networkx.draw_graphviz函数代码示例发布时间:2022-05-27
下一篇:
Python networkx.draw函数代码示例发布时间: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