There's more...

What if you want to find connections between two cities that typically do not have direct flights? For example, let's find out the possible routes between San Francisco and Buffalo:

subsetOfPaths = graph.bfs(
fromExpr = "id = 'SFO'",
toExpr = "id = 'BUF'",
maxPathLength = 1)

display(subsetOfPaths)

Output:
OK

The OK in this case indicates that there are no direct flights between San Francisco and Buffalo as we could not retrieve a single edge (at least from this dataset). But to find out whether there are any layover flights, just change maxPathLength = 2 (to indicate a single stopover city):

subsetOfPaths = graph.bfs(
fromExpr = "id = 'SFO'",
toExpr = "id = 'BUF'",
maxPathLength = 2)

display(subsetOfPaths)

As you can see here, there are many flights with a single stopover connecting San Francisco and Buffalo:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset