All pastes #504861 Raw Edit

Someone

public text v1 · immutable
·published 2007-05-23 09:26 UTC
rendered paste body
	function dfs($path, $to, $visited) { // current path, destination, current visited nodes
		$from = $path->peekLastNodeId();
		if ($from == $to) { // found a path
			$this -> addPath($path);
		} else { // find next linked node(s)
			$links = $this -> edges_d[$from];
			foreach ($links as $id => $dist) {
				if ($visited[$id] != true) {
					$visited[$id] = true;
					$path->addNode(new Node($id, $dist, $this->edges_l[$from][$id]));
					$this->dfs($path, $to, $visited);
					$path->removeLastNode();
				}
			}
		}
		// backtrack
		return;
	}