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


Python networkx.circular_layout方法代碼示例

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


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

示例1: draw_transmat_graph_inner

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import circular_layout [as 別名]
def draw_transmat_graph_inner(G, edge_threshold=0, lw=1, ec='0.2', node_size=15):

    num_states = G.number_of_nodes()

    edgewidth = [ d['weight'] for (u,v,d) in G.edges(data=True)]
    edgewidth = np.array(edgewidth)
    edgewidth[edgewidth<edge_threshold] = 0

    npos=circular_layout(G, scale=1, direction='CW')

    nx.draw_networkx_edges(G, npos, alpha=1.0, width=edgewidth*lw, edge_color=ec)

    nx.draw_networkx_nodes(G, npos, node_size=node_size, node_color='k',alpha=1.0)
    ax = plt.gca()
    ax.set_aspect('equal')

    return ax 
開發者ID:nelpy,項目名稱:nelpy,代碼行數:19,代碼來源:graph.py

示例2: draw_circular

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import circular_layout [as 別名]
def draw_circular(G, **kwargs):
    """Draw networkx graph with circular 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
    """
    return draw(G, pos=nx.circular_layout, **kwargs) 
開發者ID:holoviz,項目名稱:hvplot,代碼行數:20,代碼來源:networkx.py

示例3: test_smoke_int

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import circular_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 circular_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 circular_layout [as 別名]
def plot_graph(call_graph: nx.Graph, size: Tuple[int, int] = (10, 10)):
    """
    Plot circular graph using matplotlib.

    Parameters
    ----------
    call_graph : nx.Graph
        The graph to plot.
    size : Tuple[int, int]
        size of plot, default is(10,10)

    """
    # if circos:
    #     c = CircosPlot(
    #         call_graph,
    #         node_color='degree',
    #         node_grouping='degree',
    #         node_order="degree",
    #         node_labels=True,
    #         fontsize="large",
    #         node_label_layout="rotation",
    #         figsize=(20,20)
    #     )
    #     c.draw()
    # else:
    pos = nx.circular_layout(call_graph)
    nx.draw_networkx(call_graph, pos=pos)
    plt.gcf().set_size_inches(size)
    plt.show() 
開發者ID:microsoft,項目名稱:msticpy,代碼行數:31,代碼來源:module_tree.py

示例6: draw_transmat_graph

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import circular_layout [as 別名]
def draw_transmat_graph(G, edge_threshold=0, lw=1, ec='0.2', node_size=15):

    num_states = G.number_of_nodes()

    edgewidth = [ d['weight'] for (u,v,d) in G.edges(data=True)]
    edgewidth = np.array(edgewidth)
    edgewidth[edgewidth<edge_threshold] = 0

    labels = {}
    labels[0] = '1'
    labels[1]= '2'
    labels[2]= '3'
    labels[num_states-1] = str(num_states)

    npos=circular_layout(G, scale=1, direction='CW')
    lpos=circular_layout(G, scale=1.15, direction='CW')

    nx.draw_networkx_edges(G, npos, alpha=0.8, width=edgewidth*lw, edge_color=ec)

    nx.draw_networkx_nodes(G, npos, node_size=node_size, node_color='k',alpha=0.8)
    ax = plt.gca()
    nx.draw_networkx_labels(G, lpos, labels, fontsize=18, ax=ax); # fontsize does not seem to work :/

    ax.set_aspect('equal')

    return ax 
開發者ID:nelpy,項目名稱:nelpy,代碼行數:28,代碼來源:graph.py

示例7: double_circular_layout

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import circular_layout [as 別名]
def double_circular_layout(Gi, scale=1, center=None, dim=2, direction='CCW'):
    inner=circular_layout(Gi, center=center, dim=dim, scale=scale, direction=direction)
    outer=circular_layout(Gi, center=center, dim=dim, scale=scale*1.3, direction=direction)

    num_states = Gi.number_of_nodes()

    npos = {}
    for k in outer.keys():
        npos[k+num_states] = outer[k]

    npos.update(inner)

    return npos 
開發者ID:nelpy,項目名稱:nelpy,代碼行數:15,代碼來源:graph.py

示例8: _plot_graph

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import circular_layout [as 別名]
def _plot_graph(graph, axis, weights=None, display_edge_labels=True):
    """Plot graph using networkx."""
    pos = nx.circular_layout(graph)
    nx.draw_circular(graph, with_labels=True, node_size=600, alpha=1.0,
                     ax=axis, node_color='Gainsboro', hold=True, font_size=14,
                     font_weight='bold')
    if display_edge_labels:
        edge_labels = nx.get_edge_attributes(graph, weights)
        nx.draw_networkx_edge_labels(graph, pos, edge_labels=edge_labels,
                                     font_size=13)  # font_weight='bold' 
開發者ID:pwollstadt,項目名稱:IDTxl,代碼行數:12,代碼來源:visualise_graph.py

示例9: setUp

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import circular_layout [as 別名]
def setUp(self):
        N = 8
        self.nodes = circular_layout(np.arange(N))
        self.source = np.arange(N, dtype=np.int32)
        self.target = np.zeros(N, dtype=np.int32)
        self.edge_info = np.arange(N)
        self.graph = Graph(((self.source, self.target),)) 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:9,代碼來源:testgraphelement.py

示例10: test_from_networkx_with_node_attrs

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import circular_layout [as 別名]
def test_from_networkx_with_node_attrs(self):
        import networkx as nx
        G = nx.karate_club_graph()
        graph = Graph.from_networkx(G, nx.circular_layout)
        clubs = np.array([
            'Mr. Hi', 'Mr. Hi', 'Mr. Hi', 'Mr. Hi', 'Mr. Hi', 'Mr. Hi',
            'Mr. Hi', 'Mr. Hi', 'Mr. Hi', 'Officer', 'Mr. Hi', 'Mr. Hi',
            'Mr. Hi', 'Mr. Hi', 'Officer', 'Officer', 'Mr. Hi', 'Mr. Hi',
            'Officer', 'Mr. Hi', 'Officer', 'Mr. Hi', 'Officer', 'Officer',
            'Officer', 'Officer', 'Officer', 'Officer', 'Officer', 'Officer',
            'Officer', 'Officer', 'Officer', 'Officer'])
        self.assertEqual(graph.nodes.dimension_values('club'), clubs) 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:14,代碼來源:testgraphelement.py

示例11: test_from_networkx_with_invalid_node_attrs

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import circular_layout [as 別名]
def test_from_networkx_with_invalid_node_attrs(self):
        import networkx as nx
        FG = nx.Graph()
        FG.add_node(1, test=[])
        FG.add_node(2, test=[])
        FG.add_edge(1, 2)
        graph = Graph.from_networkx(FG, nx.circular_layout)
        self.assertEqual(graph.nodes.vdims, [])
        self.assertEqual(graph.nodes.dimension_values(2), np.array([1, 2]))
        self.assertEqual(graph.array(), np.array([(1, 2)])) 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:12,代碼來源:testgraphelement.py

示例12: test_from_networkx_with_edge_attrs

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import circular_layout [as 別名]
def test_from_networkx_with_edge_attrs(self):
        import networkx as nx
        FG = nx.Graph()
        FG.add_weighted_edges_from([(1,2,0.125), (1,3,0.75), (2,4,1.2), (3,4,0.375)])
        graph = Graph.from_networkx(FG, nx.circular_layout)
        self.assertEqual(graph.dimension_values('weight'), np.array([0.125, 0.75, 1.2, 0.375])) 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:8,代碼來源:testgraphelement.py

示例13: test_from_networkx_with_invalid_edge_attrs

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import circular_layout [as 別名]
def test_from_networkx_with_invalid_edge_attrs(self):
        import networkx as nx
        FG = nx.Graph()
        FG.add_weighted_edges_from([(1,2,[]), (1,3,[]), (2,4,[]), (3,4,[])])
        graph = Graph.from_networkx(FG, nx.circular_layout)
        self.assertEqual(graph.vdims, []) 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:8,代碼來源:testgraphelement.py

示例14: test_from_networkx_custom_nodes

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import circular_layout [as 別名]
def test_from_networkx_custom_nodes(self):
        import networkx as nx
        FG = nx.Graph()
        FG.add_weighted_edges_from([(1,2,0.125), (1,3,0.75), (2,4,1.2), (3,4,0.375)])
        nodes = Dataset([(1, 'A'), (2, 'B'), (3, 'A'), (4, 'B')], 'index', 'some_attribute')
        graph = Graph.from_networkx(FG, nx.circular_layout, nodes=nodes)
        self.assertEqual(graph.nodes.dimension_values('some_attribute'), np.array(['A', 'B', 'A', 'B'])) 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:9,代碼來源:testgraphelement.py

示例15: test_from_networkx_dictionary_positions

# 需要導入模塊: import networkx [as 別名]
# 或者: from networkx import circular_layout [as 別名]
def test_from_networkx_dictionary_positions(self):
        import networkx as nx
        G = nx.Graph()
        G.add_nodes_from([1, 2, 3])
        positions = nx.circular_layout(G)
        graph = Graph.from_networkx(G, positions)
        self.assertEqual(graph.nodes.dimension_values(2), np.array([1, 2, 3])) 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:9,代碼來源:testgraphelement.py


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