Create nodes from keys and edges from the values from a dictionary Networkx
问题 I'm stuck trying to solve a problem that I encounter. As mentioned in this post the nx.Graph() function can take a dictionary as an initialising argument. Which works fine, but I had something different in mind. My dictionary looks as follows (contents simplified): graph = {'A': ['a','b','c'], 'B':['a','b','c']} This creates the following: plot As can be seen for 'B', 'A', 'a', 'b' and 'c' nodes have been created. What I am looking for is a way to initialise the keys in my dictionary as nodes