Commit d0c176a6 authored by THAKARE AKSHAY HARIBHAU's avatar THAKARE AKSHAY HARIBHAU

Merge branch 'Nalgo' into 'algorand'

network generator

See merge request !8
parents 6113f258 41e9287d
...@@ -4,6 +4,12 @@ ...@@ -4,6 +4,12 @@
* Basic requirements * Basic requirements
`pip3 install -r requirements.txt` `pip3 install -r requirements.txt`
`pip3 install python-louvain==0.5`
`sudo pip3 install networkx`
`apt-get install python3-tk`
* Setup * Setup
......
...@@ -4,6 +4,10 @@ import sys ...@@ -4,6 +4,10 @@ import sys
import networkx as nx import networkx as nx
from networkx.algorithms import community from networkx.algorithms import community
'''
Generates a file of nodes
'''
f = open("Nodes1.dat", "w") f = open("Nodes1.dat", "w")
for i in range(int(sys.argv[1])): for i in range(int(sys.argv[1])):
...@@ -12,27 +16,64 @@ for i in range(int(sys.argv[1])): ...@@ -12,27 +16,64 @@ for i in range(int(sys.argv[1])):
f.close() f.close()
# G = nx.Graph() '''
# G=nx.complete_graph(100) Generates a graph given degree sequence
# G1=nx.path_graph(100) '''
G2=nx.erdos_renyi_graph(int(sys.argv[1]),0.1)
# G3=nx.fast_gnp_random_graph(100,0.1) sequence = numpy.random.uniform(2,4.1,int(sys.argv[1])).round()
# G4=nx.connected_caveman_graph(100,0) while 1:
# print(nx.is_connected(G2)) sequence1 = numpy.random.random_integers(2,4,int(sys.argv[1]))
# print(G2.edges()) try :
G5 = nx.random_degree_sequence_graph(list(sequence1),tries=10)
if nx.is_connected(G2): break
except nx.NetworkXUnfeasible :
pass
except nx.NetworkXError:
pass
print(sorted(G5.degree()))
if nx.is_connected(G5):
print("Graph is connected")
f = open("Links1.dat", "w") f = open("Links1.dat", "w")
count = 0 count = 0
for edge in G2.edges(): for edge in G5.edges():
# print(edge) # print(edge)
# print(str(edge[0])+'\t'+str(edge[1])+'\n') # print(str(edge[0])+'\t'+str(edge[1])+'\n')
f.write(str(edge[0])+'\t'+str(edge[1])+'\n') f.write(str(edge[0])+'\t'+str(edge[1])+'\n')
count += 1 count += 1
f.close() f.close()
print('Nodes: ',sys.argv[1],'Edges: ',count) print('Nodes: ',sys.argv[1],'Edges: ',count)
'''
generates a file given nodes and randomly links
'''
# G2=nx.erdos_renyi_graph(int(sys.argv[1]),0.1)
#
# if nx.is_connected(G2):
# f = open("Links1.dat", "w")
# count = 0
# for edge in G2.edges():
# # print(edge)
# # print(str(edge[0])+'\t'+str(edge[1])+'\n')
# f.write(str(edge[0])+'\t'+str(edge[1])+'\n')
# count += 1
# f.close()
#
# print('Nodes: ',sys.argv[1],'Edges: ',count)
# G = nx.Graph()
# G=nx.complete_graph(100)
# G1=nx.path_graph(100)
# G3=nx.fast_gnp_random_graph(100,0.1)
# G4=nx.connected_caveman_graph(100,0)
# print(nx.is_connected(G2))
# print(G2.edges())
# nx.draw(G) # nx.draw(G)
# #
# from igraph import Graph # from igraph import Graph
...@@ -77,4 +118,4 @@ print('Nodes: ',sys.argv[1],'Edges: ',count) ...@@ -77,4 +118,4 @@ print('Nodes: ',sys.argv[1],'Edges: ',count)
# print(randint(1, 51, 1)) # print(randint(1, 51, 1))
# print(randint(1, 51, 1)) # print(randint(1, 51, 1))
# print(randint(1, 51, 1)) # print(randint(1, 51, 1))
# #
\ No newline at end of file
apturl==0.5.2 apturl==0.5.2
asn1crypto==0.24.0 asn1crypto==0.24.0
backcall==0.1.0
Brlapi==0.6.6 Brlapi==0.6.6
certifi==2018.1.18 certifi==2018.1.18
cffi==1.12.2 cffi==1.12.2
...@@ -7,14 +8,21 @@ chardet==3.0.4 ...@@ -7,14 +8,21 @@ chardet==3.0.4
command-not-found==0.3 command-not-found==0.3
cryptography==2.6.1 cryptography==2.6.1
cupshelpers==1.0 cupshelpers==1.0
cycler==0.10.0
decorator==4.4.0
defer==1.0.6 defer==1.0.6
distro-info===0.18ubuntu0.18.04.1 distro-info===0.18ubuntu0.18.04.1
ecdsa==0.13 ecdsa==0.13
httplib2==0.9.2 httplib2==0.9.2
idna==2.6 idna==2.6
igraph==0.1.11
ipython==7.5.0
ipython-genutils==0.2.0
jedi==0.13.3
kazam==1.4.5 kazam==1.4.5
keyring==10.6.0 keyring==10.6.0
keyrings.alt==3.0 keyrings.alt==3.0
kiwisolver==1.1.0
language-selector==0.1 language-selector==0.1
launchpadlib==1.10.6 launchpadlib==1.10.6
lazr.restfulclient==0.13.5 lazr.restfulclient==0.13.5
...@@ -23,23 +31,33 @@ louis==3.5.0 ...@@ -23,23 +31,33 @@ louis==3.5.0
macaroonbakery==1.1.3 macaroonbakery==1.1.3
Mako==1.0.7 Mako==1.0.7
MarkupSafe==1.0 MarkupSafe==1.0
matplotlib==3.0.3
netifaces==0.10.4 netifaces==0.10.4
numpy==1.16.2 networkx==2.3
numpy==1.16.3
oauth==1.0.1 oauth==1.0.1
olefile==0.45.1 olefile==0.45.1
pexpect==4.2.1 parso==0.4.0
pexpect==4.7.0
pickleshare==0.7.5
Pillow==5.1.0 Pillow==5.1.0
prompt-toolkit==2.0.9
protobuf==3.0.0 protobuf==3.0.0
ptyprocess==0.6.0
pycairo==1.16.2 pycairo==1.16.2
pycparser==2.19 pycparser==2.19
pycrypto==2.6.1 pycrypto==2.6.1
pycups==1.9.73 pycups==1.9.73
Pygments==2.3.1
pygobject==3.26.1 pygobject==3.26.1
pymacaroons==0.13.0 pymacaroons==0.13.0
PyNaCl==1.1.2 PyNaCl==1.1.2
pyparsing==2.4.0
pyRFC3339==1.0 pyRFC3339==1.0
python-apt==1.6.3+ubuntu1 python-apt==1.6.3+ubuntu1
python-dateutil==2.8.0
python-debian==0.1.32 python-debian==0.1.32
python-louvain==0.5
pytz==2018.3 pytz==2018.3
pyxdg==0.25 pyxdg==0.25
PyYAML==3.12 PyYAML==3.12
...@@ -53,11 +71,13 @@ six==1.12.0 ...@@ -53,11 +71,13 @@ six==1.12.0
sortedcontainers==2.1.0 sortedcontainers==2.1.0
system-service==0.3 system-service==0.3
systemd-python==234 systemd-python==234
traitlets==4.3.2
ubuntu-drivers-common==0.0.0 ubuntu-drivers-common==0.0.0
ufw==0.36 ufw==0.36
unattended-upgrades==0.1 unattended-upgrades==0.1
urllib3==1.22 urllib3==1.22
usb-creator==0.3.3 usb-creator==0.3.3
wadllib==1.3.2 wadllib==1.3.2
wcwidth==0.1.7
xkit==0.0.0 xkit==0.0.0
zope.interface==4.3.2 zope.interface==4.3.2
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment