protected static Clique createClique(MoralGraphNode node) { BruseNode[] family = new BruseNode[node.getNeighbors().size() + 1]; ArrayList<GraphNode> neighbors = node.getNeighbors(); // add the simplicial node to the family family[0] = node.getBruseNode(); // add the simplicial nodes neighbors to the family for (int i = 0; i < neighbors.size(); i++) { MoralGraphNode neighbor = (MoralGraphNode) neighbors.get(i); family[i + 1] = neighbor.getBruseNode(); } // System.out.println("Clique size: " + domSize(node)); return (new Clique(family)); }
private static int numFillIns(MoralGraphNode node) { ArrayList<GraphNode> neighbors = node.getNeighbors(); int numFillIns = 0; for (int i = 0; i < neighbors.size(); i++) { MoralGraphNode neighbor = (MoralGraphNode) neighbors.get(i); for (int j = 0; j < neighbors.size(); j++) { if (i != j) { MoralGraphNode otherNeighbor = (MoralGraphNode) neighbors.get(j); // If neighbor is not connected then a fillin would be required if (neighbor.getNeighbors().contains(otherNeighbor) == false) numFillIns++; } } } return numFillIns; }
protected static boolean isSimplicialNode(MoralGraphNode node) { ArrayList<GraphNode> neighbors = node.getNeighbors(); for (int i = 0; i < neighbors.size(); i++) { MoralGraphNode neighbor = (MoralGraphNode) neighbors.get(i); for (int j = 0; j < neighbors.size(); j++) { if (i != j) { MoralGraphNode otherNeighbor = (MoralGraphNode) neighbors.get(j); // If neighbor is not fully connected then this is not a simplicial node if (neighbor.getNeighbors().contains(otherNeighbor) == false) return false; } } } // must be a simplicial node if we make it here return true; }
protected static void removeNode(MoralGraph graph, MoralGraphNode node) { ArrayList<GraphNode> neighbors = node.getNeighbors(); for (int i = 0; i < neighbors.size(); i++) { MoralGraphNode neighbor = (MoralGraphNode) neighbors.get(i); neighbor.removeNeighbor(node); } graph.removeNode(node); }
protected static long domSize(MoralGraphNode node) { long dom = node.getBruseNode().getStates().size(); ArrayList<GraphNode> neighbors = node.getNeighbors(); for (int i = 0; i < neighbors.size(); i++) { MoralGraphNode neighbor = (MoralGraphNode) neighbors.get(i); dom *= neighbor.getBruseNode().getStates().size(); } return dom; }
protected static void createFillIns(MoralGraphNode node) { ArrayList<GraphNode> neighbors = node.getNeighbors(); for (int i = 0; i < neighbors.size(); i++) { MoralGraphNode neighbor = (MoralGraphNode) neighbors.get(i); for (int j = 0; j < neighbors.size(); j++) { if (i != j) { MoralGraphNode otherNeighbor = (MoralGraphNode) neighbors.get(j); // Add the neighbor // Note this will ignore if already a neighbor neighbor.addNeighbor(otherNeighbor); } } } }