1

I have a small graph network and I've been looking for methods that can make use of the structural properties of the small network to generate a complex network. I'd like to use a method that preserves properties such as degree distribution, clustering, etc..

Fortunately, I came across this [article] (https://link.springer.com/article/10.1007/s41109-017-0054-z) that discusses the generation of a replica of the original network followed by network scaling.

For example, I have generated an edge-weighted Networkx graph like the following: ( a random graph is created for illustration),

import random
import networkx as nx
import matplotlib.pyplot as plt
G = nx.gnm_random_graph(20, 30, seed=1)

for (u, v) in G.edges():
    G.edges[u, v]['weight'] = random.randint(0, 10)

nx.draw(G, with_labels=True)
plt.show()
print(G.edges(data=True))

This graph has 20 nodes. I'd like to know how to scale such Networks by a scale factor x varying from 5 to 10. Examples will be really helpful.

Also, in the documentation (https://github.com/networkit/networkit/blob/Dev/notebooks/User-Guide.ipynb) it is mentioned that the supported graph data format is METIS adjacency format. I would like to know if the networkx graph has to be converted to metis graph. Is there an option of directly using the Networkx graph in Networkit?

Natasha
  • 937
  • 2
  • 13
  • 30

1 Answers1

1

You can use the nxadapter module in NetworKit to convert graphs from networkx to NetworKit and vice versa. In your code this would work as follows:

import networkit as nk
import random
import networkx as nx
import matplotlib.pyplot as plt
G = nx.gnm_random_graph(20, 30, seed=1)

for (u, v) in G.edges():
    G.edges[u, v]['weight'] = random.randint(0, 10)

nx.draw(G, with_labels=True)
plt.show()
print(G.edges(data=True))

# Networkx graph to NetworKit graph
G_nk = nk.nxadapter.nx2nk(G, weightAttr='weight')

To generate complex networks you can also consider to use a graph generator, here you can find some examples.

angriman
  • 345
  • 1
  • 10
  • Thank you very much. I had a look at the graph generators. From what I understand, the generators listed in the above-mentioned link can be used for creating random graphs. I am not sure if these generators can be used for scaling an existing graph. Could you please elaborate on this? – Natasha Oct 01 '20 at 11:44
  • That's true, you can use the generators to generate complex networks but not to scale existing graphs. My point is that if want to generate a complex network there are plenty of generators you can use, otherwise I am not familiar with network scaling. – angriman Oct 01 '20 at 14:25
  • Thank you. I've opened a new thread [here](https://github.com/networkit/networkit/issues/600) – Natasha Oct 01 '20 at 15:23
  • @angriamn As suggested in the thread shared above I tried networkit.generators.LFRGenerator.fit(G_nk, scale=2) . But, this returns an object and I am not sure how to access the scaled graph. Could you please help? – Natasha Oct 02 '20 at 05:56