diff options
author | 2019-07-10 10:56:00 -0400 | |
---|---|---|
committer | 2019-07-10 10:56:00 -0400 | |
commit | 991dacefdb8f78fccc359d3d2ec836dc2e7fc80a (patch) | |
tree | 6b18aa59c5f711a845aa9e3e5cf3fd3632ad7a33 /Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/graph/GraphStatistic.xtend | |
parent | add sample domain for measuring realistic metrics (diff) | |
download | VIATRA-Generator-991dacefdb8f78fccc359d3d2ec836dc2e7fc80a.tar.gz VIATRA-Generator-991dacefdb8f78fccc359d3d2ec836dc2e7fc80a.tar.zst VIATRA-Generator-991dacefdb8f78fccc359d3d2ec836dc2e7fc80a.zip |
measurements for the different violation types, comparison for differenct generation config
Diffstat (limited to 'Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/graph/GraphStatistic.xtend')
-rw-r--r-- | Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/graph/GraphStatistic.xtend | 42 |
1 files changed, 29 insertions, 13 deletions
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 | |||
5 | import java.util.HashMap | 5 | import java.util.HashMap |
6 | import java.util.HashSet | 6 | import java.util.HashSet |
7 | import java.util.List | 7 | import java.util.List |
8 | import java.util.Map | ||
9 | import java.util.Set | ||
8 | import org.eclipse.emf.ecore.EObject | 10 | import org.eclipse.emf.ecore.EObject |
9 | 11 | ||
10 | class GraphStatistic { | 12 | class GraphStatistic { |
11 | val incomingEdges = new HashMap<String, Multimap<EObject, EObject>>; | 13 | val incomingEdges = new HashMap<String, Multimap<EObject, EObject>>; |
12 | val outcomingEdges = new HashMap<String, Multimap<EObject, EObject>>; | 14 | val outcomingEdges = new HashMap<String, Multimap<EObject, EObject>>; |
13 | 15 | ||
14 | val edgeTypes = new HashSet<String>(); | 16 | val edgeTypes = new HashSet<String>(); |
15 | val nodes = new HashSet<EObject>(); | 17 | val nodeToType = new HashMap<EObject, Set<String>>(); |
16 | 18 | ||
17 | /** | 19 | /** |
18 | * Add an edge type to to the graph | 20 | * Add an edge type to to the graph |
19 | * @param type: type to add | 21 | * @param type: type to add |
20 | */ | 22 | */ |
21 | def void addType(String type){ | 23 | def void addEdgeType(String type){ |
22 | if(edgeTypes.contains(type)){ | 24 | if(edgeTypes.contains(type)){ |
23 | return; | 25 | return; |
24 | } | 26 | } |
@@ -28,15 +30,20 @@ class GraphStatistic { | |||
28 | } | 30 | } |
29 | 31 | ||
30 | /** | 32 | /** |
31 | * Add a node to he graph | 33 | * Add a node to the graph with one type in its type hierarchy |
32 | * @param node: node to add | 34 | * @param node: node to add |
33 | */ | 35 | */ |
34 | def void addNode(EObject n){ | 36 | def void addNodeWithType(EObject n, String Type){ |
35 | if(nodes.contains(n)){ | 37 | var types = nodeToType.getOrDefault(n, new HashSet<String>()); |
36 | return; | 38 | types.add(Type); |
37 | } | 39 | nodeToType.put(n, types); |
38 | 40 | } | |
39 | nodes.add(n); | 41 | |
42 | /** | ||
43 | * Add a node to the graph with all types in its type hierarchy | ||
44 | */ | ||
45 | def void addNodeWithAllTypes(EObject n, Set<String> types){ | ||
46 | nodeToType.put(n, types); | ||
40 | } | 47 | } |
41 | 48 | ||
42 | /** | 49 | /** |
@@ -82,7 +89,7 @@ class GraphStatistic { | |||
82 | } | 89 | } |
83 | 90 | ||
84 | /** | 91 | /** |
85 | * calculate the number of edge types for a given degree. | 92 | * calculate the number of edge types for a given node. |
86 | */ | 93 | */ |
87 | def int numOfEdgeTypes(EObject o){ | 94 | def int numOfEdgeTypes(EObject o){ |
88 | var count = 0; | 95 | var count = 0; |
@@ -100,8 +107,17 @@ class GraphStatistic { | |||
100 | return edgeTypes.toList(); | 107 | return edgeTypes.toList(); |
101 | } | 108 | } |
102 | 109 | ||
110 | def Map<EObject, Set<String>> getNodeToTypesMap(){ | ||
111 | return nodeToType; | ||
112 | } | ||
113 | |||
103 | def List<EObject> getAllNodes(){ | 114 | def List<EObject> getAllNodes(){ |
104 | return nodes.toList(); | 115 | return nodeToType.keySet().toList(); |
105 | } | 116 | } |
117 | |||
118 | def HashMap<String, Multimap<EObject, EObject>> getOutgoingEdges(){ | ||
119 | return outcomingEdges; | ||
120 | } | ||
121 | |||
106 | } | 122 | } |
107 | 123 | ||