g.nodes() from networkx is not working with random.choice()

前端 未结 3 440
梦毁少年i
梦毁少年i 2021-01-21 15:04

I\'m trying to generate random edges between random nodes but the line of code ab=choice(G.nodes()) is generating errors.

import networkx as nx
impo         


        
3条回答
  •  余生分开走
    2021-01-21 15:24

    G.node usage is replaced by G.nodes from networkx version 2.4.

    Hence you might come across this error if you are trying to un an old code which uses G.node as a key(s) identifier.

    Replace all G.node with G.nodes or vice versa. depending on teh version you are trying to work.

提交回复
热议问题