Search in sources :

Example 1 with EdgeImpl

use of org.drools.beliefs.graph.impl.EdgeImpl in project drools by kiegroup.

the class GraphTest method connectParentToChildren.

public static void connectParentToChildren(GraphNode parent, GraphNode... children) {
    for (GraphNode child : children) {
        EdgeImpl e = new EdgeImpl();
        e.setOutGraphNode(parent);
        e.setInGraphNode(child);
    }
}
Also used : EdgeImpl(org.drools.beliefs.graph.impl.EdgeImpl) GraphNode(org.drools.beliefs.graph.GraphNode)

Example 2 with EdgeImpl

use of org.drools.beliefs.graph.impl.EdgeImpl in project drools by kiegroup.

the class GraphTest method connectChildToParents.

public static void connectChildToParents(GraphNode child, GraphNode... parents) {
    for (GraphNode parent : parents) {
        EdgeImpl e = new EdgeImpl();
        e.setOutGraphNode(parent);
        e.setInGraphNode(child);
    }
}
Also used : EdgeImpl(org.drools.beliefs.graph.impl.EdgeImpl) GraphNode(org.drools.beliefs.graph.GraphNode)

Example 3 with EdgeImpl

use of org.drools.beliefs.graph.impl.EdgeImpl in project drools by kiegroup.

the class SprinkerTest method connectParentToChildren.

public static void connectParentToChildren(GraphNode parent, GraphNode... children) {
    for (GraphNode child : children) {
        EdgeImpl e = new EdgeImpl();
        e.setOutGraphNode(parent);
        e.setInGraphNode(child);
    }
}
Also used : EdgeImpl(org.drools.beliefs.graph.impl.EdgeImpl) GraphNode(org.drools.beliefs.graph.GraphNode)

Example 4 with EdgeImpl

use of org.drools.beliefs.graph.impl.EdgeImpl in project drools by kiegroup.

the class XmlBifParser method buildBayesNetwork.

public static BayesNetwork buildBayesNetwork(Bif bif) {
    String name = bif.getNetwork().getName();
    String packageName = "default";
    List<String> props = bif.getNetwork().getProperties();
    if (props != null) {
        for (String prop : props) {
            prop = prop.trim();
            if (prop.startsWith("package")) {
                packageName = prop.substring(prop.indexOf('=') + 1).trim();
            }
        }
    }
    BayesNetwork graph = new BayesNetwork(name, packageName);
    Map<String, GraphNode<BayesVariable>> map = new HashMap<String, GraphNode<BayesVariable>>();
    for (Definition def : bif.getNetwork().getDefinitions()) {
        GraphNode<BayesVariable> node = graph.addNode();
        BayesVariable var = buildVariable(def, bif.getNetwork(), node.getId());
        node.setContent(var);
        map.put(var.getName(), node);
    }
    for (Entry<String, GraphNode<BayesVariable>> entry : map.entrySet()) {
        GraphNode<BayesVariable> node = entry.getValue();
        BayesVariable var = node.getContent();
        if (var.getGiven() != null && var.getGiven().length > 0) {
            for (String given : var.getGiven()) {
                GraphNode<BayesVariable> givenNode = map.get(given);
                EdgeImpl e = new EdgeImpl();
                e.setOutGraphNode(givenNode);
                e.setInGraphNode(node);
            }
        }
    }
    return graph;
}
Also used : BayesVariable(org.drools.beliefs.bayes.BayesVariable) HashMap(java.util.HashMap) EdgeImpl(org.drools.beliefs.graph.impl.EdgeImpl) GraphNode(org.drools.beliefs.graph.GraphNode) BayesNetwork(org.drools.beliefs.bayes.BayesNetwork)

Aggregations

GraphNode (org.drools.beliefs.graph.GraphNode)4 EdgeImpl (org.drools.beliefs.graph.impl.EdgeImpl)4 HashMap (java.util.HashMap)1 BayesNetwork (org.drools.beliefs.bayes.BayesNetwork)1 BayesVariable (org.drools.beliefs.bayes.BayesVariable)1