aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorColin Schmidt2018-06-08 17:25:25 -0700
committerJack Koenig2018-06-08 17:25:25 -0700
commit87aa2629beaef20bbc57f36316b73742c599e559 (patch)
tree328a116564fba114c4f5bc4c6d7511d90e73e407 /src
parentdcdfc467a5f59058b482127340ebef375cec077a (diff)
Add a blacklist option for paths (#810)
Useful if you want to find out how a node was reachable and you used a blacklist during the reachability analysis
Diffstat (limited to 'src')
-rw-r--r--src/main/scala/firrtl/graph/DiGraph.scala14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/main/scala/firrtl/graph/DiGraph.scala b/src/main/scala/firrtl/graph/DiGraph.scala
index 22f5fcc5..4b900be4 100644
--- a/src/main/scala/firrtl/graph/DiGraph.scala
+++ b/src/main/scala/firrtl/graph/DiGraph.scala
@@ -162,9 +162,19 @@ class DiGraph[T] private[graph] (private[graph] val edges: LinkedHashMap[T, Link
* @throws PathNotFoundException
* @return a Seq[T] of nodes defining an arbitrary valid path
*/
- def path(start: T, end: T): Seq[T] = {
+ def path(start: T, end: T): Seq[T] = path(start, end, Set.empty[T])
+
+ /** Finds a path (if one exists) from one node to another, with a blacklist
+ *
+ * @param start the start node
+ * @param end the destination node
+ * @param blacklist list of nodes which break path, if encountered
+ * @throws PathNotFoundException
+ * @return a Seq[T] of nodes defining an arbitrary valid path
+ */
+ def path(start: T, end: T, blacklist: Set[T]): Seq[T] = {
val nodePath = new mutable.ArrayBuffer[T]
- val prev = BFS(start)
+ val prev = BFS(start, blacklist)
nodePath += end
while (nodePath.last != start && prev.contains(nodePath.last)) {
nodePath += prev(nodePath.last)