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

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

Ansible warning on jinja2 braces on when -