I am trying to create a new directed networkX
graph given a directed networkX
graph and a node_id
as input.
What I would like to do is the only keep the connected nodes to the node_id
parameter on the subgraph. Some example:
current networkX graph:
node_id | edge_to
france spain, germany, italy, belgium
spain france, portugal
portugal spain
germany france, netherlands, belgium
the function I would like to implement:
new_graph = get_subgraph(graph='graph', node_id='spain')
new graph:
node_id | edge_to
france spain, germany, italy, belgium
spain france, portugal
portugal spain