Skip to content

Instantly share code, notes, and snippets.

@altilunium
Created March 30, 2021 04:04
Show Gist options
  • Save altilunium/08805df0c195f23d7899da2f2efbb99b to your computer and use it in GitHub Desktop.
Save altilunium/08805df0c195f23d7899da2f2efbb99b to your computer and use it in GitHub Desktop.
import numpy as np
subreddit = []
thelinks = dict()
with open('node-ids.txt','r') as fp:
line = fp.readline()
cnt = 1
#print(line.strip())
subreddit.append(line.strip())
while line:
line = fp.readline()
cnt += 1
#print(line.strip())
subreddit.append(line.strip())
f = open('links.bin',mode='rb')
a = np.fromfile(f, dtype=np.int32)
currentNode = 0
for x in a:
#print(x)
if x < 0:
currentNode = abs(x)
thelinks[currentNode] = []
else:
thelinks[currentNode].append(x)
'''
for i in thelinks:
print("[*]"+str(subreddit[i-1]))
for x in thelinks[i]:
print(str(subreddit[x-1]))
print("--------------")
'''
thelinksr = dict()
for i in thelinks:
thelinksr[i] = len(thelinks[i])
'''
for i in sorted(thelinksr,key=thelinksr.get,reverse=True):
print("[*]"+str(subreddit[i-1]))
for x in thelinks[i]:
print(str(subreddit[x-1]))
print("--------------")
'''
print("Warning : Case Sensitive")
subr = input("r/")
cnt = 0
for i in subreddit:
if subr == i:
nya = set()
print()
print("LEVEL 1")
for z in thelinks[cnt+1]:
#print(subreddit[z-1],end=", ")
nya.add(z)
for o in nya:
print(subreddit[o-1],end=", ")
print()
print()
print("LEVEL 2")
nya2 = set()
for z in nya:
nya2.add(z)
for z in nya:
for k in thelinks[z+1]:
#print(subreddit[k-1],end=", ")
nya2.add(k)
for o in nya2:
print(subreddit[o-1],end=", ")
print()
print()
print("LEVEL 3")
nya3 = set()
for z in nya2:
nya3.add(z)
for z in nya2:
for k in thelinks[z+1]:
#print(subreddit[k-1],end=", ")
nya3.add(k)
for o in nya3:
print(subreddit[o-1],end=", ")
else:
cnt +=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment