2

I was using networkx 1.9 with python 2.7 and decided to update to the latest 1.10 version. when using the bipartite graph generator function configuration_model, I found that what I what using before :

import networkx as nx
from networkx.algorithms import bipartite
import networkx.algorithms.bipartite as bipartite
aseq=[1 2 1]
bseq=[2 1 1]
G =bipartite_configuration_model(aseq,bseq, create_using=None, seed=None)

new version:

G =configuration_model(aseq, bseq, create_using=None, seed=None)

configuration_model() got multiple values for keyword argument 'create_using'

did not work anymore. Any idea what is the create_using= should be ? I read the source file and could not see what was needed !

user3767071
  • 99
  • 1
  • 1
  • 9

2 Answers2

1

I am not sure of the difference between versions but small changes to your old version solved the issue. What I did as a change for your code is:

the definition of aseq and bseq as they gave error:

aseq=[1, 2, 1] # with commas between degree sequences
bseq=[2, 1, 1]

Calling the configuration_model function

G = bipartite.configuration_model(aseq,bseq, create_using=None, seed=None) # you had an underscore instead of a '.'

then with a simple color_map to differentiate the nodes belonging to each part as follows:

color_map = []
for n in G.nodes():
    if G.node[n]['bipartite'] == 0:
        color_map.append('blue')
    else: color_map.append('green')

Drawing the graph produced:

enter image description here

As for the create_using parameter, you can check the documentation. it says that you can use it to determine the type of the returned graph. By default it is a multi-Graph with parallel edges.

Abdallah Sobehy
  • 2,881
  • 1
  • 15
  • 28
  • 1
    Thank you ! About the sequence, it was indeed an error, I actually create my sequences using 'nx.utils.create_degree_sequence(3, powerlaw_sequence, exponent=2)' which results in a degree sequence with comma separation. But I understand with @Joel and your answer that writing configuration model alone without specifying bipartite indeed resulted in the error I had... but reading the graph generator section did not help in explaining that I needed to write 'bipartite.graph_generator'. Thanks again for clarifying that ! – user3767071 Nov 04 '15 at 08:57
1

bipartite_configuration_model and configuration_model are different commands. Your new code calls configuration_model, for which there is only a single partition of nodes.

It interprets aseq as the degree distribution. It then interprets the second argument as the create_using variable (if the second argument is optional, it can be specified either by giving a second argument in the function call, or by using a keyword in the function call (more details)). So it saw that as create_using=bseq. Then you explicitly passed it an additional value for create_using, and so it had multiple values. You clearly don't mean to do that, hence the error.

I believe Abdallah's answer shows you what you actually want to do.


Additional: I doubt you really mean to do both of these calls.

from networkx.algorithms import bipartite
import networkx.algorithms.bipartite as bipartite
Community
  • 1
  • 1
Joel
  • 22,598
  • 6
  • 69
  • 93