paths.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:pybel-tools 作者: pybel 项目源码 文件源码
def get_nodes_in_all_shortest_paths(graph, nodes, weight=None):
    """Gets all shortest paths from all nodes to all other nodes in the given list and returns the set of all nodes 
    contained in those paths using :func:`networkx.all_shortest_paths`.

    :param pybel.BELGraph graph: A BEL graph
    :param iter[tuple] nodes: The list of nodes to use to use to find all shortest paths
    :param str weight: Edge data key corresponding to the edge weight. If none, uses unweighted search.
    :return: A set of nodes appearing in the shortest paths between nodes in the BEL graph
    :rtype: set[tuple]

    .. note:: This can be trivially parallelized using :func:`networkx.single_source_shortest_path`
    """
    shortest_paths_nodes_iterator = _get_nodes_in_all_shortest_paths_helper(graph, nodes, weight=weight)

    return set(itt.chain.from_iterable(shortest_paths_nodes_iterator))


# TODO consider all shortest paths?
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号