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

Python networkx.random_layout函数代码示例

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

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



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

示例1: test_scale_and_center_arg

    def test_scale_and_center_arg(self):
        G = nx.complete_graph(9)
        G.add_node(9)
        vpos = nx.random_layout(G, scale=2, center=(4,5))
        self.check_scale_and_center(vpos, scale=2, center=(4,5))
        vpos = nx.spring_layout(G, scale=2, center=(4,5))
        self.check_scale_and_center(vpos, scale=2, center=(4,5))
        vpos = nx.spectral_layout(G, scale=2, center=(4,5))
        self.check_scale_and_center(vpos, scale=2, center=(4,5))
        # circular can have twice as big length
        vpos = nx.circular_layout(G, scale=2, center=(4,5))
        self.check_scale_and_center(vpos, scale=2*2, center=(4,5))
        vpos = nx.shell_layout(G, scale=2, center=(4,5))
        self.check_scale_and_center(vpos, scale=2*2, center=(4,5))

        # check default center and scale
        vpos = nx.random_layout(G)
        self.check_scale_and_center(vpos, scale=1, center=(0.5,0.5))
        vpos = nx.spring_layout(G)
        self.check_scale_and_center(vpos, scale=1, center=(0.5,0.5))
        vpos = nx.spectral_layout(G)
        self.check_scale_and_center(vpos, scale=1, center=(0.5,0.5))
        vpos = nx.circular_layout(G)
        self.check_scale_and_center(vpos, scale=2, center=(0,0))
        vpos = nx.shell_layout(G)
        self.check_scale_and_center(vpos, scale=2, center=(0,0))
开发者ID:JFriel,项目名称:honours_project,代码行数:26,代码来源:test_layout.py


示例2: generateNetworkCoordinates

def generateNetworkCoordinates(G, forRadius=4, forSize=(800,600)):#, layout='dot'):
    '''
    """
    generates network coordinates in the attribute 'pos'
    :param G:
    :Param layout: neato|dot|twopi|circo|fdp|nop
    :return:
    """
    ag = networkx.nx_agraph.to_agraph(G)
    ag.layout(prog=layout)
    ag.write(path='dot.dot')
    G = networkx.nx_agraph.from_agraph(ag)
    '''
    import networkx as nx
    if forSize[0] > forSize[1]:
        scale = 1.0-(float(forRadius)/float(forSize[1]))
    else:
        scale = 1.0-(float(forRadius)/float(forSize[0]))

    try:
        G = nx.random_layout(G, dim=2, scale=scale, center=(0,0))
    except TypeError: # Fixes the problem of having another version of nx
        G = nx.random_layout(G, dim=2)
        for (key,(x,y)) in G.items():
            x = 2 * x - 1
            y = 2 * y - 1
            G[key] = [x,y]

    return G
开发者ID:etteerr,项目名称:NeuronNet,代码行数:29,代码来源:python27Ca2VideoMaker.py


示例3: simplePlot

def simplePlot(graph, layout = "shell", nodeSize= 600, widthEdge=2):
    """ Plot a directed graph using igraph library.
        
        @type graph: graph
        @param graph: a graph to plot
        @type layout: string
        @param layout: node position method (shell, circular, random, spring, spectral)

    """
    G=nx.DiGraph()
    for node in graph.keys():
        G.add_node(node)
  
    #add edges
    for v1 in graph.keys():
       for v2 in graph[v1]:
          G.add_edge(v1, v2)
  
    # draw graph
    if layout == 'circular':
      pos = nx.circular_layout(G)
    elif layout == 'random':
      pos = nx.random_layout(G)
    elif layout == 'spring':
      pos = nx.random_layout(G)
    elif layout == 'spectral':
      pos = nx.spectral_layout(G)
    else:
      pos = nx.shell_layout(G)
  
    nx.draw(G, pos, edge_color='#796d54', alpha=1, node_color='#4370D8',cmap=plt.cm.Blues, node_size=nodeSize, width=widthEdge)
  
    plt.show()
开发者ID:emanuelepesce,项目名称:NetworksSimulator,代码行数:33,代码来源:drawGraph.py


