return true;
}
public CliqueTree findCliqueTree() {
Map<Vertex, Node> vertexCliqueMap = new HashMap<Vertex, Node>();
CliqueTree cliqueTree = new CliqueTree();
Vertex root = order[order.length - 1];
ArrayList<Vertex> rootCliqueVertices = new ArrayList<Vertex>();
rootCliqueVertices.add(root);
Node initialClique = new Node(null, rootCliqueVertices);
cliqueTree.addNode(initialClique);
vertexCliqueMap.put(root, initialClique);
for (int i = order.length - 2; i >= 0; i--) {
Vertex x = order[i];
ArrayList<Vertex> RNwithoutParent = new ArrayList<Vertex>(x.getRightNeighbours());
RNwithoutParent.remove(x.getParent());
ArrayList<Vertex> RNofParent = null;
if (x != null && x.getParent() != null && x.getParent().getRightNeighbours() != null) {
RNofParent = new ArrayList<Vertex>(x.getParent().getRightNeighbours());
}
if (!RNwithoutParent.equals(RNofParent)) {
ArrayList<Vertex> cliqueVertices = new ArrayList<Vertex>();
cliqueVertices.add(x);
cliqueVertices.addAll(x.getRightNeighbours());
Node clique = new Node(vertexCliqueMap.get(x.getParent()), cliqueVertices);
vertexCliqueMap.put(x, clique);
cliqueTree.addNode(clique);
} else {
Node parentClique = vertexCliqueMap.get(x.getParent());
ArrayList<Vertex> cliqueVerteces = new ArrayList<Vertex>();
boolean similarRN = false;
for (Vertex vertex : parentClique.getData()) {
if (x.getRightNeighbours().equals(vertex.getRightNeighbours())) {
similarRN = true;
break;
} else {
similarRN = false;
}
}
if (similarRN == false) {
cliqueVerteces.add(x);
cliqueVerteces.addAll(parentClique.getData());
parentClique.setData(cliqueVerteces);
vertexCliqueMap.put(x, parentClique);
} else {
cliqueVerteces.add(x);
cliqueVerteces.addAll(x.getRightNeighbours());
Node clique = new Node(vertexCliqueMap.get(x.getParent()), cliqueVerteces);
vertexCliqueMap.put(x, clique);
cliqueTree.addNode(clique);
}
}
}
return cliqueTree;
}