Answers for "networkx - add features from graph"

-1

networkx - add features from graph

df = pd.DataFrame(index=G.nodes())                              # Use nodes as index
df['node_name'] = pd.Series(nx.get_node_attributes(G, 'name'))  # Add attribute
df['clustering'] = pd.Series(nx.clustering(G))                  # Calculate lcc
df['degree'] = pd.Series(G.degree())                            # Calculate degree
Posted by: Guest on July-07-2020

Python Answers by Framework

Browse Popular Code Answers by Language