@@ 38-53 (lines=16) @@ | ||
35 | """ |
|
36 | filtered_paths = [] |
|
37 | ||
38 | if desired: |
|
39 | for link_id in desired: |
|
40 | try: |
|
41 | endpoint_a = self._topology.links[link_id].endpoint_a.id |
|
42 | endpoint_b = self._topology.links[link_id].endpoint_b.id |
|
43 | except KeyError: |
|
44 | return [] |
|
45 | ||
46 | for path in paths: |
|
47 | head = path['hops'][:-1] |
|
48 | tail = path['hops'][1:] |
|
49 | if (((endpoint_a, endpoint_b) in zip(head, tail)) or |
|
50 | ((endpoint_b, endpoint_a) in zip(head, tail))): |
|
51 | filtered_paths.append(path) |
|
52 | else: |
|
53 | filtered_paths = paths |
|
54 | ||
55 | if undesired: |
|
56 | for link_id in undesired: |
|
@@ 55-69 (lines=15) @@ | ||
52 | else: |
|
53 | filtered_paths = paths |
|
54 | ||
55 | if undesired: |
|
56 | for link_id in undesired: |
|
57 | try: |
|
58 | endpoint_a = self._topology.links[link_id].endpoint_a.id |
|
59 | endpoint_b = self._topology.links[link_id].endpoint_b.id |
|
60 | except KeyError: |
|
61 | continue |
|
62 | ||
63 | for path in paths: |
|
64 | head = path['hops'][:-1] |
|
65 | tail = path['hops'][1:] |
|
66 | if (((endpoint_a, endpoint_b) in zip(head, tail)) or |
|
67 | ((endpoint_b, endpoint_a) in zip(head, tail))): |
|
68 | ||
69 | filtered_paths.remove(path) |
|
70 | ||
71 | return filtered_paths |
|
72 |