当前位置: 首页>>代码示例>>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;未经允许,请勿转载。