[PYTHON] Labeled graphs on NetworkX

Labeling nodes is subtly annoying for some reason

--Add labeled nodes in bulk

>>> G = nx.Graph()
>>> G.add_nodes_from([(1,{'color':'red'}),(2,{'color':'blue'}),(3,{'color':'red'})])
>>> G.nodes(data=True)
[(1, {'color': 'red'}), (2, {'color': 'blue'}), (3, {'color': 'red'})]

-(Node) Read labeled graph from file

Can not

-(Node) Create a labeled graph from dict or list

Can not

Graphs with labels on edges can be created from files, dicts, and lists, so why can't I create graphs with labels on nodes?

Recommended Posts

Labeled graphs on NetworkX
Union Find on networkX
Use directional graphs with networkx
Real-time graphs on Plotly (Python)
Drawing graphs on Windows10 + Julia + PyPlot
Visualize graphs with Japanese labeled edges in NetworkX and PyGraphviz / Gephi
Write SVG graphs with matplotlib on heroku