diff options
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/scala/firrtl/graph/DiGraph.scala | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main/scala/firrtl/graph/DiGraph.scala b/src/main/scala/firrtl/graph/DiGraph.scala index 6538c880..6dad56d7 100644 --- a/src/main/scala/firrtl/graph/DiGraph.scala +++ b/src/main/scala/firrtl/graph/DiGraph.scala @@ -308,6 +308,17 @@ class DiGraph[T] private[graph] (private[graph] val edges: LinkedHashMap[T, Link edges.foreach({ case (k, v) => eprime(f(k)) ++= v.map(f(_)) }) new DiGraph(eprime) } + + /** Graph sum of `this` and `that` + * + * @param that a second DiGraph[T] + * @return a DiGraph[T] containing all vertices and edges of each graph + */ + def +(that: DiGraph[T]): DiGraph[T] = { + val eprime = edges.clone + that.edges.map({ case (k, v) => eprime.getOrElseUpdate(k, new LinkedHashSet[T]) ++= v }) + new DiGraph(eprime) + } } class MutableDiGraph[T] extends DiGraph[T](new LinkedHashMap[T, LinkedHashSet[T]]) { |
