/// <summary> /// Optimizes the automaton by removing all states which can't reach end states. /// </summary> public bool RemoveDeadStates() { var builder = Builder.FromAutomaton(this); var simplification = new Simplification(builder, this.PruneTransitionsWithLogWeightLessThan); if (simplification.RemoveDeadStates()) { this.Data = builder.GetData(); return(true); } return(false); }
/// <summary> /// Optimizes the automaton by removing all states which can't reach end states. /// </summary> public bool RemoveDeadStates() { var builder = Builder.FromAutomaton(this); var initialStatesCount = builder.StatesCount; var simplification = new Simplification(builder, this.PruneStatesWithLogEndWeightLessThan); simplification.RemoveDeadStates(); if (builder.StatesCount != initialStatesCount) { this.Data = builder.GetData(); return(true); } return(false); }
/// <summary> /// Optimizes the automaton by removing all states which can't reach end states. /// </summary> /// <returns>Result automaton. Simplified automaton, if there were states to be removed, current automaton otherwise.</returns> public TThis RemoveDeadStates() { var builder = Builder.FromAutomaton(this); var initialStatesCount = builder.StatesCount; var simplification = new Simplification(builder, this.PruneStatesWithLogEndWeightLessThan); simplification.RemoveDeadStates(); if (builder.StatesCount != initialStatesCount) { return(WithData(builder.GetData())); } else { return((TThis)this); } }