net.automatalib.util.ts.TS Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of automata-util Show documentation
Show all versions of automata-util Show documentation
This artifact provides various common utility operations for analyzing and manipulating
automata and graphs, such as traversal, minimization and copying.
/* Copyright (C) 2013-2019 TU Dortmund
* This file is part of AutomataLib, http://www.automatalib.net/.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.automatalib.util.ts;
import java.util.Collection;
import java.util.Iterator;
import java.util.function.Function;
import net.automatalib.ts.DeterministicTransitionSystem;
import net.automatalib.ts.TransitionSystem;
import net.automatalib.ts.UniversalTransitionSystem;
import net.automatalib.util.ts.iterators.AllDefinedInputsIterator;
import net.automatalib.util.ts.iterators.AllUndefinedInputsIterator;
import net.automatalib.util.ts.iterators.DefinedInputsIterator;
import net.automatalib.util.ts.iterators.UndefinedInputsIterator;
import net.automatalib.util.ts.traversal.BFSOrderIterator;
public class TS {
protected TS() {
}
public static Iterable bfsOrder(TransitionSystem ts, Collection extends I> inputs) {
return () -> bfsOrderIterator(ts, inputs);
}
public static Iterator bfsOrderIterator(TransitionSystem ts, Collection extends I> inputs) {
return new BFSOrderIterator<>(ts, inputs);
}
public static Function stateProperties(final UniversalTransitionSystem uts) {
return uts::getStateProperty;
}
public static Function transitionProperties(final UniversalTransitionSystem, ?, T, ?, TP> uts) {
return uts::getTransitionProperty;
}
public static Iterable definedInputs(final DeterministicTransitionSystem dts,
final S state,
final Iterable extends I> inputs) {
return () -> definedInputsIterator(dts, state, inputs.iterator());
}
public static Iterator definedInputsIterator(TransitionSystem ts,
S state,
Iterator extends I> inputsIt) {
return new DefinedInputsIterator<>(ts, state, inputsIt);
}
public static Iterable> allDefinedInputs(final TransitionSystem ts,
final Iterable extends S> states,
final Iterable extends I> inputs) {
return () -> allDefinedInputsIterator(ts, states.iterator(), inputs);
}
public static Iterator> allDefinedInputsIterator(TransitionSystem ts,
Iterator extends S> stateIt,
Iterable extends I> inputs) {
return new AllDefinedInputsIterator<>(stateIt, ts, inputs);
}
public static Iterable undefinedInputs(final TransitionSystem ts,
final S state,
final Iterable extends I> inputs) {
return () -> undefinedInputsIterator(ts, state, inputs.iterator());
}
public static Iterator undefinedInputsIterator(TransitionSystem ts,
S state,
Iterator extends I> inputsIt) {
return new UndefinedInputsIterator<>(ts, state, inputsIt);
}
public static Iterable> allUndefinedTransitions(final TransitionSystem ts,
final Iterable extends S> states,
final Iterable extends I> inputs) {
return () -> allUndefinedTransitionsIterator(ts, states.iterator(), inputs);
}
public static Iterator> allUndefinedTransitionsIterator(TransitionSystem ts,
Iterator extends S> stateIt,
Iterable extends I> inputs) {
return new AllUndefinedInputsIterator<>(stateIt, ts, inputs);
}
public static final class TransRef {
public final S state;
public final I input;
public final T transition;
public TransRef(S state, I input) {
this(state, input, null);
}
public TransRef(S state, I input, T transition) {
this.state = state;
this.input = input;
this.transition = transition;
}
}
}