MCPcopy Create free account
hub / github.com/Valdecy/pyCombinatorial / construct_path

Function construct_path

pyCombinatorial/algorithm/zs.py:129–145  ·  view source on GitHub ↗
(path_pairs, n)

Source from the content-addressed store, hash-verified

127
128# Function: Path Build
129def construct_path(path_pairs, n):
130 route = [path_pairs[0][0]]
131 visited = set(route)
132 while len(route) < n:
133 for pair in path_pairs:
134 if (pair[0] == route[-1] and pair[1] not in visited):
135 route.append(pair[1])
136 visited.add(pair[1])
137 break
138 else:
139 for pair in path_pairs:
140 if (pair[0] not in visited):
141 route.append(pair[0])
142 visited.add(pair[0])
143 break
144 route.append(route[0])
145 return route
146
147############################################################################
148

Callers 1

zero_suffix_methodFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected