比较订阅用户与非订阅用户的行程距离
让我们按距离对比订阅用户与非订阅用户的图。请记住,订阅用户大多是经常用车的芝加哥本地居民,而非订阅用户更可能是临时使用者或游客。此外,需要牢记这个图是地理位置的抽象表示。您认为哪张图的地理跨度更大?为什么?
get_diameter() 和 farthest_vertices() 都会给出图中那对"最短路径最长"的顶点——get_diameter() 会返回包含所有中间顶点的路径,而 farthest_vertices() 返回的是两端顶点以及它们之间的节点数量。
还提供了 calc_physical_distance_m() 函数,它接收两个站点 ID 作为输入,计算站点之间的物理距离(米)。您可以在控制台运行 calc_physical_distance_m 查看该函数。
本练习是课程的一部分
案例研究:用 R 进行网络分析
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Get the diameter of the subscriber graph
get_diameter(___)
# Get the diameter of the customer graph
get_diameter(___)
# Find the farthest vertices of the subscriber graph
farthest_vertices(___)
# Find the farthest vertices of the customer graph
farthest_vertices(___)