Examples of GraphNode


Examples of org.drools.beliefs.graph.GraphNode

    @Test
    public void testMapNodeToCliques() {
        Graph<BayesVariable> graph = new BayesNetwork();
        JunctionTreeBuilder tbuilder = new JunctionTreeBuilder(graph);

        GraphNode x0 = addNode(graph);
        GraphNode x1 = addNode(graph);
        GraphNode x2 = addNode(graph);
        GraphNode x3 = addNode(graph);
        GraphNode x4 = addNode(graph);
        GraphNode x5 = addNode(graph);
        GraphNode x6 = addNode(graph);
        GraphNode x7 = addNode(graph);

        OpenBitSet clique0 = bitSet("01010101");
        OpenBitSet clique1 = bitSet("10010001");
        OpenBitSet clique2 = bitSet("10111010");
View Full Code Here

Examples of org.drools.beliefs.graph.GraphNode

    public void testFullExample1() {
        // from "Bayesian Belief Network Propagation Engine In Java"
        // the result here is slightly different, due to ordering, but it's still correct.
        // http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.135.7921&rep=rep1&type=pdf
        Graph<BayesVariable> graph = new BayesNetwork();
        GraphNode xa = addNode(graph);
        GraphNode xb = addNode(graph);
        GraphNode xc = addNode(graph);
        GraphNode xd = addNode(graph);
        GraphNode xe = addNode(graph);
        GraphNode xf = addNode(graph);
        GraphNode xg = addNode(graph);
        GraphNode xh = addNode(graph);

        connectParentToChildren(xa, xb, xc);
        connectParentToChildren(xb, xd);
        connectParentToChildren(xc, xe, xg);
        connectParentToChildren(xd, xf);
View Full Code Here

Examples of org.drools.beliefs.graph.GraphNode

    @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();
View Full Code Here

Examples of org.drools.beliefs.graph.GraphNode

        this.likelyhoods[id] = null;
        dirty = BitMaskUtil.set(dirty, id);
    }

    public void setLikelyhood(BayesVariable var, double[] distribution) {
        GraphNode node = graph.getNode( var.getId() );
        JunctionTreeClique clique = tree.getJunctionTreeNodes( )[var.getFamily()];

        setLikelyhood( new BayesLikelyhood(graph, clique, node, distribution ) );
    }
View Full Code Here

Examples of org.drools.beliefs.graph.GraphNode

        BayesVariable c = new BayesVariable<String>( "C", 2, new String[] {"C1", "C2"}new double[][] {{0.1, 0.2}});
        BayesVariable d = new BayesVariable<String>( "D", 3, new String[] {"D1", "D2"}new double[][] {{0.1, 0.2}, {0.3, 0.4}});


        Graph<BayesVariable> graph = new BayesNetwork();
        GraphNode x0 = addNode(graph);
        GraphNode x1 = addNode(graph);
        GraphNode x2 = addNode(graph);
        GraphNode x3 = addNode(graph);

        //connectParentToChildren(x0, x2);
        connectParentToChildren(x2, x3);

        x0.setContent( a );
        x1.setContent( b );
        x2.setContent( c );
        x3.setContent( d );


        JunctionTreeClique node1 = new JunctionTreeClique(0, graph, bitSet("0011") );
        JunctionTreeClique node2 = new JunctionTreeClique(1, graph, bitSet("1100")  );
        new JunctionTreeSeparator(0, node1, node2, new OpenBitSet(), graph);
View Full Code Here

Examples of org.eclipse.zest.core.widgets.GraphNode

    private void highlightBundles(BundleGraph graph, ISigilBundle selected,
        Set<ISigilBundle> connected)
    {
        for (ISigilBundle bundle : graph.getBundles())
        {
            GraphNode node = (GraphNode) findGraphItem(bundle);
            if (node != null)
            {
                node.unhighlight();

                if (bundle == selected)
                {
                    node.setHighlightColor(ColorConstants.yellow);
                    node.highlight();
                }
                else if (view.isDisplayed(BundleResolverView.DEPENDENTS))
                {
                    if (connected.contains(bundle))
                    {
                        node.setHighlightColor(ColorConstants.lightBlue);
                        node.highlight();
                    }
                }
            }
        }
    }
View Full Code Here

Examples of org.eclipse.zest.core.widgets.GraphNode

        Iterator nodes = viewer.getGraphControl().getNodes().iterator();
        Graph graph = viewer.getGraphControl();
        Dimension centre = new Dimension(graph.getBounds().width / 2, graph.getBounds().height / 2);
        while (nodes.hasNext()) {
            GraphNode graphNode = (GraphNode) nodes.next();
            if (graphNode.getLocation().x <= 1 && graphNode.getLocation().y <= 1) {
                graphNode.setLocation(centre.width, centre.height);
            }
        }

        currentRoot = focus;
View Full Code Here

Examples of org.eclipse.zest.core.widgets.GraphNode

   * @return has this node selected childen?
   */
  protected boolean hasSelectedSourceNodes(GraphNode node) {
    boolean result = false;
    for (Object connection : node.getTargetConnections()) {
      GraphNode source = ((GraphConnection) connection).getSource();
      if (getCheckboxFigure(source).isChecked()) {
        result = true;
        break;
      }

View Full Code Here

Examples of org.eclipse.zest.core.widgets.GraphNode

          .getElement();
      entry.getValue().addCheckListener(new ICheckListener() {

        @Override
        public void unchecked() {
          GraphNode node = getNodeForElement(element);
          for (Object connection : node.getSourceConnections()) {
            GraphNode destination = ((GraphConnection) connection)
                .getDestination();
            if (((GSSElementGraphNode) destination).getElement() instanceof Principle) {
              if (!hasSelectedSourceNodes(destination))
                getCheckboxFigure(destination).setIsUnchecked();
View Full Code Here

Examples of org.eclipse.zest.core.widgets.GraphNode

          .getElement();
      entry.getValue().addCheckListener(new ICheckListener() {

        @Override
        public void unchecked() {
          GraphNode node = getNodeForElement(element);
          for (Object connection : node.getSourceConnections()) {
            GraphNode destination = ((GraphConnection) connection)
                .getDestination();
            if (((GSSElementGraphNode) destination).getElement() instanceof Goal) {
              if (!hasSelectedSourceNodes(destination))
                getCheckboxFigure(destination).setIsUnchecked();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.