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