公交地铁网络拓扑建模

方法总览

metro_network(line, stop[, transfertime, ...])

输入地铁站数据并输出网络拓扑模型。

get_shortest_path(G, stop, ostation, dstation)

获取下一个地铁最短路径的出行路径

get_k_shortest_paths(G, stop, ostation, ...)

获取距离地铁nextwork的第k条最短路径

get_path_traveltime(G, path)

获取路径的行程时间

split_subwayline(line, stop)

将地铁线路与地铁站进行切片以获取地铁部分信息(此步骤在地铁客流可视化中很有用)

transbigdata.metro_network(line, stop, transfertime=5, nxgraph=True)

输入地铁站数据并输出网络拓扑模型。生成的图形依赖于 NetworkX。行程时间包括:车站之间的运营时间+各车站的停靠时间+换乘时间

参数:
  • line (GeoDataFrame) – 线。应该有“线路”列来存储线路名称“速度”列来存储地铁速度,“停止时间”列来存储每个车站的停靠时间。

  • stop (GeoDataFrame) – 巴士/地铁站

  • transfertime (number) – 每次换乘所需时间

  • nxgraph (bool) – 默认值为 True,如果为 True,则输出 NetworkX 构造的网络 G,如果为 False,则输出 edges1(线段)、edge2(站换乘)和网络节点

返回:

当 nxgraph 参数为 True 时:**G**(networkx.classes.graph.Graph)— networkx 中构建的图 。 当 nxgraph 参数为 False 时:**edge1**(DataFrame) — 线段的网络边。**edge2**(DataFrame) — 用于传输的网络边缘。**node**(List) — 网络节点。

transbigdata.get_shortest_path(G, stop, ostation, dstation)

获取下一个地铁最短路径的出行路径

参数:
  • G (networkx.classes.graph.Graph) – 地铁网络

  • stop (DataFrame) – 地铁站数据框

  • ostation (str) – O站名

  • dstation (str) – D站名

返回:

path – 旅行路径:站名列表

返回类型:

list

transbigdata.get_k_shortest_paths(G, stop, ostation, dstation, k)

获取距离地铁nextwork的第k条最短路径

参数:
  • G (networkx.classes.graph.Graph) – 地铁网络

  • stop (DataFrame) – 地铁站数据框

  • ostation (str) – O站名

  • dstation (str) – D站名

  • k (int) – 第k条最短路径

返回:

paths – 旅行路径:旅行路径列表

返回类型:

list

transbigdata.get_path_traveltime(G, path)

获取路径的行程时间

参数:
  • G (networkx.classes.graph.Graph) – 地铁网络

  • path (list) – 站名列表

返回:

traveltime – 路径的旅行时间

返回类型:

float

transbigdata.split_subwayline(line, stop)

将地铁线路与地铁站进行切片以获取地铁部分信息(此步骤在地铁客流可视化中很有用)

参数:
  • line (GeoDataFrame) – 公交/地铁线路

  • stop (GeoDataFrame) – 巴士/地铁站

返回:

metro_line_splited – 生成的剖面线形状

返回类型:

GeoDataFrame