AllPairsPath映射#

class AllPairsPathMapping#

基础:object

一个用于返回从所有节点到目标节点路径的自定义类

该类是一个从整数节点索引到PathMapping形式的只读映射,形式如下:

{0: {1: [0, 2, 3, 1], 2: [0, 2]}}

该类是一个容器类,用于存储返回从所有节点到目标节点的路径映射函数的结果。它实现了Python的映射协议,因此你可以将该返回视为一个只读的映射/字典。

例如:

import rustworkx as rx

graph = rx.generators.directed_path_graph(5)
edges = rx.all_pairs_dijkstra_shortest_paths(graph)
# Target node access
third_node_shortest_paths = edges[2]

方法