I want to construct a random bipartite graph with networkx, but I get
AttributeError: module networkx has no attribute bipartite_random_graph
Does anyone know how to resolve this issue? I've seen on stackoverflow that other people had the same problem with other functions which could be resolved by importing the right package, but I cannot find a solution to my problem.
I am using networkx version 2.8.7
import networkx as nx
if __name__ == "__main__":
g=nx.bipartite_random_graph(3, 2, 0.5, seed=None, directed=False)
a = nx.adjacency_data(g)
If you're version 2.8.7 of NetworkX
, the docs indicate that either of the following should work:
from networkx.algorithms import bipartite
g = bipartite.random_graph(3, 2, 0.5, seed = None, directed = False)
Or (without importing the bipartite
algorithms separately):
g = nx.bipartite.random_graph(3, 2, 0.5, seed = None, directed = False)