python - NetworkX add_nodes_from doesn't work as expected -


>>> import networkx nx >>> g = nx.graph() >>> g.add_nodes_from([1, 2, 3, 4, 5], carved=false) >>> g[1] {} >>> nx.get_node_attributes(g, "carved") {1: false, 2: false, 3: false, 4: false, 5: false} >>> 

shouldn't getting "carved" attribute when type 'g[1]'? following works:

>>> g[1] {} >>> g[1]["carved"] = true >>> g[1] {'carved': true} >>> 

what missing here, why isn't "carve" attribute being applied in second example? i'm running python 2.7 on windows. updated install of networkx, thinking maybe had older version?

any appreciated.

it looks intended use g.node[1] instead of g[1].


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -