aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlbert Magyar2017-11-16 18:32:32 -0800
committerGitHub2017-11-16 18:32:32 -0800
commit50a3641dd9700c1899198f13bc1362db78e25b79 (patch)
tree38ba90d612b5cd7ef99d0f27f85fd370852c569e /src
parent4429e2112aa958acab2ab43b0bf1d4c43becb50e (diff)
Move digraph exceptions out of digraph class (#688)
Diffstat (limited to 'src')
-rw-r--r--src/main/scala/firrtl/graph/DiGraph.scala15
-rw-r--r--src/test/scala/firrtlTests/graph/DiGraphTests.scala4
2 files changed, 9 insertions, 10 deletions
diff --git a/src/main/scala/firrtl/graph/DiGraph.scala b/src/main/scala/firrtl/graph/DiGraph.scala
index 3a657cc0..7e56919c 100644
--- a/src/main/scala/firrtl/graph/DiGraph.scala
+++ b/src/main/scala/firrtl/graph/DiGraph.scala
@@ -4,7 +4,13 @@ import scala.collection.{Set, Map}
import scala.collection.mutable
import scala.collection.mutable.{LinkedHashSet, LinkedHashMap}
-/** A companion to create immutable DiGraphs from mutable data */
+/** An exception that is raised when an assumed DAG has a cycle */
+class CyclicException extends Exception("No valid linearization for cyclic graph")
+
+/** An exception that is raised when attempting to find an unreachable node */
+class PathNotFoundException extends Exception("Unreachable node")
+
+/** A companion to create DiGraphs from mutable data */
object DiGraph {
/** Create a DiGraph from a MutableDigraph, representing the same graph */
def apply[T](mdg: MutableDiGraph[T]): DiGraph[T] = mdg
@@ -27,13 +33,6 @@ object DiGraph {
/** Represents common behavior of all directed graphs */
class DiGraph[T] private[graph] (private[graph] val edges: LinkedHashMap[T, LinkedHashSet[T]]) {
-
- /** An exception that is raised when an assumed DAG has a cycle */
- class CyclicException extends Exception("No valid linearization for cyclic graph")
- /** An exception that is raised when attempting to find an unreachable node */
- class PathNotFoundException extends Exception("Unreachable node")
-
-
/** Check whether the graph contains vertex v */
def contains(v: T): Boolean = edges.contains(v)
diff --git a/src/test/scala/firrtlTests/graph/DiGraphTests.scala b/src/test/scala/firrtlTests/graph/DiGraphTests.scala
index da268e4f..84122f83 100644
--- a/src/test/scala/firrtlTests/graph/DiGraphTests.scala
+++ b/src/test/scala/firrtlTests/graph/DiGraphTests.scala
@@ -37,11 +37,11 @@ class DiGraphTests extends FirrtlFlatSpec {
acyclicGraph.path("a","e") should not be empty
- an [acyclicGraph.PathNotFoundException] should be thrownBy acyclicGraph.path("e","a")
+ an [PathNotFoundException] should be thrownBy acyclicGraph.path("e","a")
acyclicGraph.linearize.head should equal ("a")
- a [cyclicGraph.CyclicException] should be thrownBy cyclicGraph.linearize
+ a [CyclicException] should be thrownBy cyclicGraph.linearize
acyclicGraph.reverse.getEdgeMap should equal (reversedAcyclicGraph.getEdgeMap)