Exemplo n.º 1
0
def prime_paths(N,E):
	edges = edges_to_dict(N,E)
	W = [[n] for n in edges.keys()]
	Prime = []

	# Finds all simple paths.
	while W:
		for path in W[:]:
			W.remove(path)
			p_prime_list = find_all_simple(path,edges)
			if p_prime_list:
				for p_prime in p_prime_list:
					W.append(p_prime)
			else:
				Prime.append(path)
	
	# Ensures all paths are maximal, transforming it from a list of simple
	# paths to a list of prime paths.
	for p in Prime[:]:
		for p_prime in Prime[:]:
			if p!=p_prime and is_subpath(p,p_prime):
				Prime.remove(p)
				break

	return Prime
Exemplo n.º 2
0
def test_paths(prime_paths, N, E, N0, Nf):
	edges = edges_to_dict(N,E)
	tests = extend_to_n0(prime_paths,edges,N0)
	tests = extend_to_nf(tests,edges,Nf)
	return remove_duplicates(tests)