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?
评论列表
文章目录