示例4: test_empty_graph

 def test_empty_graph(self):
     G=nx.Graph()
     vpos = nx.random_layout(G)
     vpos = nx.circular_layout(G)
     vpos = nx.spring_layout(G)
     vpos = nx.fruchterman_reingold_layout(G)
     vpos = nx.shell_layout(G)
     vpos = nx.spectral_layout(G)
     # center arg
     vpos = nx.random_layout(G, scale=2, center=(4,5))
     vpos = nx.circular_layout(G, scale=2, center=(4,5))
     vpos = nx.spring_layout(G, scale=2, center=(4,5))
     vpos = nx.shell_layout(G, scale=2, center=(4,5))
     vpos = nx.spectral_layout(G, scale=2, center=(4,5))
开发者ID:JFriel,项目名称:honours_project,代码行数:14,代码来源:test_layout.py


示例5: test_single_node

 def test_single_node(self):
     G = nx.Graph()
     G.add_node(0)
     vpos = nx.random_layout(G)
     vpos = nx.circular_layout(G)
     vpos = nx.spring_layout(G)
     vpos = nx.fruchterman_reingold_layout(G)
     vpos = nx.shell_layout(G)
     vpos = nx.spectral_layout(G)
     # center arg
     vpos = nx.random_layout(G, scale=2, center=(4,5))
     vpos = nx.circular_layout(G, scale=2, center=(4,5))
     vpos = nx.spring_layout(G, scale=2, center=(4,5))
     vpos = nx.shell_layout(G, scale=2, center=(4,5))
     vpos = nx.spectral_layout(G, scale=2, center=(4,5))
开发者ID:JFriel,项目名称:honours_project,代码行数:15,代码来源:test_layout.py


示例6: draw_graph

    def draw_graph(self):
        """
            Draws the graph of relations
        """
        G=nx.Graph()
        
        list_location1 = []
        list_location2 = []
        list_location3 = []
        list_location4 = []
        
        for citizen in self.citizens:
            G.add_node(citizen.id)
            if citizen.location == 1:
                list_location1.append(citizen.id)
            elif citizen.location == 2:
                list_location2.append(citizen.id)
            elif citizen.location == 3:
                list_location3.append(citizen.id)
            else: 
                list_location4.append(citizen.id)

        for citizen in self.citizens:
            for friend in citizen.friends:
                G.add_edge(citizen.id,friend.id)

        pos = nx.random_layout(G)
        nx.draw_networkx_nodes(G,pos,node_size=60,nodelist=list_location1, node_color='r')
        nx.draw_networkx_nodes(G,pos,node_size=60,nodelist=list_location2, node_color='g')
        nx.draw_networkx_nodes(G,pos,node_size=60,nodelist=list_location3, node_color='b')
        nx.draw_networkx_nodes(G,pos,node_size=60,nodelist=list_location4, node_color='y')
        nx.draw_networkx_edges(G,pos, width=1)

        plt.show()
开发者ID:guilhermeamorim,项目名称:neodemocracy,代码行数:34,代码来源:simulator.py


示例7: display_community_graph

 def display_community_graph(self):
     """
     Display the subgraph identified by community detection
     """
     plt.figure(num=None, figsize=(70, 50), dpi=80)
     up_pos_cnm=nx.random_layout(user_post_graph_cnm)
     for (idx, comm) in enumerate(self.sig_communities_by_id):
         comm_u_cnm = []
         comm_p_cnm = []
         for n in self.all_post_users:
             if n in comm:
                 comm_u_cnm.append(n)
         for n in self.all_posts_res:
             if n in comm:
                 comm_p_cnm.append(n)
         nx.draw_networkx_nodes(self.user_post_graph_cnm,up_pos_cnm,
                                nodelist=comm_u_cnm,
                                node_color=self.group_colors[idx],
                                alpha=0.8)
         nx.draw_networkx_nodes(self.user_post_graph_cnm,up_pos_cnm,
                                nodelist=comm_p_cnm,
                                node_color=self.group_colors[idx],
                                alpha=0.8)
         elsg1_cnm = [e for e in self.up_likes if e[0] in comm_u_cnm and e[1] in comm_p_cnm]
         ecsg1_cnm = [e for e in self.up_comments if e[0] in comm_u_cnm and e[1] in comm_p_cnm]
         epsg1_cnm = [e for e in self.up_posts if e[0] in comm_u_cnm and e[1] in comm_p_cnm]
         nx.draw_networkx_edges(self.user_post_graph_cnm,up_pos,edgelist=elsg1_cnm,alpha=0.5,edge_color='m')
         nx.draw_networkx_edges(self.user_post_graph_cnm,up_pos,edgelist=ecsg1_cnm,alpha=0.5,edge_color='teal')
         nx.draw_networkx_edges(self.user_post_graph_cnm,up_pos,edgelist=epsg1_cnm,alpha=0.5,edge_color='y')
