From 991dacefdb8f78fccc359d3d2ec836dc2e7fc80a Mon Sep 17 00:00:00 2001 From: 20001LastOrder Date: Wed, 10 Jul 2019 10:56:00 -0400 Subject: measurements for the different violation types, comparison for differenct generation config --- .../metrics/calculator/graph/GraphStatistic.xtend | 42 +++++++++++++++------- 1 file changed, 29 insertions(+), 13 deletions(-) (limited to 'Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/graph/GraphStatistic.xtend') diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/graph/GraphStatistic.xtend b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/graph/GraphStatistic.xtend index 7ed58094..9b8fd0e3 100644 --- a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/graph/GraphStatistic.xtend +++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/graph/GraphStatistic.xtend @@ -5,20 +5,22 @@ import com.google.common.collect.Multimap import java.util.HashMap import java.util.HashSet import java.util.List +import java.util.Map +import java.util.Set import org.eclipse.emf.ecore.EObject class GraphStatistic { val incomingEdges = new HashMap>; val outcomingEdges = new HashMap>; - + val edgeTypes = new HashSet(); - val nodes = new HashSet(); - + val nodeToType = new HashMap>(); + /** * Add an edge type to to the graph * @param type: type to add */ - def void addType(String type){ + def void addEdgeType(String type){ if(edgeTypes.contains(type)){ return; } @@ -28,15 +30,20 @@ class GraphStatistic { } /** - * Add a node to he graph + * Add a node to the graph with one type in its type hierarchy * @param node: node to add */ - def void addNode(EObject n){ - if(nodes.contains(n)){ - return; - } - - nodes.add(n); + def void addNodeWithType(EObject n, String Type){ + var types = nodeToType.getOrDefault(n, new HashSet()); + types.add(Type); + nodeToType.put(n, types); + } + + /** + * Add a node to the graph with all types in its type hierarchy + */ + def void addNodeWithAllTypes(EObject n, Set types){ + nodeToType.put(n, types); } /** @@ -82,7 +89,7 @@ class GraphStatistic { } /** - * calculate the number of edge types for a given degree. + * calculate the number of edge types for a given node. */ def int numOfEdgeTypes(EObject o){ var count = 0; @@ -100,8 +107,17 @@ class GraphStatistic { return edgeTypes.toList(); } + def Map> getNodeToTypesMap(){ + return nodeToType; + } + def List getAllNodes(){ - return nodes.toList(); + return nodeToType.keySet().toList(); } + + def HashMap> getOutgoingEdges(){ + return outcomingEdges; + } + } -- cgit v1.2.3-54-g00ecf