// Separate out the vertex set for our new folded graph.
for (Object vert : graphCopy.getVertices()) {
if (vert instanceof Identity) {
Identity ivert = (Identity) vert;
LabelVertex v = new LabelVertex(ivert);
foldedGraph.addVertex(v);
identMap.put(ivert, v);
} else {
objVerts.add(vert);
}
}
for (Object objVert : objVerts) {
// We know objVert is not an Identity because of the loop above.
List<Object> neighbors =
new ArrayList<Object>(graphCopy.getNeighbors(objVert));
int length = neighbors.size();
for (int i = 0; i < length - 1; i++) {
Object neighbor = neighbors.get(i);
Identity v1 = (Identity) neighbor;
for (int j = i + 1; j < length; j++) {
neighbor = neighbors.get(j);
Identity v2 = (Identity) neighbor;
// The weight of the edge representing this use
// is the min of the counts of each identity's use
// of the object
long e1Weight = graphCopy.findEdge(v1, objVert).getWeight();
long e2Weight = graphCopy.findEdge(v2, objVert).getWeight();
long minWeight = Math.min(e1Weight, e2Weight);
LabelVertex label1 = getVertex(v1);
LabelVertex label2 = getVertex(v2);
WeightedEdge edge = foldedGraph.findEdge(label1, label2);
if (edge == null) {
foldedGraph.addEdge(new WeightedEdge(minWeight),
label1, label2);
} else {