def test_all_pairs_connectivity_directed(self): G = nx.DiGraph() nodes = [0, 1, 2, 3] G.add_path(nodes) A = numpy.zeros((4, 4), dtype=int) for u, v in itertools.combinations(nodes, 2): A[u][v] = nx.node_connectivity(G, u, v) C = nx.all_pairs_node_connectivity_matrix(G) assert_equal(A, C)
def compute_all_pairs_node_connectivity_matrix(G): """For the given graph, returns a numpy 2d ndarray with node connectivity between all pairs of nodes""" return nx.all_pairs_node_connectivity_matrix(G)
def test_all_pairs_connectivity_nodelist(self): G = nx.path_graph(4) C = nx.all_pairs_node_connectivity_matrix(G, nodelist=[1, 2, 3, 1])
def test_all_pairs_connectivity_empty(self): C = nx.all_pairs_node_connectivity_matrix(nx.Graph())