if (prevToNewMap == null) {
prevToNewMap = wordMapFactory.newMap();
}
Set<IndexedWord> vertexes = g.vertexSet();
for (IndexedWord vertex : vertexes) {
IndexedWord newVertex = new IndexedWord(vertex);
addVertex(newVertex);
prevToNewMap.put(vertex, newVertex);
}
roots = wordMapFactory.newSet();
for (IndexedWord oldRoot : g.getRoots()) {
roots.add(prevToNewMap.get(oldRoot));
}
for (SemanticGraphEdge edge : g.edgeIterable()) {
IndexedWord newGov = prevToNewMap.get(edge.getGovernor());
IndexedWord newDep = prevToNewMap.get(edge.getDependent());
addEdge(newGov, newDep, edge.getRelation(), edge.getWeight(), edge.isExtra());
}
}