开发者ID:charlescearl,项目名称:blogs,代码行数:29,代码来源:graph_analysis.py


示例8: draw_graph

def draw_graph(graph, labels=None, graph_layout='spring',
               node_size=1600, node_color='blue', node_alpha=0.3,
               node_text_size=12,
               edge_color='blue', edge_alpha=0.3, edge_tickness=1,
               edge_text_pos=0.3,
               text_font='sans-serif'):

	# create networkx graph
	G=nx.Graph()
	# add edges
	for edge in graph:
		G.add_edge(edge[0], edge[1])

	# these are different layouts for the network you may try
	if graph_layout == 'spring':
		graph_pos=nx.spring_layout(G)
	elif graph_layout == 'spectral':
		graph_pos=nx.spectral_layout(G)
	elif graph_layout == 'random':
		graph_pos=nx.random_layout(G)
	else:
		graph_pos=nx.shell_layout(G)

	# draw graph
	nx.draw_networkx_nodes(G,graph_pos,node_size=node_size, alpha=node_alpha, node_color=node_color)
	nx.draw_networkx_edges(G,graph_pos,width=edge_tickness, alpha=edge_alpha,edge_color=edge_color)
	nx.draw_networkx_labels(G, graph_pos,font_size=node_text_size,font_family=text_font)

	plt.show()
开发者ID:yh1008,项目名称:socialNetwork,代码行数:29,代码来源:social_graph.py


示例9: calcMetrics

def calcMetrics():
    print('\nTrips:')
    for trip in trips:
        trip.display()
    print('\nPairs:')
    for a, b in itertools.combinations(trips, 2):
        # if isTimeTestFail(): continue
        bestDist = getBestDist(a, b)
        sumDist = a.dist + b.dist
        if bestDist > sumDist: continue
        minDist = min(a.dist, b.dist)
        maxDist = max(a.dist, b.dist)
        delta = sumDist - bestDist
        coPathCoeff = maxDist / bestDist
        effect = delta / bestDist
        weight = effect * coPathCoeff
        G.add_edge(a, b, weight=weight)
        print('edge is added', weight)

    pos = nx.random_layout(G)
    nx.draw_networkx_nodes(G, pos)
    nx.draw_networkx_edges(G, pos, width=weight,)
    plt.axis('off')
    plt.savefig("weighted_graph.png")  # save as png
    plt.show()  # display
开发者ID:LukeSkypewalker,项目名称:Python,代码行数:25,代码来源:metrica.py


示例10: draw_graph

def draw_graph(G, labels=None, graph_layout='shell',
               node_size=1600, node_color='blue', node_alpha=0.3,
               node_text_size=12,
               edge_color='blue', edge_alpha=0.3, edge_tickness=1,
               edge_text_pos=0.3,
               text_font='sans-serif'):

    # these are different layouts for the network you may try
    # shell seems to work best
    if graph_layout == 'spring':
        graph_pos=nx.spring_layout(G)
    elif graph_layout == 'spectral':
        graph_pos=nx.spectral_layout(G)
    elif graph_layout == 'random':
        graph_pos=nx.random_layout(G)
    else:
        graph_pos=nx.shell_layout(G)
    # draw graph
    nx.draw_networkx_nodes(G,graph_pos,node_size=node_size, 
                           alpha=node_alpha, node_color=node_color)
    nx.draw_networkx_edges(G,graph_pos,width=edge_tickness,
                           alpha=edge_alpha,edge_color=edge_color)
    nx.draw_networkx_labels(G, graph_pos,font_size=node_text_size,
                            font_family=text_font)
    nx.draw_networkx_edge_labels(G, graph_pos, edge_labels=labels, 
                                 label_pos=edge_text_pos)
    # show graph
    frame = plt.gca()
    frame.axes.get_xaxis().set_visible(False)
    frame.axes.get_yaxis().set_visible(False)

    plt.show()
开发者ID:alanshutko,项目名称:hia-examples,代码行数:32,代码来源:disease_graph.py


示例11: test_layouts

def test_layouts():
    G =nx.gnm_random_graph(10,15)

    rand = [nx.random_layout(G)]
    circ = [nx.circular_layout(G)]
    #shell = [nx.shell_layout(G)] #same as circular layout...
    spectral = [nx.spectral_layout(G)]
    tripod = [tripod_layout(G)]

    layouts = [rand,circ,spectral, tripod]
    regimes = ["random","circular","spectral", "tripod"]

    for layout in layouts:
        layout.append(nx.spring_layout(G,2,layout[0]))
        layout.append(iterate_swaps(G,layout[0]))
        layout.append(nx.spring_layout(G,2,layout[2]))
        layout.append(greedy_swapper(G,layout[0]))

    # Now have list of lists... Find lengths of edgecrossings...

    num_crossings = []
    for layout in layouts:
        for sublayout in layout:
            num_crossings.append(count_crosses(G,sublayout))

    names = []
    for regime in regimes:
        names.append(regime)
        names.append(regime + "-spring")
        names.append(regime + "-swap")
        names.append(regime + "-swap-spr")
        names.append(regime + "-greedy")

    return G, layouts, names, num_crossings
开发者ID:natlund,项目名称:disentangler,代码行数:34,代码来源:disentangler.py


示例12: draw_graph

def draw_graph(graph, labels=None, graph_layout='shell',
               node_size=120, node_color='blue', node_alpha=0.3,
               node_text_size=8,
               edge_color='blue', edge_alpha=0.3, edge_tickness=1,
               edge_text_pos=0.3,
               text_font='sans-serif'):

    # create networkx graph
    G=nx.Graph()

    # add edges
    for edge in graph:
        G.add_edge(edge[0], edge[1])

    print G.nodes()

    nodeColors = []
    nodeClients = []
    for node in G.nodes():
	if is_number(node):
		nodeColors.append(0)
	else:
		nodeColors.append(1)
		nodeClients.append(node)

    edgeColors = []
    for edge in G.edges():
	if (edge[0] in nodeClients) or (edge[1] in nodeClients):
		edgeColors.append(1)
	else:
		edgeColors.append(0)

    # these are different layouts for the network you may try
    # shell seems to work best
    if graph_layout == 'spring':
        graph_pos=nx.spring_layout(G)
    elif graph_layout == 'spectral':
        graph_pos=nx.spectral_layout(G)
    elif graph_layout == 'random':
        graph_pos=nx.random_layout(G)
    else:
        graph_pos=nx.shell_layout(G)

    # draw graph
    nx.draw_networkx_nodes(G,graph_pos,node_size=node_size, 
                           alpha=node_alpha, node_color=nodeColors)
    nx.draw_networkx_edges(G,graph_pos,width=edge_tickness,
                           alpha=edge_alpha,edge_color=edgeColors)
    nx.draw_networkx_labels(G, graph_pos,font_size=node_text_size,
                            font_family=text_font, font_weight='normal', alpha=1.0)

    # if labels is None:
    #    labels = range(len(graph))

    # edge_labels = dict(zip(graph, labels))
    # nx.draw_networkx_edge_labels(G, graph_pos, edge_labels=edge_labels, 
    #                             label_pos=edge_text_pos)

    # show graph
    plt.show()
开发者ID:ephemeral2eternity,项目名称:parseTopology,代码行数:60,代码来源:drawNetwork.py


示例13: opti

def opti(nodeList, colorList, edgeList, cList, firstDistance):
    #Only recheck for node with new color
    for i in range(10):    
        v = random.randint(0, len(nodeList))
        
        currentDistance = 0
                
        cListBis = cList
        cListBis.pop(i)
        newColor = random.choice(cListBis)
        colorList[i] = newColor
        
        newDistance = 0
        for (u,v) in graph.edges():
            if graph.node[u]['color'] == graph.node[v]['color']:
                newDistance += 1
        
        if newDistance <= distance :
            pos=nx.random_layout(graph)
            plt.figure(3,figsize=(12,9))          
            for nodes in graph.nodes():
                nx.draw_networkx_nodes(graph, pos, nodelist=[nodes], node_color=graph.node[nodes]['color'])
            nx.draw_networkx_edges(graph, pos)      
            plt.axis('off')
            plt.draw()    
开发者ID:fonfonx,项目名称:GraphColoring,代码行数:25,代码来源:Project.py


示例14: draw_graph

def draw_graph(G, labels=None, graph_layout='shell',
               node_size=1600, node_color='blue', node_alpha=0.3,
               node_text_size=12,
               edge_color='blue', edge_alpha=0.3, edge_tickness=1,
               edge_text_pos=0.3,
               text_font='sans-serif'):

    # these are different layouts for the network you may try
    # shell seems to work best
    if graph_layout == 'spring':
        graph_pos=nx.spring_layout(G)
    elif graph_layout == 'spectral':
        graph_pos=nx.spectral_layout(G)
    elif graph_layout == 'random':
        graph_pos=nx.random_layout(G)
    else:
        graph_pos=nx.shell_layout(G)

    # draw graph
    nx.draw_networkx_nodes(G,graph_pos,node_size=node_size, 
                           alpha=node_alpha, node_color=node_color)
    nx.draw_networkx_edges(G,graph_pos,width=edge_tickness,
                           alpha=edge_alpha,edge_color=edge_color)
    nx.draw_networkx_labels(G, graph_pos,font_size=node_text_size,
                            font_family=text_font)

    if labels is None:
        labels = range(len(G))

    edge_labels = dict(zip(G, labels))
    nx.draw_networkx_edge_labels(G, graph_pos, edge_labels=labels, 
                                 label_pos=edge_text_pos)

    # show graph
    plt.show()
开发者ID:RenanGreca,项目名称:wireless-networks,代码行数:35,代码来源:dijkstra.py


示例15: draw_graph

def draw_graph(graph):

    # extract nodes from graph
    nodes = set([n1 for n1, n2 in graph] + [n2 for n1, n2 in graph])

    # create networkx graph
    G=nx.Graph()
    #G=nx.cubical_graph()

    # add nodes
    for node in nodes:
        G.add_node(node)

    # add edges
    for edge in graph:
        G.add_edge(edge[0], edge[1])

    # draw graph
    #pos = nx.shell_layout(G)
    #pos = nx.spectral_layout(G)
    pos = nx.random_layout(G) # Funciona melhor
    #pos = nx.circular_layout(G) # Mais ou menos
    #pos = nx.fruchterman_reingold_layout(G) # Funciona melhor

    #nx.draw(G, pos)
    nx.draw_networkx(G)

    # show graph
    plt.axis('off')
    plt.show()
开发者ID:AnaSLCaldeira,项目名称:EADW,代码行数:30,代码来源:graph_functions.py


示例16: draw_graph

def draw_graph(graph, graph_layout='shell',
               node_size=1600, node_color='blue', node_alpha=0.3, node_text_size=12,
               edge_color='blue', edge_alpha=0.3, edge_tickness=1, edge_text_pos=0.3,
               text_font='sans-serif', save=True, filename=None):

    edge_labels=dict([((u,v,),d['weight']) for u,v,d in graph.edges(data=True)])
    # these are different layouts for the network you may try
    # shell seems to work best
    if graph_layout == 'spring':
        graph_pos=nx.spring_layout(graph)
    elif graph_layout == 'spectral':
        graph_pos=nx.spectral_layout(graph)
    elif graph_layout == 'random':
        graph_pos=nx.random_layout(graph)
    elif graph_layout == 'circular':
        graph_pos=nx.circular_layout(graph)
    else:
        graph_pos=nx.shell_layout(graph)

    # draw graph
    nx.draw_networkx_nodes(graph, graph_pos, node_size=node_size, alpha=node_alpha, node_color=node_color)
    nx.draw_networkx_edges(graph, graph_pos, width=edge_tickness, alpha=edge_alpha, edge_color=edge_color)
    nx.draw_networkx_labels(graph, graph_pos, font_size=node_text_size, font_family=text_font)
    nx.draw_networkx_edge_labels(graph, graph_pos, edge_labels=edge_labels, label_pos=edge_text_pos)

    # show graph
    if save == True:
        plt.savefig(filename, dpi=1000)
    plt.show()
开发者ID:AdrienGuille,项目名称:EGC-Cup-2016,代码行数:29,代码来源:collaboration_graph.py


示例17: draw_graph

 def draw_graph(self, type):
     val_map = {}
     if type == 'whole':
         for user in self.extr_dic_users:
             if self.extr_dic_users[user] == 'c':
                 val_map.update({ user : 'r'})
             elif self.extr_dic_users[user] == 'n':
                 val_map.update({ user : 'b'})
             else:
                 val_map.update({ user : 'g'})
         #for user in self.extr_dic_users:
         #    val_map.update({ user : 'g'})
         self.m_extr_G = self.m_extr_G.to_undirected()
         values = [val_map.get(node) for node in self.m_extr_G.nodes()]
         nx.draw(self.m_extr_G, pos = nx.random_layout(self.m_extr_G, dim = 2), randomcmap = plt.get_cmap('jet'), node_color = values, width = 1, node_size = 40, with_labels=False)
         plt.show()
     elif type == 'internal':
         for user in self.dic_users:
             if self.dic_users[user][1] == 'c':
                 val_map.update({ user : 'r'})
             else:
                 val_map.update({ user : 'b'})
         #for user in self.extr_dic_users:
         #    val_map.update({ user : 'g'})
         #self.G = self.G.to_undirected()
         values = [val_map.get(node) for node in self.m_G.nodes()]
         nx.draw(self.m_G, pos = nx.spring_layout(self.m_G, dim = 2), randomcmap = plt.get_cmap('jet'), node_color = values, width = 1, node_size = 200, with_labels=True)
         plt.show()
开发者ID:huangbolun,项目名称:ElectionTweetsAnalysis,代码行数:28,代码来源:mention_graph.py


示例18: draw_graph

def draw_graph(G):
    """
    @type G: DiGraph
    @param G: DiGraph
    """
    nx.draw(G, pos = nx.random_layout(G, dim = 2), randomcmap = plt.get_cmap('jet'), node_color = "blue", alpha = 0.5, width = 1, node_size = 400, with_labels=True)
    plt.show()
开发者ID:JohnaLiu,项目名称:topic_tweet_analysis,代码行数:7,代码来源:hits.py


示例19: draw_graph

def draw_graph(graph, labels=None, graph_layout='shell',
               node_size=1600, node_color='blue', node_alpha=0.3,
               node_text_size=12,
               edge_color='blue', edge_alpha=0.3, edge_tickness=1,
               edge_text_pos=0.3,
               text_font='sans-serif'):

    # create networkx graph
    G=nx.Graph()

    # add edges
    for edge in graph:
        G.add_edge(edge[0], edge[1])

    # these are different layouts for the network you may try
    # shell seems to work best
    if graph_layout == 'spring':
        graph_pos=nx.spring_layout(G)
    elif graph_layout == 'spectral':
        graph_pos=nx.spectral_layout(G)
    elif graph_layout == 'random':
        graph_pos=nx.random_layout(G)
    else:
        graph_pos=nx.shell_layout(G)

    nx.draw(G)
    #nx.draw_random(G)
    #nx.draw_spectral(G)
    # show graph

    newFolder = graphPath
    if not os.path.exists(newFolder):
        os.makedirs(newFolder)
    plt.savefig(newFolder+anchor+"Network.png")
开发者ID:Israel-Andrade,项目名称:Project2CST205,代码行数:34,代码来源:networkMap.py


示例20: communities_histogram

def communities_histogram(graph, verbose=False):
    graph, partition = detect_communities(graph, verbose)

    #plt.hist(partition.values(), bins=25, color="#0f6dbc")
    #plt.title("Size of Marvel Communities")
    #plt.xlabel("Community")
    #plt.ylabel("Nodes")

    parts = defaultdict(int)
    for part in partition.values():
        parts[part] += 1

    bubbles = nx.Graph()
    for part in parts.items():
        bubbles.add_node(part[0], size=part[1])

    pos = nx.random_layout(bubbles)
    plt.figure(figsize=(12,12))
    plt.axis('off')

    nx.draw_networkx_nodes(bubbles, pos,
        alpha=0.6, node_size=map(lambda x: x*6, parts.values()),
        node_color=[random.random() for x in parts.values()], cmap=plt.cm.RdYlBu)

    #plt.show()
    plt.savefig("figure/communities_histogram_alt.png")
开发者ID:saltfog,项目名称:r-code,代码行数:26,代码来源:cluster.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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