Package core.Trees

Examples of core.Trees.CliqueTree


        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;
    }
View Full Code Here


//            System.out.println();

                if (graph.isChordal() == true) {
//                System.out.println("Corresponding cliques are:");
//                long cliqueTreeStartTime = System.nanoTime();
                    CliqueTree nodeCliqueTree = graph.findCliqueTree();
//                long cliqueTreeEndTime = System.nanoTime() - cliqueTreeStartTime;
//                System.out.println("Finding clique tree time is - " + cliqueTreeEndTime);
//                System.out.println(nodeCliqueTree.toString());
//                System.out.println();
//                long findingIntervalityStartTime = System.nanoTime();
View Full Code Here

TOP

Related Classes of core.Trees.CliqueTree

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.