mirror of
				https://github.com/stevenrobertson/cuburn.git
				synced 2025-11-03 18:00:55 -05:00 
			
		
		
		
	Another little helper
This commit is contained in:
		
							
								
								
									
										22
									
								
								scripts/walk.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										22
									
								
								scripts/walk.py
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,22 @@
 | 
				
			|||||||
 | 
					import os
 | 
				
			||||||
 | 
					import random
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					edges = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					for i in os.listdir('edges'):
 | 
				
			||||||
 | 
					    if '=' not in i: continue
 | 
				
			||||||
 | 
					    src, dst = i.rsplit('.', 1)[0].split('=', 1)
 | 
				
			||||||
 | 
					    edges.setdefault(src, set()).add((src, dst))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					seen = set()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					src = random.choice(edges.keys())
 | 
				
			||||||
 | 
					for i in range(1000):
 | 
				
			||||||
 | 
					    print src
 | 
				
			||||||
 | 
					    dsts = edges.get(src, set()).difference(seen)
 | 
				
			||||||
 | 
					    if not dsts:
 | 
				
			||||||
 | 
					        src = random.choice(edges.keys())
 | 
				
			||||||
 | 
					    else:
 | 
				
			||||||
 | 
					        dst = random.choice(list(dsts))[1]
 | 
				
			||||||
 | 
					        print '='.join([src, dst])
 | 
				
			||||||
 | 
					        src = dst
 | 
				
			||||||
		Reference in New Issue
	
	Block a user