當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。