use of org.iobserve.service.behavior.analysis.model.BehaviorModelNode in project iobserve-analysis by research-iobserve.
the class TestHelper method addNode.
public static void addNode(final BehaviorModelGED model, final String nodeName) {
final BehaviorModelNode node = new BehaviorModelNode(nodeName);
model.getNodes().put(nodeName, node);
}
use of org.iobserve.service.behavior.analysis.model.BehaviorModelNode in project iobserve-analysis by research-iobserve.
the class UserSessionToModelConverter method eventsToModel.
/**
* Converts a list of events into a behavior model
*
* @param events
* The list of events
* @return The behavior model
*/
public static BehaviorModelGED eventsToModel(final List<EntryCallEvent> events) {
final BehaviorModelGED model = new BehaviorModelGED();
final Iterator<EntryCallEvent> iterator = events.iterator();
// start with the node "init"
BehaviorModelNode currentNode = new BehaviorModelNode("Init");
model.getNodes().put("Init", currentNode);
BehaviorModelNode lastNode = currentNode;
// for all events
while (iterator.hasNext()) {
final PayloadAwareEntryCallEvent event = (PayloadAwareEntryCallEvent) iterator.next();
// current node is an existing node with the same name or if non-existing a new node
currentNode = model.getNodes().get(event.getOperationSignature());
if (currentNode == null) {
currentNode = new BehaviorModelNode(event.getOperationSignature());
}
// add node to model
model.getNodes().put(event.getOperationSignature(), currentNode);
// add edge to model
UserSessionToModelConverter.addEdge(event, model, lastNode, currentNode);
lastNode = currentNode;
}
return model;
}
use of org.iobserve.service.behavior.analysis.model.BehaviorModelNode 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;
}
Aggregations