Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
algorand
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nilak
algorand
Commits
e2ab3569
Commit
e2ab3569
authored
May 01, 2019
by
UNHALE NILESH ARUN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update filegen
parent
001cc416
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
12 deletions
+54
-12
filegen.py
filegen.py
+54
-12
No files found.
filegen.py
View file @
e2ab3569
...
...
@@ -2,9 +2,14 @@ import hashlib
from
numpy.random
import
randint
import
sys
import
networkx
as
nx
import
numpy
import
matplotlib.pyplot
as
plt
from
networkx.algorithms
import
community
'''
Generates a file of nodes
'''
f
=
open
(
"Nodes1.dat"
,
"w"
)
for
i
in
range
(
int
(
sys
.
argv
[
1
])):
...
...
@@ -13,27 +18,64 @@ for i in range(int(sys.argv[1])):
f
.
close
()
# G = nx.Graph()
# G=nx.complete_graph(100)
# 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)
# G4=nx.connected_caveman_graph(100,0)
# print(nx.is_connected(G2))
# print(G2.edges())
if
nx
.
is_connected
(
G2
):
'''
Generates a graph given degree sequence
'''
sequence
=
numpy
.
random
.
uniform
(
2
,
4.1
,
int
(
sys
.
argv
[
1
]))
.
round
()
while
1
:
sequence1
=
numpy
.
random
.
random_integers
(
2
,
4
,
int
(
sys
.
argv
[
1
]))
try
:
G5
=
nx
.
random_degree_sequence_graph
(
list
(
sequence1
),
tries
=
10
)
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"
)
count
=
0
for
edge
in
G
2
.
edges
():
for
edge
in
G
5
.
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
)
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)
#
# from igraph import Graph
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment