EdgeIterator graphEdges = graph.getGraph().edges();
VertexInfo src;
VertexInfo dest;
seenFirstState = false;
while (graphEdges.hasNext()) {
Edge e = graphEdges.nextEdge();
if (!vertices.containsKey(graph.getGraph().origin(e).element())) {
src = new VertexInfo(graph.getGraph().origin(e).element());
} else {
src = (VertexInfo) vertices.get(graph.getGraph().origin(e).element());
}
g.addVertex(src);
if (!seenFirstState) {
src.setStartState(true);
seenFirstState = true;
}
vertices.put(src.getName(), src);
if (!vertices.containsKey(graph.getGraph().destination(e).element())) {
dest = new VertexInfo(graph.getGraph().destination(e).element());
} else {
dest = (VertexInfo) vertices.get(graph.getGraph().destination(e).element());
}
g.addVertex(dest);
vertices.put(dest.getName(), dest);
Transition action = new Transition(src.getName(), (String) e.element(), dest.getName());
EdgeInfo edge = new EdgeInfo(action, src, dest);
g.addEdge(edge, src, dest);
edges.put(action, edge);
edge.getSrcVertex().setOutgoingEdges(edge.getSrcVertex().getOutgoingEdges() + 1);