- What would happen if corporations can only make a maximum profit of 10% per product.
- Marxist Economics: Understanding Capitalist Exploitation through “speed up” or increase in intensity
- Emacs execute keymap entry
- Running elisp within an orgmode code block
- How can I ask a user to choose from a list of options, while showing her a long list with extra metadata?
- Protection against h-bomb core explosion conditions thinkable?
- Will a race survive eugenics?
- How would Soldiers with Indestructable bones fight?
- How fast can I flood the Netherlands entirely and permanently?
- A planet with 7 suns
- What effect could drop the freezing temperature of water globally to −40 Celsius?
- Is life in a planet in this solar system possible?
- What are the limits of energy density?
- What are the benefits of reciting Durga Saptashati Devi Aparadha Kshamapana Stotram?
- Fetters in samsara
- Craft Commerce Plugin - How to refresh/reload/redirect page in onStatusChange
- How can I prevent an account activation email from being sent to an unverified user who registered via a front end registration form?
- This is it. This is the one. Find your wife
- What's the name of my cat?
- What is 3xRNN in papers?
Finding many paths in a graph
I have a graph which we can think of is representing a network of train tracks. Each node is a station and each edge is a piece of track connecting two stations. Each station node may be connected by more than one track and all tracks are one way (i.e the graph is directed).
My job is to find as many routes as possible connecting one node with a set of destination nodes. Routes may contain cycles to the train track analogy breaks down here, but whatever. I have Python code to perform this task, but it is to slow so I would love to get some help in making it faster. Below is my traversal function:
from collections import deque
from itertools import product
def travel(graph, start, dests, count):
queue = deque([[(start, None)]])
paths = 
path = queue.popleft()
at = path[-1]
if at in dests:
pp = [p for p in path[1:]]
for real_path in product(*pp):