@Test
public void testFullExample2() {
// Bayesian Networks - A Self-contained introduction with implementation remarks
// http://www.mathcs.emory.edu/~whalen/Papers/BNs/Intros/BayesianNetworksTutorial.pdf
Graph<BayesVariable> graph = new BayesNetwork();
GraphNode xElectricity = addNode(graph); // 0
GraphNode xTelecom = addNode(graph); // 1
GraphNode xRail = addNode(graph); // 2
GraphNode xAirTravel = addNode(graph); // 3
GraphNode xTransportation = addNode(graph);// 4
GraphNode xUtilities = addNode(graph); // 5
GraphNode xUSBanks = addNode(graph); // 6
GraphNode xUSStocks = addNode(graph); // 7
connectParentToChildren( xElectricity, xRail, xAirTravel, xUtilities, xTelecom );
connectParentToChildren( xTelecom, xUtilities, xUSBanks );
connectParentToChildren( xRail, xTransportation );
connectParentToChildren( xAirTravel, xTransportation );
connectParentToChildren( xUtilities, xUSStocks );
connectParentToChildren( xUSBanks, xUSStocks );
connectParentToChildren( xTransportation, xUSStocks );
OpenBitSet clique1 = bitSet("11110000"); // Utilities, Transportation, USBanks, UStocks
OpenBitSet clique2 = bitSet("01110001"); // Electricity, Transportation, Utilities, USBanks
OpenBitSet clique3 = bitSet("01100011"); // Electricity, Telecom, Utilities, USBanks
OpenBitSet clique4 = bitSet("00011101"); // Electricity, Rail, AirTravel, Transportation
OpenBitSet clique1And2 = bitSet("01110000"); // Utilities, Transportation, USBanks
OpenBitSet clique2And3 = bitSet("01100001"); // Electricity, Utilities, USBanks
OpenBitSet clique2And4 = bitSet("00010001"); // Electricity, Transportation
xElectricity.setContent(new BayesVariable<String>("Electricity", xElectricity.getId(),
new String[]{"Working", "Reduced", "NotWorking"}, new double[][]{{0.6, 0.3, 0.099}}));
xTelecom.setContent(new BayesVariable<String>("Telecom", xTelecom.getId(),
new String[]{"Working", "Reduced", "NotWorking"}, new double[][]{{0.544, 0.304, 0.151}}));
xRail.setContent(new BayesVariable<String>("Rail", xRail.getId(),
new String[]{"Working", "Reduced", "NotWorking"}, new double[][]{{0.579, 0.230, 0.190}}));
xAirTravel.setContent(new BayesVariable<String>("AirTravel", xAirTravel.getId(),
new String[]{"Working", "Reduced", "NotWorking"}, new double[][]{{0.449, 0.330, 0.219}}));
xTransportation.setContent(new BayesVariable<String>("Transportation", xTransportation.getId(),
new String[]{"Working", "Moderate", "Severe", "Failure"}, new double[][]{{0.658, 0.167, 0.097, 0.077}}));
xUtilities.setContent(new BayesVariable<String>("Utilities", xUtilities.getId(),
new String[]{"Working", "Moderate", "Severe", "Failure"}, new double[][]{{0.541, 0.272, 0.097, 0.088}}));
xUSBanks.setContent(new BayesVariable<String>("USBanks", xUSBanks.getId(),
new String[]{"Working", "Reduced", "NotWorking"}, new double[][]{{0.488, 0.370, 0.141}}));
xUSStocks.setContent(new BayesVariable<String>("USStocks", xUSStocks.getId(),
new String[]{"Up", "Down", "Crash"}, new double[][]{{0.433, 0.386, 0.179}}));
JunctionTreeBuilder jtBuilder = new JunctionTreeBuilder( graph );
JunctionTreeClique root = jtBuilder.build(false).getRoot();