Extracting Edge Data From A Networkx Graph
I need to extract out the edge information for each graph displayed. The data is in utf-8 form. The graphs are displayed for each sentence in the document. So now the information
Solution 1:
You need the connected_components function:
for component in nx.connected_components(graph):
# Each component is the set of nodes
print(component)
# Filter all edges in graph: we keep only that are in the component
print(list(
filter(
lambda x: x[0] in component and x[1] in component,
graph.edges
)
))
Post a Comment for "Extracting Edge Data From A Networkx Graph"