February 2017
Intermediate to advanced
274 pages
5h 58m
English
The Breadth-first search (BFS) is a new algorithm as part of GraphFrames that finds the shortest path from one set of vertices to another. In this section, we will use BFS to traverse our tripGraph to quickly find the desired vertices (that is, airports) and edges (that is, flights). Let's try to find the shortest number of connections between cities based on the dataset. Note that these examples do not consider time or distance, just hops between cities. For example, to find the number of direct flights between Seattle and San Francisco, you can run the following query:
# Obtain list of direct flights between SEA and SFO filteredPaths = tripGraph.bfs( fromExpr = "id = 'SEA'", toExpr = "id = 'SFO'", maxPathLength = 1) ...
Read now
Unlock full access