Last active
March 4, 2017 16:12
-
-
Save Omig12/4b7be2a2b0b1994e858fa4ed1037583a to your computer and use it in GitHub Desktop.
Pseudo-Random Pseudo-Graph Generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# n parameter: | |
# represents the ammount of nodes desired in the graph. | |
from random import * | |
def rand_graph(n=2): | |
randgraph = {} | |
Nodes = [x for x in range(n)] | |
shuffle(Nodes) | |
Edges = [(x,randint(0,n)) for x in Nodes] | |
for i in Nodes: | |
randgraph[i] = {y for x in Edges if i in x for y in x if y != i } | |
return randgraph | |
print (rand_graph()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment