diff options
Diffstat (limited to 'Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/xtend-gen/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/TypedOutDegree.java')
-rw-r--r-- | Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/xtend-gen/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/TypedOutDegree.java | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/xtend-gen/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/TypedOutDegree.java b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/xtend-gen/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/TypedOutDegree.java new file mode 100644 index 00000000..dce80389 --- /dev/null +++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/xtend-gen/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/TypedOutDegree.java | |||
@@ -0,0 +1,73 @@ | |||
1 | package ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics; | ||
2 | |||
3 | import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.graph.GraphStatistic; | ||
4 | import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.Metric; | ||
5 | import com.google.common.collect.Multimap; | ||
6 | import java.util.ArrayList; | ||
7 | import java.util.HashMap; | ||
8 | import java.util.List; | ||
9 | import java.util.Map; | ||
10 | import java.util.Set; | ||
11 | import org.eclipse.emf.ecore.EObject; | ||
12 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
13 | import org.eclipse.xtext.xbase.lib.Conversions; | ||
14 | |||
15 | @SuppressWarnings("all") | ||
16 | public class TypedOutDegree extends Metric { | ||
17 | private HashMap<String, List<Integer>> calculateMetric(final GraphStatistic g) { | ||
18 | HashMap<String, Multimap<EObject, EObject>> outgoingEdges = g.getOutgoingEdges(); | ||
19 | HashMap<String, List<Integer>> metric = new HashMap<String, List<Integer>>(); | ||
20 | Map<EObject, Set<String>> nodeToTypes = g.getNodeToTypesMap(); | ||
21 | Set<String> _keySet = outgoingEdges.keySet(); | ||
22 | for (final String edgeType : _keySet) { | ||
23 | Set<EObject> _keySet_1 = outgoingEdges.get(edgeType).keySet(); | ||
24 | for (final EObject node : _keySet_1) { | ||
25 | { | ||
26 | Set<String> classes = nodeToTypes.get(node); | ||
27 | for (final String cl : classes) { | ||
28 | { | ||
29 | String key = ((cl + " ") + edgeType); | ||
30 | List<Integer> typeCount = metric.get(key); | ||
31 | if ((typeCount == null)) { | ||
32 | ArrayList<Integer> _arrayList = new ArrayList<Integer>(); | ||
33 | typeCount = _arrayList; | ||
34 | metric.put(key, typeCount); | ||
35 | } | ||
36 | typeCount.add(Integer.valueOf(outgoingEdges.get(edgeType).get(node).size())); | ||
37 | } | ||
38 | } | ||
39 | } | ||
40 | } | ||
41 | } | ||
42 | return metric; | ||
43 | } | ||
44 | |||
45 | @Override | ||
46 | public String[][] evaluate(final GraphStatistic g) { | ||
47 | HashMap<String, List<Integer>> metric = this.calculateMetric(g); | ||
48 | ArrayList<String[]> output = new ArrayList<String[]>(); | ||
49 | output.add(((String[])Conversions.unwrapArray(CollectionLiterals.<String>newArrayList("Typed Out Degree"), String.class))); | ||
50 | Set<String> _keySet = metric.keySet(); | ||
51 | for (final String key : _keySet) { | ||
52 | { | ||
53 | List<Integer> samples = metric.get(key); | ||
54 | int _size = samples.size(); | ||
55 | int _plus = (_size + 1); | ||
56 | String[] outputForOnePair = new String[_plus]; | ||
57 | outputForOnePair[0] = key; | ||
58 | for (int i = 0; (i < samples.size()); i++) { | ||
59 | Integer _get = samples.get(i); | ||
60 | String _plus_1 = (_get + ""); | ||
61 | outputForOnePair[(i + 1)] = _plus_1; | ||
62 | } | ||
63 | output.add(outputForOnePair); | ||
64 | } | ||
65 | } | ||
66 | return ((String[][])Conversions.unwrapArray(output, String[].class)); | ||
67 | } | ||
68 | |||
69 | @Override | ||
70 | public Object evaluateSamples(final GraphStatistic g) { | ||
71 | return this.calculateMetric(g); | ||
72 | } | ||
73 | } | ||