For some reason add_star() is not inputting the attributes to the nodes.
import networkx as nx G = nx.Graph() nx.add_star(G, [0,1,2], weight=1) >>>G.nodes.data() NodeDataView({0: {}, 1: {}, 2: {}}) >>>G.node[0] {}
Any idea what’s going on??
Versions: Python 2.7 Networkx 2.2
Advertisement
Answer
If by attributes you mean the edge weights, the weights are added as edge attributes:
G = nx.Graph() nx.add_star(G, [0,1,2], weight=1) G.edges(data=True) # EdgeDataView([(0, 1, {'weight': 1}), (0, 2, {'weight': 1})])