1
+ // MIT License
2
+ //
3
+ // Copyright (c) 2019 Ruhr University Bochum, Chair for Embedded Security. All Rights reserved.
4
+ // Copyright (c) 2019 Marc Fyrbiak, Sebastian Wallat, Max Hoffmann ("ORIGINAL AUTHORS"). All rights reserved.
5
+ // Copyright (c) 2021 Max Planck Institute for Security and Privacy. All Rights reserved.
6
+ // Copyright (c) 2021 Jörn Langheinrich, Julian Speith, Nils Albartus, René Walendy, Simon Klix ("ORIGINAL AUTHORS"). All Rights reserved.
7
+ //
8
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ // of this software and associated documentation files (the "Software"), to deal
10
+ // in the Software without restriction, including without limitation the rights
11
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ // copies of the Software, and to permit persons to whom the Software is
13
+ // furnished to do so, subject to the following conditions:
14
+ //
15
+ // The above copyright notice and this permission notice shall be included in all
16
+ // copies or substantial portions of the Software.
17
+ //
18
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ // SOFTWARE.
25
+
26
+ #pragma once
27
+
28
+ #include " graph_algorithm/netlist_graph.h"
29
+ #include " hal_core/defines.h"
30
+ #include " hal_core/utilities/result.h"
31
+
32
+ #include < igraph/igraph.h>
33
+ #include < set>
34
+
35
+ namespace hal
36
+ {
37
+ class Gate ;
38
+
39
+ namespace graph_algorithm
40
+ {
41
+ /* *
42
+ * Compute a shortest path from the specified `from_gate` to each of the given `to_gates` by traversing in the provided direction.
43
+ * Returns one shortest path for each end gate, even if multiple shortest paths exist.
44
+ * Each shortest path is given as a vector of vertices in the order of traversal.
45
+ *
46
+ * @param[in] graph - The netlist graph.
47
+ * @param[in] from_gate - The start gate of the shortest path.
48
+ * @param[in] to_gates - A vector of end gates of the shortest path.
49
+ * @param[in] direction - The direction in which to compute the shortest paths starting at the `from_gate`.
50
+ * @returns The shortest paths in order of the `to_gates` on success, an error otherwise.
51
+ */
52
+ Result<std::vector<std::vector<u32 >>> get_shortest_paths (NetlistGraph* graph, Gate* from_gate, const std::vector<Gate*>& to_gates, NetlistGraph::Direction direction);
53
+
54
+ /* *
55
+ * Compute a shortest path from the specified `from_vertex` to each of the given `to_vertices` by traversing in the provided direction.
56
+ * Returns one shortest path for each end vertex, even if multiple shortest paths exist.
57
+ * Each shortest path is given as a vector of vertices in the order of traversal.
58
+ *
59
+ * @param[in] graph - The netlist graph.
60
+ * @param[in] from_gate - The start vertex of the shortest path.
61
+ * @param[in] to_gates - A vector of end vertices of the shortest path.
62
+ * @param[in] direction - The direction in which to compute the shortest paths starting at the `from_vertex`.
63
+ * @returns The shortest paths in order of the `to_vertices` on success, an error otherwise.
64
+ */
65
+ Result<std::vector<std::vector<u32 >>> get_shortest_paths (NetlistGraph* graph, u32 from_vertex, const std::vector<u32 >& to_vertices, NetlistGraph::Direction direction);
66
+
67
+ /* *
68
+ * Compute a shortest path from the specified `from_vertex` to each of the given `to_vertices` by traversing in the provided direction.
69
+ * Returns one shortest path for each end vertex, even if multiple shortest paths exist.
70
+ * Each shortest path is given as a vector of vertices in the order of traversal.
71
+ *
72
+ * @param[in] graph - The netlist graph.
73
+ * @param[in] from_gate - The start vertex of the shortest path.
74
+ * @param[in] to_gates - An igraph vector of end vertices of the shortest path.
75
+ * @param[in] direction - The direction in which to compute the shortest paths starting at the `from_vertex`.
76
+ * @returns The shortest paths in order of the `to_vertices` on success, an error otherwise.
77
+ */
78
+ Result<std::vector<std::vector<u32 >>> get_shortest_paths_igraph (NetlistGraph* graph, u32 from_vertex, const igraph_vector_int_t * to_vertices, NetlistGraph::Direction direction);
79
+
80
+ /* *
81
+ * Compute a shortest path from the specified `from_gate` to each of the given `to_gates` by traversing in the provided direction.
82
+ * Returns all shortest paths for each end gate.
83
+ * Each shortest path is given as a vector of vertices in the order of traversal.
84
+ *
85
+ * @param[in] graph - The netlist graph.
86
+ * @param[in] from_gate - The start gate of the shortest path.
87
+ * @param[in] to_gates - A vector of end gates of the shortest path.
88
+ * @param[in] direction - The direction in which to compute the shortest paths starting at the `from_gate`.
89
+ * @returns The shortest paths in order of the `to_gates` on success, an error otherwise.
90
+ */
91
+ Result<std::vector<std::vector<u32 >>> get_all_shortest_paths (NetlistGraph* graph, Gate* from_gate, const std::vector<Gate*>& to_gates, NetlistGraph::Direction direction);
92
+
93
+ /* *
94
+ * Compute a shortest path from the specified `from_vertex` to each of the given `to_vertices` by traversing in the provided direction.
95
+ * Returns all shortest paths for each end gate.
96
+ * Each shortest path is given as a vector of vertices in the order of traversal.
97
+ *
98
+ * @param[in] graph - The netlist graph.
99
+ * @param[in] from_gate - The start vertex of the shortest path.
100
+ * @param[in] to_gates - A vector of end vertices of the shortest path.
101
+ * @param[in] direction - The direction in which to compute the shortest paths starting at the `from_vertex`.
102
+ * @returns The shortest paths in order of the `to_vertices` on success, an error otherwise.
103
+ */
104
+ Result<std::vector<std::vector<u32 >>> get_all_shortest_paths (NetlistGraph* graph, u32 from_vertex, const std::vector<u32 >& to_vertices, NetlistGraph::Direction direction);
105
+
106
+ /* *
107
+ * Compute a shortest path from the specified `from_vertex` to each of the given `to_vertices` by traversing in the provided direction.
108
+ * Returns all shortest paths for each end gate.
109
+ * Each shortest path is given as a vector of vertices in the order of traversal.
110
+ *
111
+ * @param[in] graph - The netlist graph.
112
+ * @param[in] from_gate - The start vertex of the shortest path.
113
+ * @param[in] to_gates - An igraph vector of end vertices of the shortest path.
114
+ * @param[in] direction - The direction in which to compute the shortest paths starting at the `from_vertex`.
115
+ * @returns The shortest paths in order of the `to_vertices` on success, an error otherwise.
116
+ */
117
+ Result<std::vector<std::vector<u32 >>> get_all_shortest_paths_igraph (NetlistGraph* graph, u32 from_vertex, const igraph_vector_int_t * to_vertices, NetlistGraph::Direction direction);
118
+ } // namespace graph_algorithm
119
+ } // namespace hal
0 commit comments