比較訂閱用戶與非訂閱用戶的距離
來比較訂閱用戶與非訂閱用戶在圖上的距離。請記得,我們可以把訂閱用戶視為經常使用單車的芝加哥在地居民,而非訂閱用戶多半是偶爾使用的使用者或觀光客。此外,這個圖是地理位置的表徵。你覺得哪一個圖的地理距離更遠?為什麼?
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(___)