Python 论点是什么';弱';或';强';是否为scipy.sparse.csgraph.connected\U组件执行此操作?

Python 论点是什么';弱';或';强';是否为scipy.sparse.csgraph.connected\U组件执行此操作?,python,numpy,graph,scipy,graph-algorithm,Python,Numpy,Graph,Scipy,Graph Algorithm,下面的代码演示了有向图: Nodes: 0, 1, 2 Edges: [0 -> 1], [2 -> 1] 被认为是一个弱连通分量和三个强连通分量 assert(scipy.sparse.csgraph.connected_components(np.array([[0,1,0], [0,0,0], [0,1,0]]), directed=True, connection='weak', return_labels=True) == (1, array([0, 0, 0], dty

下面的代码演示了有向图:

Nodes: 0, 1, 2
Edges: [0 -> 1], [2 -> 1]
被认为是一个弱连通分量和三个强连通分量

assert(scipy.sparse.csgraph.connected_components(np.array([[0,1,0], [0,0,0], [0,1,0]]), directed=True, connection='weak', return_labels=True) == (1, array([0, 0, 0], dtype=int32)))

assert(scipy.sparse.csgraph.connected_components(np.array([[0,1,0], [0,0,0], [0,1,0]]), directed=True, connection='strong', return_labels=True) == (3, array([1, 0, 2], dtype=int32)))
我理解为什么强连接组件返回值有意义——我不能从0遍历到2,也不能从1遍历到0或从1遍历到2

但根据文件:

directedbool, optional
    If True (default), then operate on a directed graph: only move
    from point i to point j along paths csgraph[i, j]. If False,
    then find the shortest path on an undirected graph: the
    algorithm can progress from point i to j along csgraph[i, j]
    or csgraph[j, i].

connectionstr, optional    
    [‘weak’|’strong’]. For directed graphs, the type of connection
    to use. Nodes i and j are strongly connected if a path exists
    both from i to j and from j to i. Nodes i and j are weakly
    connected if only one of these paths exists. If directed ==
    False, this keyword is not referenced.
“弱”连接组件不应存在,因为1无法访问2,2也无法访问1


这是怎么回事?文档是否正确?

文档不正确,将在未来版本的Scipy中更新。看

今后的文件内容如下:

connection : str, optional
    ['weak'|'strong'].  For directed graphs, the type of connection to
    use.  Nodes i and j are strongly connected if a path exists both
    from i to j and from j to i. A directed graph is weakly connected
    if replacing all of its directed edges with undirected edges produces
    a connected (undirected) graph. If directed == False, this keyword
    is not referenced.
这是弱连通的标准定义