Search in sources :

Example 6 with BehaviorModelEdge

use of org.iobserve.service.behavior.analysis.model.BehaviorModelEdge in project iobserve-analysis by research-iobserve.

the class TestHelper method createBehaviorModelE.

// only difference to A: additional node
public static BehaviorModelGED createBehaviorModelE() {
    final BehaviorModelGED model = new BehaviorModelGED();
    TestHelper.addNode(model, "Init");
    TestHelper.addNode(model, "A");
    TestHelper.addNode(model, "B");
    TestHelper.addNode(model, "C");
    // unconnected, but sould still increase distance
    TestHelper.addNode(model, "D");
    final String[] parameters = {};
    final String[] values = {};
    final BehaviorModelEdge edge1 = TestHelper.addEdge(model, "Init", "A");
    edge1.addEvent(TestHelper.createEvent(0, "A", parameters, values));
    final BehaviorModelEdge edge2 = TestHelper.addEdge(model, "A", "B");
    edge2.addEvent(TestHelper.createEvent(1, "A", parameters, values));
    final BehaviorModelEdge edge3 = TestHelper.addEdge(model, "B", "C");
    edge3.addEvent(TestHelper.createEvent(2, "C", parameters, values));
    return model;
}
Also used : BehaviorModelEdge(org.iobserve.service.behavior.analysis.model.BehaviorModelEdge) BehaviorModelGED(org.iobserve.service.behavior.analysis.model.BehaviorModelGED)

Example 7 with BehaviorModelEdge

use of org.iobserve.service.behavior.analysis.model.BehaviorModelEdge in project iobserve-analysis by research-iobserve.

the class TestHelper method createBehaviorModelA.

public static BehaviorModelGED createBehaviorModelA() {
    final BehaviorModelGED model = new BehaviorModelGED();
    TestHelper.addNode(model, "Init");
    TestHelper.addNode(model, "A");
    TestHelper.addNode(model, "B");
    TestHelper.addNode(model, "C");
    final String[] parameters = {};
    final String[] values = {};
    final BehaviorModelEdge edge1 = TestHelper.addEdge(model, "Init", "A");
    edge1.addEvent(TestHelper.createEvent(0, "A", parameters, values));
    final BehaviorModelEdge edge2 = TestHelper.addEdge(model, "A", "B");
    edge2.addEvent(TestHelper.createEvent(1, "A", parameters, values));
    final BehaviorModelEdge edge3 = TestHelper.addEdge(model, "B", "C");
    edge3.addEvent(TestHelper.createEvent(2, "C", parameters, values));
    return model;
}
Also used : BehaviorModelEdge(org.iobserve.service.behavior.analysis.model.BehaviorModelEdge) BehaviorModelGED(org.iobserve.service.behavior.analysis.model.BehaviorModelGED)

Example 8 with BehaviorModelEdge

use of org.iobserve.service.behavior.analysis.model.BehaviorModelEdge in project iobserve-analysis by research-iobserve.

the class TestHelper method createBehaviorModelB.

// only difference to A: different values
public static BehaviorModelGED createBehaviorModelB() {
    final BehaviorModelGED model = new BehaviorModelGED();
    TestHelper.addNode(model, "Init");
    TestHelper.addNode(model, "A");
    TestHelper.addNode(model, "B");
    TestHelper.addNode(model, "C");
    final String[] parameters = {};
    final String[] values = { "different value" };
    final BehaviorModelEdge edge1 = TestHelper.addEdge(model, "Init", "A");
    edge1.addEvent(TestHelper.createEvent(0, "A", parameters, values));
    final BehaviorModelEdge edge2 = TestHelper.addEdge(model, "A", "B");
    edge2.addEvent(TestHelper.createEvent(1, "A", parameters, values));
    final BehaviorModelEdge edge3 = TestHelper.addEdge(model, "B", "C");
    edge3.addEvent(TestHelper.createEvent(2, "C", parameters, values));
    return model;
}
Also used : BehaviorModelEdge(org.iobserve.service.behavior.analysis.model.BehaviorModelEdge) BehaviorModelGED(org.iobserve.service.behavior.analysis.model.BehaviorModelGED)

Example 9 with BehaviorModelEdge

use of org.iobserve.service.behavior.analysis.model.BehaviorModelEdge in project iobserve-analysis by research-iobserve.

the class UserSessionToModelConverter method addEdge.

/**
 * Adds an edge to a model, if the edge does not exist already
 *
 * @param event
 * @param model
 * @param source
 * @param target
 */
public static void addEdge(final PayloadAwareEntryCallEvent event, final BehaviorModelGED model, final BehaviorModelNode source, final BehaviorModelNode target) {
    final BehaviorModelEdge matchingEdge = source.getOutgoingEdges().get(target);
    // if edge does not exist yet
    if (matchingEdge == null) {
        final BehaviorModelEdge newEdge = new BehaviorModelEdge(event, source, target);
        // add references to the model and the nodes
        source.getOutgoingEdges().put(target, newEdge);
        target.getIngoingEdges().put(source, newEdge);
        model.getEdges().add(newEdge);
    } else {
        // if edge already exists
        matchingEdge.addEvent(event);
    }
}
Also used : BehaviorModelEdge(org.iobserve.service.behavior.analysis.model.BehaviorModelEdge)

Example 10 with BehaviorModelEdge

use of org.iobserve.service.behavior.analysis.model.BehaviorModelEdge in project iobserve-analysis by research-iobserve.

the class GraphEditDistance method nodeDistance.

/**
 * Calculates the distance between two nodes. This includes the distance between the ingoing
 * edges
 */
private double nodeDistance(final BehaviorModelNode node1, final BehaviorModelNode node2) {
    double distance = 0;
    for (final BehaviorModelEdge edge : node1.getIngoingEdges().values()) {
        final BehaviorModelNode source1 = edge.getSource();
        final BehaviorModelNode source2 = this.model2.getNodes().get(source1.getName());
        final BehaviorModelEdge match = node2.getIngoingEdges().get(source2);
        if (match == null) {
            // edge only occurs in one node => must be inserted
            distance += this.edgeInsertionCost(edge);
        } else {
            // edge occurs in both nodes => must be compared
            distance += this.edgeDistance(edge, match);
        }
    }
    for (final BehaviorModelEdge edge : node2.getIngoingEdges().values()) {
        final BehaviorModelNode source2 = edge.getSource();
        final BehaviorModelNode source1 = this.model1.getNodes().get(source2.getName());
        final BehaviorModelEdge match = node1.getIngoingEdges().get(source1);
        // edge only occurs in one node => must be inserted
        if (match == null) {
            distance += this.edgeInsertionCost(edge);
        }
    }
    return distance;
}
Also used : BehaviorModelNode(org.iobserve.service.behavior.analysis.model.BehaviorModelNode) BehaviorModelEdge(org.iobserve.service.behavior.analysis.model.BehaviorModelEdge)

Aggregations

BehaviorModelEdge (org.iobserve.service.behavior.analysis.model.BehaviorModelEdge)10 BehaviorModelGED (org.iobserve.service.behavior.analysis.model.BehaviorModelGED)7 BehaviorModelNode (org.iobserve.service.behavior.analysis.model.BehaviorModelNode)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 EventGroup (org.iobserve.service.behavior.analysis.model.EventGroup)1 PayloadAwareEntryCallEvent (org.iobserve.stages.general.data.PayloadAwareEntryCallEvent)1 Test (org.junit.Test)1