convert networkx graph to dataframe code example
Example: Transform networkx graph to dataframe
# Get G egdes to dataframe
edge_df = nx.to_pandas_edgelist(G)
# Transform networkx nodes to dataframe
nodelist = list(G.nodes(data=True)) # From G to list
node_df = pd.DataFrame(nodelist, columns=['vertex', 'name_attribute']) # From list to DF