{
Vertex v = vertexIt.next();
outLabels.clear();
Iterator<DirectedSparseEdge>outEdgeIt = v.getOutEdges().iterator();
while(outEdgeIt.hasNext()){
DirectedSparseEdge outEdge = outEdgeIt.next();
outLabels.addAll( (Set<String>)outEdge.getUserDatum(JUConstants.LABEL) );
}
transitionsToBeAdded = !alphabet.equals(outLabels);
}
if (transitionsToBeAdded)
{
// third pass - adding transitions
g.addVertex(rejectVertex);
vertexIt = (Iterator<Vertex>)g.getVertices().iterator();
while(vertexIt.hasNext())
{
Vertex v = vertexIt.next();
if (v != rejectVertex)
{// no transitions should start from the reject vertex
Set<String> outgoingLabels = new TreeSet<String>();outgoingLabels.addAll(alphabet);
Iterator<DirectedSparseEdge>outEdgeIt = v.getOutEdges().iterator();
while(outEdgeIt.hasNext()){
DirectedSparseEdge outEdge = outEdgeIt.next();
outgoingLabels.removeAll( (Set<String>)outEdge.getUserDatum(JUConstants.LABEL) );
}
if (!outgoingLabels.isEmpty())
{
// add a transition
DirectedSparseEdge edge = new DirectedSparseEdge(v,rejectVertex);
edge.addUserDatum(JUConstants.LABEL, outgoingLabels, UserData.CLONE);
g.addEdge(edge);
}
}
}
}