for(int j = i + 1; j < neighbors.size(); j++){
Integer degree1 = neighbors.get(i).getConnectivity();
Integer degree2 = neighbors.get(j).getConnectivity();
Integer leftNodeId, rightNodeId;
DNVNode leftNode, rightNode;
DNVEdge leftEdge, rightEdge, middleEdge;
Tuple<Integer, Integer, Integer> degreeTuple;
//for each node tuple, the left node degree should be no smaller than the right one
if(degree1 >= degree2){
leftNode = neighbors.get(i);
rightNode = neighbors.get(j);
degreeTuple = new Tuple<Integer, Integer, Integer>(degree1, highDegree,degree2);
}else{
leftNode = neighbors.get(j);
rightNode = neighbors.get(i);
degreeTuple = new Tuple<Integer, Integer, Integer>(degree2, highDegree,degree1);
}
leftNodeId = leftNode.getId();
rightNodeId = rightNode.getId();
leftEdge = middlenode.getEdgeToNeighbor(leftNodeId);
rightEdge = middlenode.getEdgeToNeighbor(rightNodeId);
if(!degreeOccurTableDK3.containsKey(degreeTuple)){
degreeOccurTableDK3.put(degreeTuple, 0);
degreeUniqueEdgeTableDK3.put(degreeTuple, new HashSet<DNVEdge>());
degreeUniqueNodeTableDK3.put(degreeTuple, new HashSet<DNVNode>());
}
degreeOccurTableDK3.put(degreeTuple, degreeOccurTableDK3.get(degreeTuple) + 1);
degreeUniqueEdgeTableDK3.get(degreeTuple).add(leftEdge);
degreeUniqueEdgeTableDK3.get(degreeTuple).add(rightEdge);
degreeUniqueNodeTableDK3.get(degreeTuple).add(middlenode);
degreeUniqueNodeTableDK3.get(degreeTuple).add(leftNode);
degreeUniqueNodeTableDK3.get(degreeTuple).add(rightNode);
if(leftNode.getNeighbors().contains(rightNode) || rightNode.getNeighbors().contains(leftNode)){
middleEdge = leftNode.getEdgeToNeighbor(rightNodeId);
Triangle triangle = new Triangle(leftNode, middlenode, rightNode, leftEdge, middleEdge, rightEdge);
triangles.add(triangle);
degreeUniqueEdgeTableDK3.get(degreeTuple).add(middleEdge);
triangleCnt++;
}else{
Line line = new Line(leftNode, middlenode, rightNode, leftEdge, rightEdge);
lines.add(line);
lineCnt++;
}
cnt++;
}
}
}
if(traveledNodesId.contains(lowDegreeNodeId)){
continue;
}
//next get all the tuple nodes with the lower degree node in the center and the higher degree node at one end
DNVNode middlenode = graph.getNode(level, lowDegreeNodeId);
DNVNode leftNode = graph.getNode(level, highDegreeNodeId);
DNVEdge leftEdge = tuple.getRight();
DNVEdge rightEdge, middleEdge;
//get all the neighbors of the lower degree node which haven't been traveled
ArrayList<DNVNode> neighbors = new ArrayList<DNVNode>();
for(DNVEdge edge : middlenode.getFromEdges()){
if(!traveledNodesId.contains(edge.getToId())){
neighbors.add(graph.getNode(level, edge.getToId()));