當前位置: 首頁>>代碼示例>>Python>>正文


Python networkx.shell_layout方法代碼示例

本文整理匯總了Python中networkx.shell_layout方法的典型用法代碼示例。如果您正苦於以下問題:Python networkx.shell_layout方法的具體用法?Python networkx.shell_layout怎麽用?Python networkx.shell_layout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在networkx的用法示例。


在下文中一共展示了networkx.shell_layout方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: plot_graph

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import shell_layout [as 別名]
def plot_graph(G, ax=None):
    """
    Plots a networkx graph.

    Parameters
    ----------
    G:
        The networkx graph of interest.
    ax: Matplotlib axes object
        Defaults to None. Matplotlib axes to plot on.
    """

    weights = np.real([*nx.get_edge_attributes(G, 'weight').values()])
    pos = nx.shell_layout(G)

    nx.draw(G, pos, node_color='#A0CBE2', with_labels=True, edge_color=weights,
            width=4, edge_cmap=plt.cm.Blues, ax=ax)
    plt.show()


#############################################################################
# HAMILTONIANS AND DATA
############################################################################# 
開發者ID:entropicalabs,項目名稱:entropica_qaoa,代碼行數:25,代碼來源:utilities.py

示例2: draw_shell

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import shell_layout [as 別名]
def draw_shell(G, **kwargs):
    """Draw networkx graph with shell layout.

    Parameters
    ----------
    G : graph
       A networkx graph
    kwargs : optional keywords
       See hvplot.networkx.draw() for a description of optional
       keywords, with the exception of the pos parameter which is not
       used by this function.

    Returns
    -------
    graph : holoviews.Graph or holoviews.Overlay
       Graph element or Graph and Labels
    """
    nlist = kwargs.pop('nlist', None)
    if nlist is not None:
        kwargs['layout_kwargs'] = {'nlist': nlist}
    return draw(G, nx.shell_layout, **kwargs) 
開發者ID:holoviz,項目名稱:hvplot,代碼行數:23,代碼來源:networkx.py

示例3: test_smoke_int

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import shell_layout [as 別名]
def test_smoke_int(self):
        G = self.Gi
        vpos = nx.random_layout(G)
        vpos = nx.circular_layout(G)
        vpos = nx.planar_layout(G)
        vpos = nx.spring_layout(G)
        vpos = nx.fruchterman_reingold_layout(G)
        vpos = nx.fruchterman_reingold_layout(self.bigG)
        vpos = nx.spectral_layout(G)
        vpos = nx.spectral_layout(G.to_directed())
        vpos = nx.spectral_layout(self.bigG)
        vpos = nx.spectral_layout(self.bigG.to_directed())
        vpos = nx.shell_layout(G)
        if self.scipy is not None:
            vpos = nx.kamada_kawai_layout(G)
            vpos = nx.kamada_kawai_layout(G, dim=1) 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:18,代碼來源:test_layout.py

示例4: test_empty_graph

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import shell_layout [as 別名]
def test_empty_graph(self):
        G = nx.empty_graph()
        vpos = nx.random_layout(G, center=(1, 1))
        assert_equal(vpos, {})
        vpos = nx.circular_layout(G, center=(1, 1))
        assert_equal(vpos, {})
        vpos = nx.planar_layout(G, center=(1, 1))
        assert_equal(vpos, {})
        vpos = nx.bipartite_layout(G, G)
        assert_equal(vpos, {})
        vpos = nx.spring_layout(G, center=(1, 1))
        assert_equal(vpos, {})
        vpos = nx.fruchterman_reingold_layout(G, center=(1, 1))
        assert_equal(vpos, {})
        vpos = nx.spectral_layout(G, center=(1, 1))
        assert_equal(vpos, {})
        vpos = nx.shell_layout(G, center=(1, 1))
        assert_equal(vpos, {}) 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:20,代碼來源:test_layout.py

示例5: plot_graph

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import shell_layout [as 別名]
def plot_graph(G, filename='prova.png', values=None, colorbar_obj=None):
    
    func_types_dic = {
                'spring' : nx.spring_layout,
                'random' : nx.random_layout,
                'shell' : nx.shell_layout,
                'spectral' : nx.spectral_layout,
                'viz' : graphviz_layout
                }

    print(G.edges())
    print(G.nodes())

    fig = plt.figure(figsize=(10, 10))
    ax = fig.add_subplot(111)

    color_nodes = [values.get(node, 0.2) for node in G.nodes()] 

    pos = func_types_dic[params.plot_type_str](G)

    nodes = nx.draw_networkx_nodes(G, pos, node_color=color_nodes, \
            alpha=.6)#, cmap=plt.get_cmap('brg'))

    nx.draw_networkx_edges(G, pos, width=2.)
    nx.draw_networkx_labels(G, pos, font_color='k', font_weight='10')
    plt.title("|V| = %d, |E| = %d"%(len(G.nodes()), len(G.edges())))
    colorbar_obj.set_array(color_nodes)
    plt.colorbar(colorbar_obj)
    plt.axis('off')
    fig.savefig(filename, format='png')
    plt.close() 
開發者ID:ksanjeevan,項目名稱:mapper-tda,代碼行數:33,代碼來源:em_help.py

示例6: test_smoke_int

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import shell_layout [as 別名]
def test_smoke_int(self):
        G=self.Gi
        vpos=nx.random_layout(G)
        vpos=nx.circular_layout(G)
        vpos=nx.spring_layout(G)
        vpos=nx.fruchterman_reingold_layout(G)
        vpos=nx.spectral_layout(G)
        vpos=nx.spectral_layout(self.bigG)
        vpos=nx.shell_layout(G) 
開發者ID:SpaceGroupUCL,項目名稱:qgisSpaceSyntaxToolkit,代碼行數:11,代碼來源:test_layout.py

示例7: test_smoke_string

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import shell_layout [as 別名]
def test_smoke_string(self):
        G = self.Gs
        vpos = nx.random_layout(G)
        vpos = nx.circular_layout(G)
        vpos = nx.spring_layout(G)
        vpos = nx.fruchterman_reingold_layout(G)
        vpos = nx.spectral_layout(G)
        vpos = nx.shell_layout(G) 
開發者ID:SpaceGroupUCL,項目名稱:qgisSpaceSyntaxToolkit,代碼行數:10,代碼來源:test_layout.py

示例8: test_empty_graph

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import shell_layout [as 別名]
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:SpaceGroupUCL,項目名稱:qgisSpaceSyntaxToolkit,代碼行數:16,代碼來源:test_layout.py

示例9: test_single_node

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import shell_layout [as 別名]
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:SpaceGroupUCL,項目名稱:qgisSpaceSyntaxToolkit,代碼行數:17,代碼來源:test_layout.py

示例10: test_scale_and_center_arg

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import shell_layout [as 別名]
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:SpaceGroupUCL,項目名稱:qgisSpaceSyntaxToolkit,代碼行數:28,代碼來源:test_layout.py

示例11: test_smoke_empty_graph

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import shell_layout [as 別名]
def test_smoke_empty_graph(self):
        G = []
        vpos = nx.random_layout(G)
        vpos = nx.circular_layout(G)
        vpos = nx.planar_layout(G)
        vpos = nx.spring_layout(G)
        vpos = nx.fruchterman_reingold_layout(G)
        vpos = nx.spectral_layout(G)
        vpos = nx.shell_layout(G)
        vpos = nx.bipartite_layout(G, G)
        if self.scipy is not None:
            vpos = nx.kamada_kawai_layout(G) 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:14,代碼來源:test_layout.py

示例12: test_smoke_string

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import shell_layout [as 別名]
def test_smoke_string(self):
        G = self.Gs
        vpos = nx.random_layout(G)
        vpos = nx.circular_layout(G)
        vpos = nx.planar_layout(G)
        vpos = nx.spring_layout(G)
        vpos = nx.fruchterman_reingold_layout(G)
        vpos = nx.spectral_layout(G)
        vpos = nx.shell_layout(G)
        if self.scipy is not None:
            vpos = nx.kamada_kawai_layout(G)
            vpos = nx.kamada_kawai_layout(G, dim=1) 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:14,代碼來源:test_layout.py

示例13: test_scale_and_center_arg

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import shell_layout [as 別名]
def test_scale_and_center_arg(self):
        sc = self.check_scale_and_center
        c = (4, 5)
        G = nx.complete_graph(9)
        G.add_node(9)
        sc(nx.random_layout(G, center=c), scale=0.5, center=(4.5, 5.5))
        # rest can have 2*scale length: [-scale, scale]
        sc(nx.spring_layout(G, scale=2, center=c), scale=2, center=c)
        sc(nx.spectral_layout(G, scale=2, center=c), scale=2, center=c)
        sc(nx.circular_layout(G, scale=2, center=c), scale=2, center=c)
        sc(nx.shell_layout(G, scale=2, center=c), scale=2, center=c)
        if self.scipy is not None:
            sc(nx.kamada_kawai_layout(G, scale=2, center=c), scale=2, center=c) 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:15,代碼來源:test_layout.py

示例14: test_default_scale_and_center

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import shell_layout [as 別名]
def test_default_scale_and_center(self):
        sc = self.check_scale_and_center
        c = (0, 0)
        G = nx.complete_graph(9)
        G.add_node(9)
        sc(nx.random_layout(G), scale=0.5, center=(0.5, 0.5))
        sc(nx.spring_layout(G), scale=1, center=c)
        sc(nx.spectral_layout(G), scale=1, center=c)
        sc(nx.circular_layout(G), scale=1, center=c)
        sc(nx.shell_layout(G), scale=1, center=c)
        if self.scipy is not None:
            sc(nx.kamada_kawai_layout(G), scale=1, center=c) 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:14,代碼來源:test_layout.py

示例15: test_single_nodes

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import shell_layout [as 別名]
def test_single_nodes(self):
        G = nx.path_graph(1)
        vpos = nx.shell_layout(G)
        assert_false(vpos[0].any())
        G = nx.path_graph(3)
        vpos = nx.shell_layout(G, [[0], [1, 2]])
        assert_false(vpos[0].any()) 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:9,代碼來源:test_layout.py


注:本文中的networkx.shell_layout方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。