You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BFS output is a data frame that contains, for every vertex in the graph, the distance from the seed and a back pointer to the previous element in the path. Extracting the path from the seed to a particular vertex requires looking up values in the data frame to back track back to the seed.
If there are multiple vertices that you want to extract paths for this can be a very inefficient mechanism.
What would be helpful would be to create an efficient function that takes the data frame from BFS and a list of vertices and returns a list of the paths to the vertices.
Input:
Dataframe from BFS call
A list of vertices for which we want the path from the seed to each vertex
Output:
Dataframe with one row for each vertex in the input list containing the path
Columns (labeled something simple, like '0', '1', '2', ... 'n') representing step in the path
Nulls (at the python level) indicating entries in the Dataframe are invalid
A few notes.
Not all paths will be the same length. If the maximum path length is 5 and a path is only length 2, the unused vertices will be null
There is no requirement that there be a path to all vertices in the specified set in the input. If there is no path then all elements in that row will be null. Note that if the first column (column '0' as suggested above) is null then there is no path to the vertex for that row.
Observe that all nulls will be on the "right". That is, in no row will there be a column 'i' that is null followed by a column 'j' that is not null (where j > i)
Implementation thoughts:
Need a C++ function that does this. Should be fairly straightforward
Need a Python wrapper to encapsulate the C++ function.
The text was updated successfully, but these errors were encountered:
BFS output is a data frame that contains, for every vertex in the graph, the distance from the seed and a back pointer to the previous element in the path. Extracting the path from the seed to a particular vertex requires looking up values in the data frame to back track back to the seed.
If there are multiple vertices that you want to extract paths for this can be a very inefficient mechanism.
What would be helpful would be to create an efficient function that takes the data frame from BFS and a list of vertices and returns a list of the paths to the vertices.
Input:
Output:
A few notes.
Implementation thoughts:
The text was updated successfully, but these errors were encountered: