Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Collapse similar NFA states

  • Loading branch information...
commit 9a54c4c8c4cbd944ddd2ce29eec408e7a36e7cdf 1 parent 74f5c02
@colder authored
View
2  src/insane/alias/EffectRepresentations.scala
@@ -184,6 +184,8 @@ trait EffectRepresentations extends PointToGraphsDefs with PointToEnvs {
res = res.removeDeadPaths
+ res = res.collapseSimilarStates
+
res
}
}
View
15 src/insane/utils/Automatons.scala
@@ -61,6 +61,21 @@ object Automatons {
removeStates(states -- markedStates)
}
+
+ case class StateSig(ins: Set[(S, L)], outs: Set[(S, L)])
+
+ object StateSig {
+ def fromState(s: S): StateSig = {
+ StateSig(graph.ins(s).map(t => (t.v1, t.label)).toSet,
+ graph.outs(s).map(t => (t.v2, t.label)).toSet)
+ }
+ }
+ def collapseSimilarStates: Automaton[S, T, L] = {
+ // Keep the head of each kind, remove the rest
+ val toRemove = states.groupBy(StateSig.fromState _).values.flatMap(_.tail)
+
+ removeStates(toRemove)
+ }
}
class AutomatonDotConverter[S <: StateAbs, T <: TransitionAbs[L, S], L](atm: Automaton[S, T, L], _title: String, _prefix: String) extends DotConverter[S, T](atm.graph, _title, _prefix) {
Please sign in to comment.
Something went wrong with that request. Please try again.