Reputation: 11
I have used the Barabasi-Albert model in networkx to generate a graph with n=200 and m=2. This gives me an undirected graph but I want a directed graph so that I can plot the in and out degree distributions. Would plotting the in and out degrees be possible?
This is my code:
N=200
m=2
G_barabasi=nx.barabasi_albert_graph(n=N,m=m)
Upvotes: 1
Views: 429
Reputation: 16561
An easy way is to use the .to_directed
method on the existing graph:
from networkx import barabasi_albert_graph
G = barabasi_albert_graph(200, 2)
print(G.is_directed())
# False
G_directed = G.to_directed()
print(G_directed.is_directed())
# True
Upvotes: 0