public boolean canAddArc(Object source, Object target, Object input, Object output) { Arc a = new Arc(source, target, input, output); if (arcs.contains(a)) // inexpensive check { return false; } Pair p = Generics.newPair(source, input); return !arcsBySourceAndInput.containsKey(p); // expensive check }
public static void addOnePathToGraph(List path, double count, int markovOrder, TransducerGraph graph) { Object source = graph.getStartNode(); for (int j = 0; j < path.size(); j++) { Object input = path.get(j); Arc a = graph.getArcBySourceAndInput(source, input); if (a != null) { // increment the arc weight a.output = new Double(((Double) a.output).doubleValue() + count); } else { Object target; if (input.equals(TransducerGraph.EPSILON_INPUT)) { target = "END"; // to ensure they all share the same end node } else if (markovOrder == 0) { // we all transition back to the same state target = source; } else if (markovOrder > 0) { // the state is described by the partial history target = path.subList((j < markovOrder ? 0 : j - markovOrder + 1), j + 1); } else { // the state is described by the full history target = path.subList(0, j + 1); } Double output = new Double(count); a = new Arc(source, target, input, output); graph.addArc(a); } source = a.getTargetNode(); } graph.setEndNode(source); }
a = new Arc(a); // make a copy if (arcProcessor != null) { a = arcProcessor.processArc(a);
public boolean canAddArc(Object source, Object target, Object input, Object output) { Arc a = new Arc(source, target, input, output); if (arcs.contains(a)) // inexpensive check { return false; } Pair p = Generics.newPair(source, input); return !arcsBySourceAndInput.containsKey(p); // expensive check }
/** * @return true if and only if it created a new Arc and added it to the graph. */ public boolean addArc(Object source, Object target, Object input, Object output) { Arc a = new Arc(source, target, input, output); return addArc(a); }
/** * @return true if and only if it created a new Arc and added it to the graph. */ public boolean addArc(Object source, Object target, Object input, Object output) { Arc a = new Arc(source, target, input, output); return addArc(a); }
@Override public Arc processArc(Arc a) { a = new Arc(a); a.setInput(Generics.newPair(a.getInput(), a.getOutput())); a.setOutput(null); return a; } }
public boolean canAddArc(Object source, Object target, Object input, Object output) { Arc a = new Arc(source, target, input, output); if (arcs.contains(a)) // inexpensive check { return false; } Pair p = Generics.newPair(source, input); return !arcsBySourceAndInput.containsKey(p); // expensive check }
/** * @return true if and only if it created a new Arc and added it to the graph. */ public boolean addArc(Object source, Object target, Object input, Object output) { Arc a = new Arc(source, target, input, output); return addArc(a); }
@Override public Arc processArc(Arc a) { a = new Arc(a); a.setSourceNode(nodeProcessor.processNode(a.getSourceNode())); a.setTargetNode(nodeProcessor.processNode(a.getTargetNode())); return a; } }
@Override public Arc processArc(Arc a) { a = new Arc(a); a.setInput(Generics.newPair(a.getInput(), a.getOutput())); a.setOutput(null); return a; } }
public Arc processArc(Arc a) { a = new Arc(a); Pair p = (Pair) a.getInput(); a.setInput(p.first); a.setOutput(p.second); return a; } }
@Override public Arc processArc(Arc a) { a = new Arc(a); a.setInput(Generics.newPair(a.getInput(), a.getOutput())); a.setOutput(null); return a; } }
@Override public Arc processArc(Arc a) { a = new Arc(a); Pair p = (Pair) a.getInput(); a.setInput(p.first); a.setOutput(p.second); return a; } }
@Override public Arc processArc(Arc a) { a = new Arc(a); a.setSourceNode(nodeProcessor.processNode(a.getSourceNode())); a.setTargetNode(nodeProcessor.processNode(a.getTargetNode())); return a; } }
@Override public Arc processArc(Arc a) { a = new Arc(a); Pair p = (Pair) a.getInput(); a.setInput(p.first); a.setOutput(p.second); return a; } }
@Override public Arc processArc(Arc a) { a = new Arc(a); a.setSourceNode(nodeProcessor.processNode(a.getSourceNode())); a.setTargetNode(nodeProcessor.processNode(a.getTargetNode())); return a; } }
@Override public Arc processArc(Arc a) { a = new Arc(a); a.setInput(Generics.newPair(a.getInput(), a.getOutput())); a.setOutput(null); return a; } }
@Override public Arc processArc(Arc a) { a = new Arc(a); Pair p = (Pair) a.getInput(); a.setInput(p.first); a.setOutput(p.second); return a; } }
/** * @return true if and only if it created a new Arc and added it to the graph. */ public boolean addArc(Object source, Object target, Object input, Object output) { Arc a = new Arc(source, target, input, output); return addArc(a); }