Skip to content

Instantly share code, notes, and snippets.

@chezsick
Last active November 21, 2019 22:36
Show Gist options
  • Save chezsick/87c4b90b40a7a020cfb5437cc0a97968 to your computer and use it in GitHub Desktop.
Save chezsick/87c4b90b40a7a020cfb5437cc0a97968 to your computer and use it in GitHub Desktop.
Generate Your Web Graph For Fun! ;;;;;;;;;;;;;;;;;; args :::::::::::::::: prog webname num_pages
import sys
import random
import os
webname = str(sys.argv[1])
npages = int(sys.argv[2])
syllab = "azertyuiopqsdfghjklmwxcvbn3"
random.seed(webname)
syc = len(syllab)
for l in range(1,npages+1):
fs = open("%s.txt" %(l),"w")
words = ""
links = []
for m in range(random.randint(500,5000)):
if random.randint(1,200) == 100:
links.append(random.randint(1,npages))
else:
for n in range(random.randint(2,10)):
words += syllab[random.randint(0,syc-1)]
words += " "
fs.write(words)
fs.close()
links = sorted(links)
for t in links:
sys.stdout.write("%s\t%s\r\n" %(l,t))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment