当前位置: 首页>>代码示例>>Python>>正文


Python networkx.number_weakly_connected_components方法代码示例

本文整理汇总了Python中networkx.number_weakly_connected_components方法的典型用法代码示例。如果您正苦于以下问题:Python networkx.number_weakly_connected_components方法的具体用法?Python networkx.number_weakly_connected_components怎么用?Python networkx.number_weakly_connected_components使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在networkx的用法示例。


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

示例1: _sanity_check

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import number_weakly_connected_components [as 别名]
def _sanity_check(G):
    r"""
    Helper function that checks if the input graphs contains a single connected component. Raises an error if not.

    Parameters
    ----------
    G : graph
       A NetworkX graph

    Raises
    ------
    ValueError
        If the graph has more than one (weakly) connected component.
    """
    # Compute the number of connected components
    if G.is_directed():
        num_ccs = nx.number_weakly_connected_components(G)
    else:
        num_ccs = nx.number_connected_components(G)

    # Rise an error if more than one CC exists
    if num_ccs != 1:
        raise ValueError("Input graph should contain one (weakly) connected component. "
                         "This graph contains: " + str(num_ccs)) 
开发者ID:Dru-Mara,项目名称:EvalNE,代码行数:26,代码来源:split_train_test.py

示例2: list

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import number_weakly_connected_components [as 别名]
def list(self) -> List[Tuple[str, float]]:
        """Return a list of tuples that summarize the graph."""
        number_nodes = self.graph.number_of_nodes()
        return [
            ('Name', self.graph.name),
            ('Version', self.graph.version),
            ('Number of Nodes', number_nodes),
            ('Number of Namespaces', len(self.graph.count.namespaces())),
            ('Number of Edges', self.graph.number_of_edges()),
            ('Number of Annotations', len(self.graph.count.annotations())),
            ('Number of Citations', self.graph.number_of_citations()),
            ('Number of Authors', self.graph.number_of_authors()),
            ('Network Density', '{:.2E}'.format(nx.density(self.graph))),
            ('Number of Components', nx.number_weakly_connected_components(self.graph)),
            ('Number of Warnings', self.graph.number_of_warnings()),
        ] 
开发者ID:pybel,项目名称:pybel,代码行数:18,代码来源:graph.py

示例3: component_nb

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import number_weakly_connected_components [as 别名]
def component_nb(self) -> int:
        """Return the number of independent components that this
        DAGCircuit can be split into."""
        return nx.number_weakly_connected_components(self.graph) 
开发者ID:rigetti,项目名称:quantumflow,代码行数:6,代码来源:dagcircuit.py

示例4: test_number_weakly_connected_components

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import number_weakly_connected_components [as 别名]
def test_number_weakly_connected_components(self):
        for G, C in self.gc:
            U = G.to_undirected()
            w = nx.number_weakly_connected_components(G)
            c = nx.number_connected_components(U)
            assert_equal(w, c) 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:8,代码来源:test_weakly_connected.py

示例5: test_connected_raise

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import number_weakly_connected_components [as 别名]
def test_connected_raise(self):
        G=nx.Graph()
        assert_raises(NetworkXNotImplemented,nx.weakly_connected_components, G)
        assert_raises(NetworkXNotImplemented,nx.number_weakly_connected_components, G)
        assert_raises(NetworkXNotImplemented,nx.weakly_connected_component_subgraphs, G)
        assert_raises(NetworkXNotImplemented,nx.is_weakly_connected, G) 
开发者ID:SpaceGroupUCL,项目名称:qgisSpaceSyntaxToolkit,代码行数:8,代码来源:test_weakly_connected.py

示例6: test_number_weakly_connected_components

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import number_weakly_connected_components [as 别名]
def test_number_weakly_connected_components(self):
        for G, C in self.gc:
            U = G.to_undirected()
            w = nx.number_weakly_connected_components(G)
            c = nx.number_connected_components(U)
            assert_equal(w, c)

    # deprecated 
开发者ID:holzschu,项目名称:Carnets,代码行数:10,代码来源:test_weakly_connected.py

示例7: test_null_graph

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import number_weakly_connected_components [as 别名]
def test_null_graph(self):
        G = nx.DiGraph()
        assert_equal(list(nx.weakly_connected_components(G)), [])
        assert_equal(nx.number_weakly_connected_components(G), 0)
        assert_raises(nx.NetworkXPointlessConcept, nx.is_weakly_connected, G) 
开发者ID:holzschu,项目名称:Carnets,代码行数:7,代码来源:test_weakly_connected.py

示例8: test_connected_raise

# 需要导入模块: import networkx [as 别名]
# 或者: from networkx import number_weakly_connected_components [as 别名]
def test_connected_raise(self):
        G = nx.Graph()
        assert_raises(NetworkXNotImplemented, nx.weakly_connected_components, G)
        assert_raises(NetworkXNotImplemented, nx.number_weakly_connected_components, G)
        assert_raises(NetworkXNotImplemented, nx.is_weakly_connected, G)
        # deprecated
        assert_raises(NetworkXNotImplemented, nx.weakly_connected_component_subgraphs, G) 
开发者ID:holzschu,项目名称:Carnets,代码行数:9,代码来源:test_weakly_connected.py


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