/** @param args */ public static void main(String[] args) throws IOException { // TODO Auto-generated method stub Clique c = new Clique(); c.LoadData("egfr20_flat"); // c.LoadData("tcrsig40_flat"); c.Solve(); c.Save("cliques"); }
@Test public void createsOneElementClique() throws GraphCreationException { Clique clique = new Clique(1); TestSyntheticGraphMaker maker = new TestSyntheticGraphMaker(clique); clique.create(maker); assertEquals(1, maker.numNodes()); assertEquals(1, maker.totalNumNodes()); assertEquals(0, maker.get(0, 0)); }
@Test public void createsTenElementsClique() throws GraphCreationException { Clique clique = new Clique(10); TestSyntheticGraphMaker maker = new TestSyntheticGraphMaker(clique); clique.create(maker); assertEquals(10, maker.numNodes()); assertEquals(10, maker.totalNumNodes()); for (int i = 0; i < 10; ++i) { for (int j = 0; j < 10; ++j) { assertEquals(i != j ? 1 : 0, maker.get(i, j)); } } }
protected static ArrayList<Clique> getMaxCliques(ArrayList<Clique> cliques) { Clique c1, c2; ArrayList<Clique> maxCliques = new ArrayList<Clique>(); maxCliques.addAll(cliques); for (int i = 0; i < cliques.size(); i++) { c1 = cliques.get(i); for (int j = 0; j < cliques.size(); j++) { c2 = cliques.get(j); if ((i != j) && (c1.isSubSet(c2))) { maxCliques.remove(c1); } } } return maxCliques; }
protected static void assignPotentials(BruseNetwork network, ArrayList<Clique> cliques) { Clique clique = null, bestClique = null; BruseNode node = null; BruseTable table = null; // Uniquely assign a potential to a clique that covers the domain of the potential // If there are several qualifying cliques we choose the first clique // TODO: Try a different hueristic where we assign the potential to the clique // with the min domain difference. // Ex: pot(A,B) matches Clique(A,B,C,D) and Clique(A,B,E) // choose Clique(A,B,E) because it has the min domain difference for (int i = 0; i < network.getAllNodes().size(); i++) { node = network.getAllNodes().get(i); table = node.getTable(); for (int j = 0; j < cliques.size(); j++) { clique = cliques.get(j); if (clique.containsNodes( table.getVariableNames())) { // getMembers().containsAll(table.getVariables())) { if ((bestClique == null) || (bestClique.getPotentials().size() > clique.getPotentials().size())) { bestClique = clique; } // clique.addPotential(table); // break; } } bestClique.addPotential(table); bestClique = null; } // all cliques now have initial potentials set - this is for resetting potentials for (int i = 0; i < cliques.size(); i++) { clique = cliques.get(i); clique.setInitPotentials(); } }