diff options
author | 20000LastOrder <boqi.chen@mail.mcgill.ca> | 2021-08-17 09:58:48 -0400 |
---|---|---|
committer | 20000LastOrder <boqi.chen@mail.mcgill.ca> | 2021-08-17 09:58:48 -0400 |
commit | c7a271cd1e17d94638025d3b663354e659796c08 (patch) | |
tree | c789912419d2bb3556a4cfdcf5620d56ec0fbc00 | |
download | VIATRA-Generator-statecoding_new.tar.gz VIATRA-Generator-statecoding_new.tar.zst VIATRA-Generator-statecoding_new.zip |
initial commit for new state codingstatecoding_new
53 files changed, 2249 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..6143e53f --- /dev/null +++ b/.gitignore | |||
@@ -0,0 +1,22 @@ | |||
1 | # Compiled class file | ||
2 | *.class | ||
3 | |||
4 | # Log file | ||
5 | *.log | ||
6 | |||
7 | # BlueJ files | ||
8 | *.ctxt | ||
9 | |||
10 | # Mobile Tools for Java (J2ME) | ||
11 | .mtj.tmp/ | ||
12 | |||
13 | # Package Files # | ||
14 | *.jar | ||
15 | *.war | ||
16 | *.ear | ||
17 | *.zip | ||
18 | *.tar.gz | ||
19 | *.rar | ||
20 | |||
21 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
22 | hs_err_pid* | ||
diff --git a/org.eclipse.viatra.coding/.gradle/6.1/executionHistory/executionHistory.bin b/org.eclipse.viatra.coding/.gradle/6.1/executionHistory/executionHistory.bin new file mode 100644 index 00000000..0cb8fa97 --- /dev/null +++ b/org.eclipse.viatra.coding/.gradle/6.1/executionHistory/executionHistory.bin | |||
Binary files differ | |||
diff --git a/org.eclipse.viatra.coding/.gradle/6.1/executionHistory/executionHistory.lock b/org.eclipse.viatra.coding/.gradle/6.1/executionHistory/executionHistory.lock new file mode 100644 index 00000000..2534b722 --- /dev/null +++ b/org.eclipse.viatra.coding/.gradle/6.1/executionHistory/executionHistory.lock | |||
Binary files differ | |||
diff --git a/org.eclipse.viatra.coding/.gradle/6.1/fileChanges/last-build.bin b/org.eclipse.viatra.coding/.gradle/6.1/fileChanges/last-build.bin new file mode 100644 index 00000000..f76dd238 --- /dev/null +++ b/org.eclipse.viatra.coding/.gradle/6.1/fileChanges/last-build.bin | |||
Binary files differ | |||
diff --git a/org.eclipse.viatra.coding/.gradle/6.1/fileContent/fileContent.lock b/org.eclipse.viatra.coding/.gradle/6.1/fileContent/fileContent.lock new file mode 100644 index 00000000..f6e8d1fa --- /dev/null +++ b/org.eclipse.viatra.coding/.gradle/6.1/fileContent/fileContent.lock | |||
Binary files differ | |||
diff --git a/org.eclipse.viatra.coding/.gradle/6.1/fileHashes/fileHashes.bin b/org.eclipse.viatra.coding/.gradle/6.1/fileHashes/fileHashes.bin new file mode 100644 index 00000000..32df5d70 --- /dev/null +++ b/org.eclipse.viatra.coding/.gradle/6.1/fileHashes/fileHashes.bin | |||
Binary files differ | |||
diff --git a/org.eclipse.viatra.coding/.gradle/6.1/fileHashes/fileHashes.lock b/org.eclipse.viatra.coding/.gradle/6.1/fileHashes/fileHashes.lock new file mode 100644 index 00000000..fe6228da --- /dev/null +++ b/org.eclipse.viatra.coding/.gradle/6.1/fileHashes/fileHashes.lock | |||
Binary files differ | |||
diff --git a/org.eclipse.viatra.coding/.gradle/6.1/fileHashes/resourceHashesCache.bin b/org.eclipse.viatra.coding/.gradle/6.1/fileHashes/resourceHashesCache.bin new file mode 100644 index 00000000..3829120c --- /dev/null +++ b/org.eclipse.viatra.coding/.gradle/6.1/fileHashes/resourceHashesCache.bin | |||
Binary files differ | |||
diff --git a/org.eclipse.viatra.coding/.gradle/6.1/gc.properties b/org.eclipse.viatra.coding/.gradle/6.1/gc.properties new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/org.eclipse.viatra.coding/.gradle/6.1/gc.properties | |||
diff --git a/org.eclipse.viatra.coding/.gradle/6.1/javaCompile/classAnalysis.bin b/org.eclipse.viatra.coding/.gradle/6.1/javaCompile/classAnalysis.bin new file mode 100644 index 00000000..238579c8 --- /dev/null +++ b/org.eclipse.viatra.coding/.gradle/6.1/javaCompile/classAnalysis.bin | |||
Binary files differ | |||
diff --git a/org.eclipse.viatra.coding/.gradle/6.1/javaCompile/jarAnalysis.bin b/org.eclipse.viatra.coding/.gradle/6.1/javaCompile/jarAnalysis.bin new file mode 100644 index 00000000..6ccbc8a1 --- /dev/null +++ b/org.eclipse.viatra.coding/.gradle/6.1/javaCompile/jarAnalysis.bin | |||
Binary files differ | |||
diff --git a/org.eclipse.viatra.coding/.gradle/6.1/javaCompile/javaCompile.lock b/org.eclipse.viatra.coding/.gradle/6.1/javaCompile/javaCompile.lock new file mode 100644 index 00000000..c8fbada9 --- /dev/null +++ b/org.eclipse.viatra.coding/.gradle/6.1/javaCompile/javaCompile.lock | |||
Binary files differ | |||
diff --git a/org.eclipse.viatra.coding/.gradle/6.1/javaCompile/taskHistory.bin b/org.eclipse.viatra.coding/.gradle/6.1/javaCompile/taskHistory.bin new file mode 100644 index 00000000..e23660de --- /dev/null +++ b/org.eclipse.viatra.coding/.gradle/6.1/javaCompile/taskHistory.bin | |||
Binary files differ | |||
diff --git a/org.eclipse.viatra.coding/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/org.eclipse.viatra.coding/.gradle/buildOutputCleanup/buildOutputCleanup.lock new file mode 100644 index 00000000..c30ad625 --- /dev/null +++ b/org.eclipse.viatra.coding/.gradle/buildOutputCleanup/buildOutputCleanup.lock | |||
Binary files differ | |||
diff --git a/org.eclipse.viatra.coding/.gradle/buildOutputCleanup/cache.properties b/org.eclipse.viatra.coding/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 00000000..4d4b56be --- /dev/null +++ b/org.eclipse.viatra.coding/.gradle/buildOutputCleanup/cache.properties | |||
@@ -0,0 +1,2 @@ | |||
1 | #Wed Sep 30 09:32:44 EDT 2020 | ||
2 | gradle.version=6.1 | ||
diff --git a/org.eclipse.viatra.coding/.gradle/buildOutputCleanup/outputFiles.bin b/org.eclipse.viatra.coding/.gradle/buildOutputCleanup/outputFiles.bin new file mode 100644 index 00000000..ba8d4ba7 --- /dev/null +++ b/org.eclipse.viatra.coding/.gradle/buildOutputCleanup/outputFiles.bin | |||
Binary files differ | |||
diff --git a/org.eclipse.viatra.coding/.gradle/checksums/checksums.lock b/org.eclipse.viatra.coding/.gradle/checksums/checksums.lock new file mode 100644 index 00000000..f3359dc5 --- /dev/null +++ b/org.eclipse.viatra.coding/.gradle/checksums/checksums.lock | |||
Binary files differ | |||
diff --git a/org.eclipse.viatra.coding/.gradle/checksums/md5-checksums.bin b/org.eclipse.viatra.coding/.gradle/checksums/md5-checksums.bin new file mode 100644 index 00000000..c4f12e2e --- /dev/null +++ b/org.eclipse.viatra.coding/.gradle/checksums/md5-checksums.bin | |||
Binary files differ | |||
diff --git a/org.eclipse.viatra.coding/.gradle/checksums/sha1-checksums.bin b/org.eclipse.viatra.coding/.gradle/checksums/sha1-checksums.bin new file mode 100644 index 00000000..f7d3c9ca --- /dev/null +++ b/org.eclipse.viatra.coding/.gradle/checksums/sha1-checksums.bin | |||
Binary files differ | |||
diff --git a/org.eclipse.viatra.coding/.gradle/checksums/sha256-checksums.bin b/org.eclipse.viatra.coding/.gradle/checksums/sha256-checksums.bin new file mode 100644 index 00000000..41d0c0af --- /dev/null +++ b/org.eclipse.viatra.coding/.gradle/checksums/sha256-checksums.bin | |||
Binary files differ | |||
diff --git a/org.eclipse.viatra.coding/.gradle/checksums/sha512-checksums.bin b/org.eclipse.viatra.coding/.gradle/checksums/sha512-checksums.bin new file mode 100644 index 00000000..a0d6e518 --- /dev/null +++ b/org.eclipse.viatra.coding/.gradle/checksums/sha512-checksums.bin | |||
Binary files differ | |||
diff --git a/org.eclipse.viatra.coding/.gradle/vcs-1/gc.properties b/org.eclipse.viatra.coding/.gradle/vcs-1/gc.properties new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/org.eclipse.viatra.coding/.gradle/vcs-1/gc.properties | |||
diff --git a/org.eclipse.viatra.coding/build.gradle b/org.eclipse.viatra.coding/build.gradle new file mode 100644 index 00000000..0fb0c555 --- /dev/null +++ b/org.eclipse.viatra.coding/build.gradle | |||
@@ -0,0 +1,34 @@ | |||
1 | plugins { | ||
2 | id "java" | ||
3 | id 'maven-publish' | ||
4 | } | ||
5 | |||
6 | |||
7 | group 'org.eclipse.viatra' | ||
8 | version '0.0.1' | ||
9 | sourceCompatibility = '1.8' | ||
10 | targetCompatibility = '1.8' | ||
11 | |||
12 | repositories { | ||
13 | mavenCentral() | ||
14 | } | ||
15 | |||
16 | test { | ||
17 | minHeapSize = "2048m" | ||
18 | maxHeapSize = "4096m" | ||
19 | } | ||
20 | |||
21 | publishing { | ||
22 | publications { | ||
23 | mavenJava(MavenPublication) { | ||
24 | groupId = 'org.eclipse.viatra' | ||
25 | artifactId = 'org.eclipse.viatra.coding' | ||
26 | version = '0.0.1' | ||
27 | from components.java | ||
28 | } | ||
29 | } | ||
30 | } | ||
31 | |||
32 | dependencies { | ||
33 | testCompile group: 'junit', name: 'junit', version: '4.12' | ||
34 | } | ||
diff --git a/org.eclipse.viatra.coding/build/publications/mavenJava/module.json b/org.eclipse.viatra.coding/build/publications/mavenJava/module.json new file mode 100644 index 00000000..28186456 --- /dev/null +++ b/org.eclipse.viatra.coding/build/publications/mavenJava/module.json | |||
@@ -0,0 +1,61 @@ | |||
1 | { | ||
2 | "formatVersion": "1.1", | ||
3 | "component": { | ||
4 | "group": "org.eclipse.viatra", | ||
5 | "module": "org.eclipse.viatra.coding", | ||
6 | "version": "0.0.1", | ||
7 | "attributes": { | ||
8 | "org.gradle.status": "release" | ||
9 | } | ||
10 | }, | ||
11 | "createdBy": { | ||
12 | "gradle": { | ||
13 | "version": "6.1", | ||
14 | "buildId": "glqdqz76vna6nc2pgh6jxpbene" | ||
15 | } | ||
16 | }, | ||
17 | "variants": [ | ||
18 | { | ||
19 | "name": "apiElements", | ||
20 | "attributes": { | ||
21 | "org.gradle.category": "library", | ||
22 | "org.gradle.dependency.bundling": "external", | ||
23 | "org.gradle.jvm.version": 8, | ||
24 | "org.gradle.libraryelements": "jar", | ||
25 | "org.gradle.usage": "java-api" | ||
26 | }, | ||
27 | "files": [ | ||
28 | { | ||
29 | "name": "org.eclipse.viatra.coding-0.0.1.jar", | ||
30 | "url": "org.eclipse.viatra.coding-0.0.1.jar", | ||
31 | "size": 15736, | ||
32 | "sha512": "0d0481a2a0ad7d13209bb08dab93fcb622263e5aa72a9cfbce692cb40ba1fa52da28dd769581602518ef043dd2478f22ac54e94be49547d7952e96cda76cad1d", | ||
33 | "sha256": "d1dab31948bef224a75674a7ed4ced0080a8a59e9c41935ddbcd4556ee97f849", | ||
34 | "sha1": "6f9192cf8105539931e5d03579aef3226029a80c", | ||
35 | "md5": "784d4b5a60b73a91811a3a56b0b5c6d7" | ||
36 | } | ||
37 | ] | ||
38 | }, | ||
39 | { | ||
40 | "name": "runtimeElements", | ||
41 | "attributes": { | ||
42 | "org.gradle.category": "library", | ||
43 | "org.gradle.dependency.bundling": "external", | ||
44 | "org.gradle.jvm.version": 8, | ||
45 | "org.gradle.libraryelements": "jar", | ||
46 | "org.gradle.usage": "java-runtime" | ||
47 | }, | ||
48 | "files": [ | ||
49 | { | ||
50 | "name": "org.eclipse.viatra.coding-0.0.1.jar", | ||
51 | "url": "org.eclipse.viatra.coding-0.0.1.jar", | ||
52 | "size": 15736, | ||
53 | "sha512": "0d0481a2a0ad7d13209bb08dab93fcb622263e5aa72a9cfbce692cb40ba1fa52da28dd769581602518ef043dd2478f22ac54e94be49547d7952e96cda76cad1d", | ||
54 | "sha256": "d1dab31948bef224a75674a7ed4ced0080a8a59e9c41935ddbcd4556ee97f849", | ||
55 | "sha1": "6f9192cf8105539931e5d03579aef3226029a80c", | ||
56 | "md5": "784d4b5a60b73a91811a3a56b0b5c6d7" | ||
57 | } | ||
58 | ] | ||
59 | } | ||
60 | ] | ||
61 | } | ||
diff --git a/org.eclipse.viatra.coding/build/publications/mavenJava/pom-default.xml b/org.eclipse.viatra.coding/build/publications/mavenJava/pom-default.xml new file mode 100644 index 00000000..780c0d84 --- /dev/null +++ b/org.eclipse.viatra.coding/build/publications/mavenJava/pom-default.xml | |||
@@ -0,0 +1,13 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
3 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
4 | <!-- This module was also published with a richer model, Gradle metadata, --> | ||
5 | <!-- which should be used instead. Do not delete the following line which --> | ||
6 | <!-- is to indicate to Gradle or any Gradle module metadata file consumer --> | ||
7 | <!-- that they should prefer consuming it instead. --> | ||
8 | <!-- do_not_remove: published-with-gradle-metadata --> | ||
9 | <modelVersion>4.0.0</modelVersion> | ||
10 | <groupId>org.eclipse.viatra</groupId> | ||
11 | <artifactId>org.eclipse.viatra.coding</artifactId> | ||
12 | <version>0.0.1</version> | ||
13 | </project> | ||
diff --git a/org.eclipse.viatra.coding/build/reports/tests/test/classes/org.eclipse.viatra.coding.GraphPermutationTest.html b/org.eclipse.viatra.coding/build/reports/tests/test/classes/org.eclipse.viatra.coding.GraphPermutationTest.html new file mode 100644 index 00000000..f118ca08 --- /dev/null +++ b/org.eclipse.viatra.coding/build/reports/tests/test/classes/org.eclipse.viatra.coding.GraphPermutationTest.html | |||
@@ -0,0 +1,96 @@ | |||
1 | <!DOCTYPE html> | ||
2 | <html> | ||
3 | <head> | ||
4 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | ||
5 | <meta http-equiv="x-ua-compatible" content="IE=edge"/> | ||
6 | <title>Test results - Class org.eclipse.viatra.coding.GraphPermutationTest</title> | ||
7 | <link href="../css/base-style.css" rel="stylesheet" type="text/css"/> | ||
8 | <link href="../css/style.css" rel="stylesheet" type="text/css"/> | ||
9 | <script src="../js/report.js" type="text/javascript"></script> | ||
10 | </head> | ||
11 | <body> | ||
12 | <div id="content"> | ||
13 | <h1>Class org.eclipse.viatra.coding.GraphPermutationTest</h1> | ||
14 | <div class="breadcrumbs"> | ||
15 | <a href="../index.html">all</a> > | ||
16 | <a href="../packages/org.eclipse.viatra.coding.html">org.eclipse.viatra.coding</a> > GraphPermutationTest</div> | ||
17 | <div id="summary"> | ||
18 | <table> | ||
19 | <tr> | ||
20 | <td> | ||
21 | <div class="summaryGroup"> | ||
22 | <table> | ||
23 | <tr> | ||
24 | <td> | ||
25 | <div class="infoBox" id="tests"> | ||
26 | <div class="counter">1</div> | ||
27 | <p>tests</p> | ||
28 | </div> | ||
29 | </td> | ||
30 | <td> | ||
31 | <div class="infoBox" id="failures"> | ||
32 | <div class="counter">0</div> | ||
33 | <p>failures</p> | ||
34 | </div> | ||
35 | </td> | ||
36 | <td> | ||
37 | <div class="infoBox" id="ignored"> | ||
38 | <div class="counter">0</div> | ||
39 | <p>ignored</p> | ||
40 | </div> | ||
41 | </td> | ||
42 | <td> | ||
43 | <div class="infoBox" id="duration"> | ||
44 | <div class="counter">0.098s</div> | ||
45 | <p>duration</p> | ||
46 | </div> | ||
47 | </td> | ||
48 | </tr> | ||
49 | </table> | ||
50 | </div> | ||
51 | </td> | ||
52 | <td> | ||
53 | <div class="infoBox success" id="successRate"> | ||
54 | <div class="percent">100%</div> | ||
55 | <p>successful</p> | ||
56 | </div> | ||
57 | </td> | ||
58 | </tr> | ||
59 | </table> | ||
60 | </div> | ||
61 | <div id="tabs"> | ||
62 | <ul class="tabLinks"> | ||
63 | <li> | ||
64 | <a href="#tab0">Tests</a> | ||
65 | </li> | ||
66 | </ul> | ||
67 | <div id="tab0" class="tab"> | ||
68 | <h2>Tests</h2> | ||
69 | <table> | ||
70 | <thead> | ||
71 | <tr> | ||
72 | <th>Test</th> | ||
73 | <th>Duration</th> | ||
74 | <th>Result</th> | ||
75 | </tr> | ||
76 | </thead> | ||
77 | <tr> | ||
78 | <td class="success">testUniqueStateCodes</td> | ||
79 | <td class="success">0.098s</td> | ||
80 | <td class="success">passed</td> | ||
81 | </tr> | ||
82 | </table> | ||
83 | </div> | ||
84 | </div> | ||
85 | <div id="footer"> | ||
86 | <p> | ||
87 | <div> | ||
88 | <label class="hidden" id="label-for-line-wrapping-toggle" for="line-wrapping-toggle">Wrap lines | ||
89 | <input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/> | ||
90 | </label> | ||
91 | </div>Generated by | ||
92 | <a href="http://www.gradle.org">Gradle 6.1</a> at Oct 26, 2020, 12:09:38 AM</p> | ||
93 | </div> | ||
94 | </div> | ||
95 | </body> | ||
96 | </html> | ||
diff --git a/org.eclipse.viatra.coding/build/reports/tests/test/css/base-style.css b/org.eclipse.viatra.coding/build/reports/tests/test/css/base-style.css new file mode 100644 index 00000000..4afa73e3 --- /dev/null +++ b/org.eclipse.viatra.coding/build/reports/tests/test/css/base-style.css | |||
@@ -0,0 +1,179 @@ | |||
1 | |||
2 | body { | ||
3 | margin: 0; | ||
4 | padding: 0; | ||
5 | font-family: sans-serif; | ||
6 | font-size: 12pt; | ||
7 | } | ||
8 | |||
9 | body, a, a:visited { | ||
10 | color: #303030; | ||
11 | } | ||
12 | |||
13 | #content { | ||
14 | padding-left: 50px; | ||
15 | padding-right: 50px; | ||
16 | padding-top: 30px; | ||
17 | padding-bottom: 30px; | ||
18 | } | ||
19 | |||
20 | #content h1 { | ||
21 | font-size: 160%; | ||
22 | margin-bottom: 10px; | ||
23 | } | ||
24 | |||
25 | #footer { | ||
26 | margin-top: 100px; | ||
27 | font-size: 80%; | ||
28 | white-space: nowrap; | ||
29 | } | ||
30 | |||
31 | #footer, #footer a { | ||
32 | color: #a0a0a0; | ||
33 | } | ||
34 | |||
35 | #line-wrapping-toggle { | ||
36 | vertical-align: middle; | ||
37 | } | ||
38 | |||
39 | #label-for-line-wrapping-toggle { | ||
40 | vertical-align: middle; | ||
41 | } | ||
42 | |||
43 | ul { | ||
44 | margin-left: 0; | ||
45 | } | ||
46 | |||
47 | h1, h2, h3 { | ||
48 | white-space: nowrap; | ||
49 | } | ||
50 | |||
51 | h2 { | ||
52 | font-size: 120%; | ||
53 | } | ||
54 | |||
55 | ul.tabLinks { | ||
56 | padding-left: 0; | ||
57 | padding-top: 10px; | ||
58 | padding-bottom: 10px; | ||
59 | overflow: auto; | ||
60 | min-width: 800px; | ||
61 | width: auto !important; | ||
62 | width: 800px; | ||
63 | } | ||
64 | |||
65 | ul.tabLinks li { | ||
66 | float: left; | ||
67 | height: 100%; | ||
68 | list-style: none; | ||
69 | padding-left: 10px; | ||
70 | padding-right: 10px; | ||
71 | padding-top: 5px; | ||
72 | padding-bottom: 5px; | ||
73 | margin-bottom: 0; | ||
74 | -moz-border-radius: 7px; | ||
75 | border-radius: 7px; | ||
76 | margin-right: 25px; | ||
77 | border: solid 1px #d4d4d4; | ||
78 | background-color: #f0f0f0; | ||
79 | } | ||
80 | |||
81 | ul.tabLinks li:hover { | ||
82 | background-color: #fafafa; | ||
83 | } | ||
84 | |||
85 | ul.tabLinks li.selected { | ||
86 | background-color: #c5f0f5; | ||
87 | border-color: #c5f0f5; | ||
88 | } | ||
89 | |||
90 | ul.tabLinks a { | ||
91 | font-size: 120%; | ||
92 | display: block; | ||
93 | outline: none; | ||
94 | text-decoration: none; | ||
95 | margin: 0; | ||
96 | padding: 0; | ||
97 | } | ||
98 | |||
99 | ul.tabLinks li h2 { | ||
100 | margin: 0; | ||
101 | padding: 0; | ||
102 | } | ||
103 | |||
104 | div.tab { | ||
105 | } | ||
106 | |||
107 | div.selected { | ||
108 | display: block; | ||
109 | } | ||
110 | |||
111 | div.deselected { | ||
112 | display: none; | ||
113 | } | ||
114 | |||
115 | div.tab table { | ||
116 | min-width: 350px; | ||
117 | width: auto !important; | ||
118 | width: 350px; | ||
119 | border-collapse: collapse; | ||
120 | } | ||
121 | |||
122 | div.tab th, div.tab table { | ||
123 | border-bottom: solid #d0d0d0 1px; | ||
124 | } | ||
125 | |||
126 | div.tab th { | ||
127 | text-align: left; | ||
128 | white-space: nowrap; | ||
129 | padding-left: 6em; | ||
130 | } | ||
131 | |||
132 | div.tab th:first-child { | ||
133 | padding-left: 0; | ||
134 | } | ||
135 | |||
136 | div.tab td { | ||
137 | white-space: nowrap; | ||
138 | padding-left: 6em; | ||
139 | padding-top: 5px; | ||
140 | padding-bottom: 5px; | ||
141 | } | ||
142 | |||
143 | div.tab td:first-child { | ||
144 | padding-left: 0; | ||
145 | } | ||
146 | |||
147 | div.tab td.numeric, div.tab th.numeric { | ||
148 | text-align: right; | ||
149 | } | ||
150 | |||
151 | span.code { | ||
152 | display: inline-block; | ||
153 | margin-top: 0em; | ||
154 | margin-bottom: 1em; | ||
155 | } | ||
156 | |||
157 | span.code pre { | ||
158 | font-size: 11pt; | ||
159 | padding-top: 10px; | ||
160 | padding-bottom: 10px; | ||
161 | padding-left: 10px; | ||
162 | padding-right: 10px; | ||
163 | margin: 0; | ||
164 | background-color: #f7f7f7; | ||
165 | border: solid 1px #d0d0d0; | ||
166 | min-width: 700px; | ||
167 | width: auto !important; | ||
168 | width: 700px; | ||
169 | } | ||
170 | |||
171 | span.wrapped pre { | ||
172 | word-wrap: break-word; | ||
173 | white-space: pre-wrap; | ||
174 | word-break: break-all; | ||
175 | } | ||
176 | |||
177 | label.hidden { | ||
178 | display: none; | ||
179 | } \ No newline at end of file | ||
diff --git a/org.eclipse.viatra.coding/build/reports/tests/test/css/style.css b/org.eclipse.viatra.coding/build/reports/tests/test/css/style.css new file mode 100644 index 00000000..3dc4913e --- /dev/null +++ b/org.eclipse.viatra.coding/build/reports/tests/test/css/style.css | |||
@@ -0,0 +1,84 @@ | |||
1 | |||
2 | #summary { | ||
3 | margin-top: 30px; | ||
4 | margin-bottom: 40px; | ||
5 | } | ||
6 | |||
7 | #summary table { | ||
8 | border-collapse: collapse; | ||
9 | } | ||
10 | |||
11 | #summary td { | ||
12 | vertical-align: top; | ||
13 | } | ||
14 | |||
15 | .breadcrumbs, .breadcrumbs a { | ||
16 | color: #606060; | ||
17 | } | ||
18 | |||
19 | .infoBox { | ||
20 | width: 110px; | ||
21 | padding-top: 15px; | ||
22 | padding-bottom: 15px; | ||
23 | text-align: center; | ||
24 | } | ||
25 | |||
26 | .infoBox p { | ||
27 | margin: 0; | ||
28 | } | ||
29 | |||
30 | .counter, .percent { | ||
31 | font-size: 120%; | ||
32 | font-weight: bold; | ||
33 | margin-bottom: 8px; | ||
34 | } | ||
35 | |||
36 | #duration { | ||
37 | width: 125px; | ||
38 | } | ||
39 | |||
40 | #successRate, .summaryGroup { | ||
41 | border: solid 2px #d0d0d0; | ||
42 | -moz-border-radius: 10px; | ||
43 | border-radius: 10px; | ||
44 | } | ||
45 | |||
46 | #successRate { | ||
47 | width: 140px; | ||
48 | margin-left: 35px; | ||
49 | } | ||
50 | |||
51 | #successRate .percent { | ||
52 | font-size: 180%; | ||
53 | } | ||
54 | |||
55 | .success, .success a { | ||
56 | color: #008000; | ||
57 | } | ||
58 | |||
59 | div.success, #successRate.success { | ||
60 | background-color: #bbd9bb; | ||
61 | border-color: #008000; | ||
62 | } | ||
63 | |||
64 | .failures, .failures a { | ||
65 | color: #b60808; | ||
66 | } | ||
67 | |||
68 | .skipped, .skipped a { | ||
69 | color: #c09853; | ||
70 | } | ||
71 | |||
72 | div.failures, #successRate.failures { | ||
73 | background-color: #ecdada; | ||
74 | border-color: #b60808; | ||
75 | } | ||
76 | |||
77 | ul.linkList { | ||
78 | padding-left: 0; | ||
79 | } | ||
80 | |||
81 | ul.linkList li { | ||
82 | list-style: none; | ||
83 | margin-bottom: 5px; | ||
84 | } | ||
diff --git a/org.eclipse.viatra.coding/build/reports/tests/test/index.html b/org.eclipse.viatra.coding/build/reports/tests/test/index.html new file mode 100644 index 00000000..c628c6fd --- /dev/null +++ b/org.eclipse.viatra.coding/build/reports/tests/test/index.html | |||
@@ -0,0 +1,133 @@ | |||
1 | <!DOCTYPE html> | ||
2 | <html> | ||
3 | <head> | ||
4 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | ||
5 | <meta http-equiv="x-ua-compatible" content="IE=edge"/> | ||
6 | <title>Test results - Test Summary</title> | ||
7 | <link href="css/base-style.css" rel="stylesheet" type="text/css"/> | ||
8 | <link href="css/style.css" rel="stylesheet" type="text/css"/> | ||
9 | <script src="js/report.js" type="text/javascript"></script> | ||
10 | </head> | ||
11 | <body> | ||
12 | <div id="content"> | ||
13 | <h1>Test Summary</h1> | ||
14 | <div id="summary"> | ||
15 | <table> | ||
16 | <tr> | ||
17 | <td> | ||
18 | <div class="summaryGroup"> | ||
19 | <table> | ||
20 | <tr> | ||
21 | <td> | ||
22 | <div class="infoBox" id="tests"> | ||
23 | <div class="counter">1</div> | ||
24 | <p>tests</p> | ||
25 | </div> | ||
26 | </td> | ||
27 | <td> | ||
28 | <div class="infoBox" id="failures"> | ||
29 | <div class="counter">0</div> | ||
30 | <p>failures</p> | ||
31 | </div> | ||
32 | </td> | ||
33 | <td> | ||
34 | <div class="infoBox" id="ignored"> | ||
35 | <div class="counter">0</div> | ||
36 | <p>ignored</p> | ||
37 | </div> | ||
38 | </td> | ||
39 | <td> | ||
40 | <div class="infoBox" id="duration"> | ||
41 | <div class="counter">0.098s</div> | ||
42 | <p>duration</p> | ||
43 | </div> | ||
44 | </td> | ||
45 | </tr> | ||
46 | </table> | ||
47 | </div> | ||
48 | </td> | ||
49 | <td> | ||
50 | <div class="infoBox success" id="successRate"> | ||
51 | <div class="percent">100%</div> | ||
52 | <p>successful</p> | ||
53 | </div> | ||
54 | </td> | ||
55 | </tr> | ||
56 | </table> | ||
57 | </div> | ||
58 | <div id="tabs"> | ||
59 | <ul class="tabLinks"> | ||
60 | <li> | ||
61 | <a href="#tab0">Packages</a> | ||
62 | </li> | ||
63 | <li> | ||
64 | <a href="#tab1">Classes</a> | ||
65 | </li> | ||
66 | </ul> | ||
67 | <div id="tab0" class="tab"> | ||
68 | <h2>Packages</h2> | ||
69 | <table> | ||
70 | <thead> | ||
71 | <tr> | ||
72 | <th>Package</th> | ||
73 | <th>Tests</th> | ||
74 | <th>Failures</th> | ||
75 | <th>Ignored</th> | ||
76 | <th>Duration</th> | ||
77 | <th>Success rate</th> | ||
78 | </tr> | ||
79 | </thead> | ||
80 | <tbody> | ||
81 | <tr> | ||
82 | <td class="success"> | ||
83 | <a href="packages/org.eclipse.viatra.coding.html">org.eclipse.viatra.coding</a> | ||
84 | </td> | ||
85 | <td>1</td> | ||
86 | <td>0</td> | ||
87 | <td>0</td> | ||
88 | <td>0.098s</td> | ||
89 | <td class="success">100%</td> | ||
90 | </tr> | ||
91 | </tbody> | ||
92 | </table> | ||
93 | </div> | ||
94 | <div id="tab1" class="tab"> | ||
95 | <h2>Classes</h2> | ||
96 | <table> | ||
97 | <thead> | ||
98 | <tr> | ||
99 | <th>Class</th> | ||
100 | <th>Tests</th> | ||
101 | <th>Failures</th> | ||
102 | <th>Ignored</th> | ||
103 | <th>Duration</th> | ||
104 | <th>Success rate</th> | ||
105 | </tr> | ||
106 | </thead> | ||
107 | <tbody> | ||
108 | <tr> | ||
109 | <td class="success"> | ||
110 | <a href="classes/org.eclipse.viatra.coding.GraphPermutationTest.html">org.eclipse.viatra.coding.GraphPermutationTest</a> | ||
111 | </td> | ||
112 | <td>1</td> | ||
113 | <td>0</td> | ||
114 | <td>0</td> | ||
115 | <td>0.098s</td> | ||
116 | <td class="success">100%</td> | ||
117 | </tr> | ||
118 | </tbody> | ||
119 | </table> | ||
120 | </div> | ||
121 | </div> | ||
122 | <div id="footer"> | ||
123 | <p> | ||
124 | <div> | ||
125 | <label class="hidden" id="label-for-line-wrapping-toggle" for="line-wrapping-toggle">Wrap lines | ||
126 | <input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/> | ||
127 | </label> | ||
128 | </div>Generated by | ||
129 | <a href="http://www.gradle.org">Gradle 6.1</a> at Oct 26, 2020, 12:09:38 AM</p> | ||
130 | </div> | ||
131 | </div> | ||
132 | </body> | ||
133 | </html> | ||
diff --git a/org.eclipse.viatra.coding/build/reports/tests/test/js/report.js b/org.eclipse.viatra.coding/build/reports/tests/test/js/report.js new file mode 100644 index 00000000..83bab4a1 --- /dev/null +++ b/org.eclipse.viatra.coding/build/reports/tests/test/js/report.js | |||
@@ -0,0 +1,194 @@ | |||
1 | (function (window, document) { | ||
2 | "use strict"; | ||
3 | |||
4 | var tabs = {}; | ||
5 | |||
6 | function changeElementClass(element, classValue) { | ||
7 | if (element.getAttribute("className")) { | ||
8 | element.setAttribute("className", classValue); | ||
9 | } else { | ||
10 | element.setAttribute("class", classValue); | ||
11 | } | ||
12 | } | ||
13 | |||
14 | function getClassAttribute(element) { | ||
15 | if (element.getAttribute("className")) { | ||
16 | return element.getAttribute("className"); | ||
17 | } else { | ||
18 | return element.getAttribute("class"); | ||
19 | } | ||
20 | } | ||
21 | |||
22 | function addClass(element, classValue) { | ||
23 | changeElementClass(element, getClassAttribute(element) + " " + classValue); | ||
24 | } | ||
25 | |||
26 | function removeClass(element, classValue) { | ||
27 | changeElementClass(element, getClassAttribute(element).replace(classValue, "")); | ||
28 | } | ||
29 | |||
30 | function initTabs() { | ||
31 | var container = document.getElementById("tabs"); | ||
32 | |||
33 | tabs.tabs = findTabs(container); | ||
34 | tabs.titles = findTitles(tabs.tabs); | ||
35 | tabs.headers = findHeaders(container); | ||
36 | tabs.select = select; | ||
37 | tabs.deselectAll = deselectAll; | ||
38 | tabs.select(0); | ||
39 | |||
40 | return true; | ||
41 | } | ||
42 | |||
43 | function getCheckBox() { | ||
44 | return document.getElementById("line-wrapping-toggle"); | ||
45 | } | ||
46 | |||
47 | function getLabelForCheckBox() { | ||
48 | return document.getElementById("label-for-line-wrapping-toggle"); | ||
49 | } | ||
50 | |||
51 | function findCodeBlocks() { | ||
52 | var spans = document.getElementById("tabs").getElementsByTagName("span"); | ||
53 | var codeBlocks = []; | ||
54 | for (var i = 0; i < spans.length; ++i) { | ||
55 | if (spans[i].className.indexOf("code") >= 0) { | ||
56 | codeBlocks.push(spans[i]); | ||
57 | } | ||
58 | } | ||
59 | return codeBlocks; | ||
60 | } | ||
61 | |||
62 | function forAllCodeBlocks(operation) { | ||
63 | var codeBlocks = findCodeBlocks(); | ||
64 | |||
65 | for (var i = 0; i < codeBlocks.length; ++i) { | ||
66 | operation(codeBlocks[i], "wrapped"); | ||
67 | } | ||
68 | } | ||
69 | |||
70 | function toggleLineWrapping() { | ||
71 | var checkBox = getCheckBox(); | ||
72 | |||
73 | if (checkBox.checked) { | ||
74 | forAllCodeBlocks(addClass); | ||
75 | } else { | ||
76 | forAllCodeBlocks(removeClass); | ||
77 | } | ||
78 | } | ||
79 | |||
80 | function initControls() { | ||
81 | if (findCodeBlocks().length > 0) { | ||
82 | var checkBox = getCheckBox(); | ||
83 | var label = getLabelForCheckBox(); | ||
84 | |||
85 | checkBox.onclick = toggleLineWrapping; | ||
86 | checkBox.checked = false; | ||
87 | |||
88 | removeClass(label, "hidden"); | ||
89 | } | ||
90 | } | ||
91 | |||
92 | function switchTab() { | ||
93 | var id = this.id.substr(1); | ||
94 | |||
95 | for (var i = 0; i < tabs.tabs.length; i++) { | ||
96 | if (tabs.tabs[i].id === id) { | ||
97 | tabs.select(i); | ||
98 | break; | ||
99 | } | ||
100 | } | ||
101 | |||
102 | return false; | ||
103 | } | ||
104 | |||
105 | function select(i) { | ||
106 | this.deselectAll(); | ||
107 | |||
108 | changeElementClass(this.tabs[i], "tab selected"); | ||
109 | changeElementClass(this.headers[i], "selected"); | ||
110 | |||
111 | while (this.headers[i].firstChild) { | ||
112 | this.headers[i].removeChild(this.headers[i].firstChild); | ||
113 | } | ||
114 | |||
115 | var h2 = document.createElement("H2"); | ||
116 | |||
117 | h2.appendChild(document.createTextNode(this.titles[i])); | ||
118 | this.headers[i].appendChild(h2); | ||
119 | } | ||
120 | |||
121 | function deselectAll() { | ||
122 | for (var i = 0; i < this.tabs.length; i++) { | ||
123 | changeElementClass(this.tabs[i], "tab deselected"); | ||
124 | changeElementClass(this.headers[i], "deselected"); | ||
125 | |||
126 | while (this.headers[i].firstChild) { | ||
127 | this.headers[i].removeChild(this.headers[i].firstChild); | ||
128 | } | ||
129 | |||
130 | var a = document.createElement("A"); | ||
131 | |||
132 | a.setAttribute("id", "ltab" + i); | ||
133 | a.setAttribute("href", "#tab" + i); | ||
134 | a.onclick = switchTab; | ||
135 | a.appendChild(document.createTextNode(this.titles[i])); | ||
136 | |||
137 | this.headers[i].appendChild(a); | ||
138 | } | ||
139 | } | ||
140 | |||
141 | function findTabs(container) { | ||
142 | return findChildElements(container, "DIV", "tab"); | ||
143 | } | ||
144 | |||
145 | function findHeaders(container) { | ||
146 | var owner = findChildElements(container, "UL", "tabLinks"); | ||
147 | return findChildElements(owner[0], "LI", null); | ||
148 | } | ||
149 | |||
150 | function findTitles(tabs) { | ||
151 | var titles = []; | ||
152 | |||
153 | for (var i = 0; i < tabs.length; i++) { | ||
154 | var tab = tabs[i]; | ||
155 | var header = findChildElements(tab, "H2", null)[0]; | ||
156 | |||
157 | header.parentNode.removeChild(header); | ||
158 | |||
159 | if (header.innerText) { | ||
160 | titles.push(header.innerText); | ||
161 | } else { | ||
162 | titles.push(header.textContent); | ||
163 | } | ||
164 | } | ||
165 | |||
166 | return titles; | ||
167 | } | ||
168 | |||
169 | function findChildElements(container, name, targetClass) { | ||
170 | var elements = []; | ||
171 | var children = container.childNodes; | ||
172 | |||
173 | for (var i = 0; i < children.length; i++) { | ||
174 | var child = children.item(i); | ||
175 | |||
176 | if (child.nodeType === 1 && child.nodeName === name) { | ||
177 | if (targetClass && child.className.indexOf(targetClass) < 0) { | ||
178 | continue; | ||
179 | } | ||
180 | |||
181 | elements.push(child); | ||
182 | } | ||
183 | } | ||
184 | |||
185 | return elements; | ||
186 | } | ||
187 | |||
188 | // Entry point. | ||
189 | |||
190 | window.onload = function() { | ||
191 | initTabs(); | ||
192 | initControls(); | ||
193 | }; | ||
194 | } (window, window.document)); \ No newline at end of file | ||
diff --git a/org.eclipse.viatra.coding/build/reports/tests/test/packages/org.eclipse.viatra.coding.html b/org.eclipse.viatra.coding/build/reports/tests/test/packages/org.eclipse.viatra.coding.html new file mode 100644 index 00000000..d9d94b7a --- /dev/null +++ b/org.eclipse.viatra.coding/build/reports/tests/test/packages/org.eclipse.viatra.coding.html | |||
@@ -0,0 +1,103 @@ | |||
1 | <!DOCTYPE html> | ||
2 | <html> | ||
3 | <head> | ||
4 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | ||
5 | <meta http-equiv="x-ua-compatible" content="IE=edge"/> | ||
6 | <title>Test results - Package org.eclipse.viatra.coding</title> | ||
7 | <link href="../css/base-style.css" rel="stylesheet" type="text/css"/> | ||
8 | <link href="../css/style.css" rel="stylesheet" type="text/css"/> | ||
9 | <script src="../js/report.js" type="text/javascript"></script> | ||
10 | </head> | ||
11 | <body> | ||
12 | <div id="content"> | ||
13 | <h1>Package org.eclipse.viatra.coding</h1> | ||
14 | <div class="breadcrumbs"> | ||
15 | <a href="../index.html">all</a> > org.eclipse.viatra.coding</div> | ||
16 | <div id="summary"> | ||
17 | <table> | ||
18 | <tr> | ||
19 | <td> | ||
20 | <div class="summaryGroup"> | ||
21 | <table> | ||
22 | <tr> | ||
23 | <td> | ||
24 | <div class="infoBox" id="tests"> | ||
25 | <div class="counter">1</div> | ||
26 | <p>tests</p> | ||
27 | </div> | ||
28 | </td> | ||
29 | <td> | ||
30 | <div class="infoBox" id="failures"> | ||
31 | <div class="counter">0</div> | ||
32 | <p>failures</p> | ||
33 | </div> | ||
34 | </td> | ||
35 | <td> | ||
36 | <div class="infoBox" id="ignored"> | ||
37 | <div class="counter">0</div> | ||
38 | <p>ignored</p> | ||
39 | </div> | ||
40 | </td> | ||
41 | <td> | ||
42 | <div class="infoBox" id="duration"> | ||
43 | <div class="counter">0.098s</div> | ||
44 | <p>duration</p> | ||
45 | </div> | ||
46 | </td> | ||
47 | </tr> | ||
48 | </table> | ||
49 | </div> | ||
50 | </td> | ||
51 | <td> | ||
52 | <div class="infoBox success" id="successRate"> | ||
53 | <div class="percent">100%</div> | ||
54 | <p>successful</p> | ||
55 | </div> | ||
56 | </td> | ||
57 | </tr> | ||
58 | </table> | ||
59 | </div> | ||
60 | <div id="tabs"> | ||
61 | <ul class="tabLinks"> | ||
62 | <li> | ||
63 | <a href="#tab0">Classes</a> | ||
64 | </li> | ||
65 | </ul> | ||
66 | <div id="tab0" class="tab"> | ||
67 | <h2>Classes</h2> | ||
68 | <table> | ||
69 | <thread> | ||
70 | <tr> | ||
71 | <th>Class</th> | ||
72 | <th>Tests</th> | ||
73 | <th>Failures</th> | ||
74 | <th>Ignored</th> | ||
75 | <th>Duration</th> | ||
76 | <th>Success rate</th> | ||
77 | </tr> | ||
78 | </thread> | ||
79 | <tr> | ||
80 | <td class="success"> | ||
81 | <a href="../classes/org.eclipse.viatra.coding.GraphPermutationTest.html">GraphPermutationTest</a> | ||
82 | </td> | ||
83 | <td>1</td> | ||
84 | <td>0</td> | ||
85 | <td>0</td> | ||
86 | <td>0.098s</td> | ||
87 | <td class="success">100%</td> | ||
88 | </tr> | ||
89 | </table> | ||
90 | </div> | ||
91 | </div> | ||
92 | <div id="footer"> | ||
93 | <p> | ||
94 | <div> | ||
95 | <label class="hidden" id="label-for-line-wrapping-toggle" for="line-wrapping-toggle">Wrap lines | ||
96 | <input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/> | ||
97 | </label> | ||
98 | </div>Generated by | ||
99 | <a href="http://www.gradle.org">Gradle 6.1</a> at Oct 26, 2020, 12:09:38 AM</p> | ||
100 | </div> | ||
101 | </div> | ||
102 | </body> | ||
103 | </html> | ||
diff --git a/org.eclipse.viatra.coding/build/test-results/test/TEST-org.eclipse.viatra.coding.GraphPermutationTest.xml b/org.eclipse.viatra.coding/build/test-results/test/TEST-org.eclipse.viatra.coding.GraphPermutationTest.xml new file mode 100644 index 00000000..1a4c17c8 --- /dev/null +++ b/org.eclipse.viatra.coding/build/test-results/test/TEST-org.eclipse.viatra.coding.GraphPermutationTest.xml | |||
@@ -0,0 +1,7 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <testsuite name="org.eclipse.viatra.coding.GraphPermutationTest" tests="1" skipped="0" failures="0" errors="0" timestamp="2020-10-26T04:09:38" hostname="DESKTOP-KQ6RJNS" time="0.098"> | ||
3 | <properties/> | ||
4 | <testcase name="testUniqueStateCodes" classname="org.eclipse.viatra.coding.GraphPermutationTest" time="0.098"/> | ||
5 | <system-out><![CDATA[]]></system-out> | ||
6 | <system-err><![CDATA[]]></system-err> | ||
7 | </testsuite> | ||
diff --git a/org.eclipse.viatra.coding/build/test-results/test/binary/output.bin b/org.eclipse.viatra.coding/build/test-results/test/binary/output.bin new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/org.eclipse.viatra.coding/build/test-results/test/binary/output.bin | |||
diff --git a/org.eclipse.viatra.coding/build/test-results/test/binary/output.bin.idx b/org.eclipse.viatra.coding/build/test-results/test/binary/output.bin.idx new file mode 100644 index 00000000..f76dd238 --- /dev/null +++ b/org.eclipse.viatra.coding/build/test-results/test/binary/output.bin.idx | |||
Binary files differ | |||
diff --git a/org.eclipse.viatra.coding/build/test-results/test/binary/results.bin b/org.eclipse.viatra.coding/build/test-results/test/binary/results.bin new file mode 100644 index 00000000..e0570c84 --- /dev/null +++ b/org.eclipse.viatra.coding/build/test-results/test/binary/results.bin | |||
Binary files differ | |||
diff --git a/org.eclipse.viatra.coding/build/tmp/jar/MANIFEST.MF b/org.eclipse.viatra.coding/build/tmp/jar/MANIFEST.MF new file mode 100644 index 00000000..59499bce --- /dev/null +++ b/org.eclipse.viatra.coding/build/tmp/jar/MANIFEST.MF | |||
@@ -0,0 +1,2 @@ | |||
1 | Manifest-Version: 1.0 | ||
2 | |||
diff --git a/org.eclipse.viatra.coding/build/tmp/publishMavenJavaPublicationToMavenLocal/module-maven-metadata.xml b/org.eclipse.viatra.coding/build/tmp/publishMavenJavaPublicationToMavenLocal/module-maven-metadata.xml new file mode 100644 index 00000000..74f31a85 --- /dev/null +++ b/org.eclipse.viatra.coding/build/tmp/publishMavenJavaPublicationToMavenLocal/module-maven-metadata.xml | |||
@@ -0,0 +1,13 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <metadata> | ||
3 | <groupId>org.eclipse.viatra</groupId> | ||
4 | <artifactId>org.eclipse.viatra.coding</artifactId> | ||
5 | <versioning> | ||
6 | <latest>0.0.1</latest> | ||
7 | <release>0.0.1</release> | ||
8 | <versions> | ||
9 | <version>0.0.1</version> | ||
10 | </versions> | ||
11 | <lastUpdated>20201028143314</lastUpdated> | ||
12 | </versioning> | ||
13 | </metadata> | ||
diff --git a/org.eclipse.viatra.coding/gradle/wrapper/gradle-wrapper.properties b/org.eclipse.viatra.coding/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..ba94df84 --- /dev/null +++ b/org.eclipse.viatra.coding/gradle/wrapper/gradle-wrapper.properties | |||
@@ -0,0 +1,5 @@ | |||
1 | distributionBase=GRADLE_USER_HOME | ||
2 | distributionPath=wrapper/dists | ||
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-bin.zip | ||
4 | zipStoreBase=GRADLE_USER_HOME | ||
5 | zipStorePath=wrapper/dists | ||
diff --git a/org.eclipse.viatra.coding/gradlew b/org.eclipse.viatra.coding/gradlew new file mode 100644 index 00000000..2fe81a7d --- /dev/null +++ b/org.eclipse.viatra.coding/gradlew | |||
@@ -0,0 +1,183 @@ | |||
1 | #!/usr/bin/env sh | ||
2 | |||
3 | # | ||
4 | # Copyright 2015 the original author or authors. | ||
5 | # | ||
6 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
7 | # you may not use this file except in compliance with the License. | ||
8 | # You may obtain a copy of the License at | ||
9 | # | ||
10 | # https://www.apache.org/licenses/LICENSE-2.0 | ||
11 | # | ||
12 | # Unless required by applicable law or agreed to in writing, software | ||
13 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
15 | # See the License for the specific language governing permissions and | ||
16 | # limitations under the License. | ||
17 | # | ||
18 | |||
19 | ############################################################################## | ||
20 | ## | ||
21 | ## Gradle start up script for UN*X | ||
22 | ## | ||
23 | ############################################################################## | ||
24 | |||
25 | # Attempt to set APP_HOME | ||
26 | # Resolve links: $0 may be a link | ||
27 | PRG="$0" | ||
28 | # Need this for relative symlinks. | ||
29 | while [ -h "$PRG" ] ; do | ||
30 | ls=`ls -ld "$PRG"` | ||
31 | link=`expr "$ls" : '.*-> \(.*\)$'` | ||
32 | if expr "$link" : '/.*' > /dev/null; then | ||
33 | PRG="$link" | ||
34 | else | ||
35 | PRG=`dirname "$PRG"`"/$link" | ||
36 | fi | ||
37 | done | ||
38 | SAVED="`pwd`" | ||
39 | cd "`dirname \"$PRG\"`/" >/dev/null | ||
40 | APP_HOME="`pwd -P`" | ||
41 | cd "$SAVED" >/dev/null | ||
42 | |||
43 | APP_NAME="Gradle" | ||
44 | APP_BASE_NAME=`basename "$0"` | ||
45 | |||
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. | ||
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' | ||
48 | |||
49 | # Use the maximum available, or set MAX_FD != -1 to use that value. | ||
50 | MAX_FD="maximum" | ||
51 | |||
52 | warn () { | ||
53 | echo "$*" | ||
54 | } | ||
55 | |||
56 | die () { | ||
57 | echo | ||
58 | echo "$*" | ||
59 | echo | ||
60 | exit 1 | ||
61 | } | ||
62 | |||
63 | # OS specific support (must be 'true' or 'false'). | ||
64 | cygwin=false | ||
65 | msys=false | ||
66 | darwin=false | ||
67 | nonstop=false | ||
68 | case "`uname`" in | ||
69 | CYGWIN* ) | ||
70 | cygwin=true | ||
71 | ;; | ||
72 | Darwin* ) | ||
73 | darwin=true | ||
74 | ;; | ||
75 | MINGW* ) | ||
76 | msys=true | ||
77 | ;; | ||
78 | NONSTOP* ) | ||
79 | nonstop=true | ||
80 | ;; | ||
81 | esac | ||
82 | |||
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar | ||
84 | |||
85 | # Determine the Java command to use to start the JVM. | ||
86 | if [ -n "$JAVA_HOME" ] ; then | ||
87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then | ||
88 | # IBM's JDK on AIX uses strange locations for the executables | ||
89 | JAVACMD="$JAVA_HOME/jre/sh/java" | ||
90 | else | ||
91 | JAVACMD="$JAVA_HOME/bin/java" | ||
92 | fi | ||
93 | if [ ! -x "$JAVACMD" ] ; then | ||
94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME | ||
95 | |||
96 | Please set the JAVA_HOME variable in your environment to match the | ||
97 | location of your Java installation." | ||
98 | fi | ||
99 | else | ||
100 | JAVACMD="java" | ||
101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. | ||
102 | |||
103 | Please set the JAVA_HOME variable in your environment to match the | ||
104 | location of your Java installation." | ||
105 | fi | ||
106 | |||
107 | # Increase the maximum file descriptors if we can. | ||
108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then | ||
109 | MAX_FD_LIMIT=`ulimit -H -n` | ||
110 | if [ $? -eq 0 ] ; then | ||
111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then | ||
112 | MAX_FD="$MAX_FD_LIMIT" | ||
113 | fi | ||
114 | ulimit -n $MAX_FD | ||
115 | if [ $? -ne 0 ] ; then | ||
116 | warn "Could not set maximum file descriptor limit: $MAX_FD" | ||
117 | fi | ||
118 | else | ||
119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" | ||
120 | fi | ||
121 | fi | ||
122 | |||
123 | # For Darwin, add options to specify how the application appears in the dock | ||
124 | if $darwin; then | ||
125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" | ||
126 | fi | ||
127 | |||
128 | # For Cygwin or MSYS, switch paths to Windows format before running java | ||
129 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then | ||
130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` | ||
131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` | ||
132 | JAVACMD=`cygpath --unix "$JAVACMD"` | ||
133 | |||
134 | # We build the pattern for arguments to be converted via cygpath | ||
135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` | ||
136 | SEP="" | ||
137 | for dir in $ROOTDIRSRAW ; do | ||
138 | ROOTDIRS="$ROOTDIRS$SEP$dir" | ||
139 | SEP="|" | ||
140 | done | ||
141 | OURCYGPATTERN="(^($ROOTDIRS))" | ||
142 | # Add a user-defined pattern to the cygpath arguments | ||
143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then | ||
144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" | ||
145 | fi | ||
146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh | ||
147 | i=0 | ||
148 | for arg in "$@" ; do | ||
149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` | ||
150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option | ||
151 | |||
152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition | ||
153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` | ||
154 | else | ||
155 | eval `echo args$i`="\"$arg\"" | ||
156 | fi | ||
157 | i=`expr $i + 1` | ||
158 | done | ||
159 | case $i in | ||
160 | 0) set -- ;; | ||
161 | 1) set -- "$args0" ;; | ||
162 | 2) set -- "$args0" "$args1" ;; | ||
163 | 3) set -- "$args0" "$args1" "$args2" ;; | ||
164 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; | ||
165 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; | ||
166 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; | ||
167 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; | ||
168 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; | ||
169 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; | ||
170 | esac | ||
171 | fi | ||
172 | |||
173 | # Escape application args | ||
174 | save () { | ||
175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done | ||
176 | echo " " | ||
177 | } | ||
178 | APP_ARGS=`save "$@"` | ||
179 | |||
180 | # Collect all arguments for the java command, following the shell quoting and substitution rules | ||
181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" | ||
182 | |||
183 | exec "$JAVACMD" "$@" | ||
diff --git a/org.eclipse.viatra.coding/gradlew.bat b/org.eclipse.viatra.coding/gradlew.bat new file mode 100644 index 00000000..9618d8d9 --- /dev/null +++ b/org.eclipse.viatra.coding/gradlew.bat | |||
@@ -0,0 +1,100 @@ | |||
1 | @rem | ||
2 | @rem Copyright 2015 the original author or authors. | ||
3 | @rem | ||
4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | @rem you may not use this file except in compliance with the License. | ||
6 | @rem You may obtain a copy of the License at | ||
7 | @rem | ||
8 | @rem https://www.apache.org/licenses/LICENSE-2.0 | ||
9 | @rem | ||
10 | @rem Unless required by applicable law or agreed to in writing, software | ||
11 | @rem distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | @rem See the License for the specific language governing permissions and | ||
14 | @rem limitations under the License. | ||
15 | @rem | ||
16 | |||
17 | @if "%DEBUG%" == "" @echo off | ||
18 | @rem ########################################################################## | ||
19 | @rem | ||
20 | @rem Gradle startup script for Windows | ||
21 | @rem | ||
22 | @rem ########################################################################## | ||
23 | |||
24 | @rem Set local scope for the variables with windows NT shell | ||
25 | if "%OS%"=="Windows_NT" setlocal | ||
26 | |||
27 | set DIRNAME=%~dp0 | ||
28 | if "%DIRNAME%" == "" set DIRNAME=. | ||
29 | set APP_BASE_NAME=%~n0 | ||
30 | set APP_HOME=%DIRNAME% | ||
31 | |||
32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. | ||
33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" | ||
34 | |||
35 | @rem Find java.exe | ||
36 | if defined JAVA_HOME goto findJavaFromJavaHome | ||
37 | |||
38 | set JAVA_EXE=java.exe | ||
39 | %JAVA_EXE% -version >NUL 2>&1 | ||
40 | if "%ERRORLEVEL%" == "0" goto init | ||
41 | |||
42 | echo. | ||
43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. | ||
44 | echo. | ||
45 | echo Please set the JAVA_HOME variable in your environment to match the | ||
46 | echo location of your Java installation. | ||
47 | |||
48 | goto fail | ||
49 | |||
50 | :findJavaFromJavaHome | ||
51 | set JAVA_HOME=%JAVA_HOME:"=% | ||
52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe | ||
53 | |||
54 | if exist "%JAVA_EXE%" goto init | ||
55 | |||
56 | echo. | ||
57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% | ||
58 | echo. | ||
59 | echo Please set the JAVA_HOME variable in your environment to match the | ||
60 | echo location of your Java installation. | ||
61 | |||
62 | goto fail | ||
63 | |||
64 | :init | ||
65 | @rem Get command-line arguments, handling Windows variants | ||
66 | |||
67 | if not "%OS%" == "Windows_NT" goto win9xME_args | ||
68 | |||
69 | :win9xME_args | ||
70 | @rem Slurp the command line arguments. | ||
71 | set CMD_LINE_ARGS= | ||
72 | set _SKIP=2 | ||
73 | |||
74 | :win9xME_args_slurp | ||
75 | if "x%~1" == "x" goto execute | ||
76 | |||
77 | set CMD_LINE_ARGS=%* | ||
78 | |||
79 | :execute | ||
80 | @rem Setup the command line | ||
81 | |||
82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar | ||
83 | |||
84 | @rem Execute Gradle | ||
85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% | ||
86 | |||
87 | :end | ||
88 | @rem End local scope for the variables with windows NT shell | ||
89 | if "%ERRORLEVEL%"=="0" goto mainEnd | ||
90 | |||
91 | :fail | ||
92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of | ||
93 | rem the _cmd.exe /c_ return code! | ||
94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 | ||
95 | exit /b 1 | ||
96 | |||
97 | :mainEnd | ||
98 | if "%OS%"=="Windows_NT" endlocal | ||
99 | |||
100 | :omega | ||
diff --git a/org.eclipse.viatra.coding/src/main/java/org/eclipse/viatra/coding/AdjacencyStateCode.java b/org.eclipse.viatra.coding/src/main/java/org/eclipse/viatra/coding/AdjacencyStateCode.java new file mode 100644 index 00000000..12b2904c --- /dev/null +++ b/org.eclipse.viatra.coding/src/main/java/org/eclipse/viatra/coding/AdjacencyStateCode.java | |||
@@ -0,0 +1,142 @@ | |||
1 | package org.eclipse.viatra.coding; | ||
2 | |||
3 | import java.util.*; | ||
4 | |||
5 | public class AdjacencyStateCode implements IStateCode { | ||
6 | private int shuffleTime; | ||
7 | private List<Integer> sortedNodeCodes; | ||
8 | |||
9 | private static final Comparator<List<List<Integer>>> adjacencyListComparator = (o1, o2) -> { | ||
10 | for (int i = 0; i < o1.size() && i < o2.size(); i++) { | ||
11 | for (int j = 0; j < 2; j++) { | ||
12 | if (!o1.get(i).get(j).equals(o2.get(i).get(j))) { | ||
13 | return o1.get(i).get(j) - o2.get(i).get(j); | ||
14 | } | ||
15 | } | ||
16 | } | ||
17 | return o1.size() - o2.size(); | ||
18 | }; | ||
19 | |||
20 | private static final Comparator<Map<String, List<List<Integer>>>> adjacencyMapComparator = (m1, m2) -> { | ||
21 | Iterator<Map.Entry<String, List<List<Integer>>>> i1 = m1.entrySet().iterator(); | ||
22 | Iterator<Map.Entry<String, List<List<Integer>>>> i2 = m2.entrySet().iterator(); | ||
23 | |||
24 | while(i1.hasNext() && i2.hasNext()) { | ||
25 | Map.Entry<String, List<List<Integer>>> e1 = i1.next(); | ||
26 | Map.Entry<String, List<List<Integer>>> e2 = i2.next(); | ||
27 | |||
28 | int keyCompare = e1.getKey().compareTo(e2.getKey()); | ||
29 | if (keyCompare != 0) { | ||
30 | return keyCompare; | ||
31 | } | ||
32 | |||
33 | int valueCompare = adjacencyListComparator.compare(e1.getValue(), e2.getValue()); | ||
34 | if (valueCompare != 0) { | ||
35 | return valueCompare; | ||
36 | } | ||
37 | } | ||
38 | |||
39 | return m1.size() - m2.size(); | ||
40 | }; | ||
41 | |||
42 | public AdjacencyStateCode(int shuffleTime) { | ||
43 | this.shuffleTime = shuffleTime; | ||
44 | } | ||
45 | |||
46 | @Override | ||
47 | public Object processStateCode(Graph graph, Map<Node, Integer> nodeCerts) { | ||
48 | Map<Integer, List<Node>> nodeGrouping = createNodeGrouping(nodeCerts); | ||
49 | |||
50 | List<Integer> sortedNodeCodes = new ArrayList<>(nodeGrouping.keySet()); | ||
51 | Collections.sort(sortedNodeCodes); | ||
52 | |||
53 | SortedMap<String, List<List<Integer>>> adjacencyMap = null; | ||
54 | |||
55 | |||
56 | for (int i = 0; i < shuffleTime; i++) { | ||
57 | List<Node> nodeOrdering = shuffleNodes(nodeGrouping, sortedNodeCodes); | ||
58 | |||
59 | SortedMap<String, List<List<Integer>>> newAdjacencyMap = Utils.adjacencyMap(graph, nodeOrdering); | ||
60 | adjacencyMap = (adjacencyMap == null)? newAdjacencyMap : (adjacencyMapComparator.compare(adjacencyMap, newAdjacencyMap) > 0) ? newAdjacencyMap : adjacencyMap; | ||
61 | } | ||
62 | |||
63 | assert adjacencyMap != null; | ||
64 | return adjacencyMatrixHash(adjacencyMap); | ||
65 | } | ||
66 | |||
67 | public int adjacencyMatrixHash(SortedMap<String, List<List<Integer>>> adjacencyMap) { | ||
68 | int code = 0; | ||
69 | for (Map.Entry<String, List<List<Integer>>> stringListEntry : adjacencyMap.entrySet()) { | ||
70 | code = code * 31 + encodeEntry(stringListEntry); | ||
71 | } | ||
72 | |||
73 | return code; | ||
74 | } | ||
75 | |||
76 | private int encodeEntry(Map.Entry<String, List<List<Integer>>> e) { | ||
77 | return e.getKey().hashCode() * 31 + e.getValue().hashCode(); | ||
78 | } | ||
79 | |||
80 | private Map<Node, Map<Node, String>> processGraph(Graph graph) { | ||
81 | Map<Node, Map<Node, String>> mapGraph = new HashMap<>(); | ||
82 | List<String> sortedEdgeLabel = graph.getEdgeLabels(); | ||
83 | Collections.sort(sortedEdgeLabel); | ||
84 | |||
85 | for (int i = 0; i < sortedEdgeLabel.size(); i++) { | ||
86 | String label = sortedEdgeLabel.get(i); | ||
87 | for (List<Node> edge : graph.getLabelEdges().get(label)) { | ||
88 | if (!mapGraph.containsKey(edge.get(0))) { | ||
89 | mapGraph.put(edge.get(0), new HashMap<>()); | ||
90 | } | ||
91 | |||
92 | Map<Node, String> neighbors = mapGraph.get(edge.get(0)); | ||
93 | neighbors.put(edge.get(1), neighbors.getOrDefault(edge.get(1), "") + Integer.toString(i)); | ||
94 | } | ||
95 | } | ||
96 | |||
97 | return mapGraph; | ||
98 | } | ||
99 | |||
100 | private Map<Integer, List<Node>> createNodeGrouping(Map<Node, Integer> nodeCerts) { | ||
101 | Map<Integer, List<Node>> grouping = new HashMap<>(); | ||
102 | for (Map.Entry<Node, Integer> entry : nodeCerts.entrySet()) { | ||
103 | if (!grouping.containsKey(entry.getValue())) { | ||
104 | grouping.put(entry.getValue(), new ArrayList<>()); | ||
105 | } | ||
106 | |||
107 | grouping.get(entry.getValue()).add(entry.getKey()); | ||
108 | } | ||
109 | |||
110 | return grouping; | ||
111 | } | ||
112 | |||
113 | private String adjacencyString(Map<Node, Map<Node, String>> mapGraph, List<Node> nodeOrdering) { | ||
114 | StringBuilder sb = new StringBuilder(); | ||
115 | for (Node start : nodeOrdering) { | ||
116 | // node has no outgoing edges | ||
117 | if (!mapGraph.containsKey(start)) { | ||
118 | for (int i = 0; i < nodeOrdering.size(); i++) { | ||
119 | sb.append("-"); | ||
120 | } | ||
121 | }else { | ||
122 | Map<Node, String> neighbors = mapGraph.get(start); | ||
123 | for (Node end : nodeOrdering) { | ||
124 | sb.append(neighbors.getOrDefault(end, "-")); | ||
125 | } | ||
126 | } | ||
127 | } | ||
128 | |||
129 | return sb.toString(); | ||
130 | } | ||
131 | |||
132 | private List<Node> shuffleNodes(Map<Integer, List<Node>> nodeGrouping, List<Integer> sortedNodeCodes) { | ||
133 | List<Node> result = new ArrayList<>(); | ||
134 | for (Integer code : sortedNodeCodes) { | ||
135 | List<Node> nodes = nodeGrouping.get(code); | ||
136 | Collections.shuffle(nodes); | ||
137 | result.addAll(nodes); | ||
138 | } | ||
139 | |||
140 | return result; | ||
141 | } | ||
142 | } | ||
diff --git a/org.eclipse.viatra.coding/src/main/java/org/eclipse/viatra/coding/ArrayStateCode.java b/org.eclipse.viatra.coding/src/main/java/org/eclipse/viatra/coding/ArrayStateCode.java new file mode 100644 index 00000000..d1743787 --- /dev/null +++ b/org.eclipse.viatra.coding/src/main/java/org/eclipse/viatra/coding/ArrayStateCode.java | |||
@@ -0,0 +1,16 @@ | |||
1 | package org.eclipse.viatra.coding; | ||
2 | |||
3 | import java.util.ArrayList; | ||
4 | import java.util.Collections; | ||
5 | import java.util.List; | ||
6 | import java.util.Map; | ||
7 | import java.util.stream.Collectors; | ||
8 | |||
9 | public class ArrayStateCode implements IStateCode { | ||
10 | @Override | ||
11 | public Object processStateCode(Graph graph, Map<Node, Integer> nodeCerts) { | ||
12 | List<Integer> nodeCodes = new ArrayList<>(nodeCerts.values()); | ||
13 | Collections.sort(nodeCodes); | ||
14 | return nodeCodes.hashCode(); | ||
15 | } | ||
16 | } | ||
diff --git a/org.eclipse.viatra.coding/src/main/java/org/eclipse/viatra/coding/CertificatePropagator.java b/org.eclipse.viatra.coding/src/main/java/org/eclipse/viatra/coding/CertificatePropagator.java new file mode 100644 index 00000000..e05bae11 --- /dev/null +++ b/org.eclipse.viatra.coding/src/main/java/org/eclipse/viatra/coding/CertificatePropagator.java | |||
@@ -0,0 +1,6 @@ | |||
1 | package org.eclipse.viatra.coding; | ||
2 | |||
3 | public interface CertificatePropagator { | ||
4 | // generate a new certificate for the edge based on the old certificate | ||
5 | int newCert(int old, String edgeLabel, int srcCert, int tgtCert); | ||
6 | } | ||
diff --git a/org.eclipse.viatra.coding/src/main/java/org/eclipse/viatra/coding/Encoder.java b/org.eclipse.viatra.coding/src/main/java/org/eclipse/viatra/coding/Encoder.java new file mode 100644 index 00000000..9d3a5db7 --- /dev/null +++ b/org.eclipse.viatra.coding/src/main/java/org/eclipse/viatra/coding/Encoder.java | |||
@@ -0,0 +1,101 @@ | |||
1 | package org.eclipse.viatra.coding; | ||
2 | |||
3 | |||
4 | import java.util.*; | ||
5 | import java.util.stream.Collectors; | ||
6 | |||
7 | public class Encoder { | ||
8 | private CertificatePropagator certificate; | ||
9 | private IStateCode stateCoder; | ||
10 | |||
11 | public Encoder(IStateCode stateCoder) { | ||
12 | certificate = new BinaryCertificatePropagator(); | ||
13 | this.stateCoder = stateCoder; | ||
14 | } | ||
15 | |||
16 | public Encoder(CertificatePropagator certificate, IStateCode stateCoder) { | ||
17 | this.certificate = certificate; | ||
18 | this.stateCoder = stateCoder; | ||
19 | } | ||
20 | |||
21 | public Object encode(Graph g) { | ||
22 | Map<Node, Integer> temp = new HashMap<>(); | ||
23 | Map<List<Node>, Integer> edgeCerts = new HashMap<>(); | ||
24 | Map<Node, Integer> nodeCerts = new HashMap<>(); | ||
25 | |||
26 | for (Map.Entry<String, Set<List<Node>>> entry : g.getLabelEdges().entrySet()) { | ||
27 | for (List<Node> edge : entry.getValue()) { | ||
28 | edgeCerts.put(edge, entry.getKey().hashCode()); | ||
29 | } | ||
30 | } | ||
31 | |||
32 | for (Map.Entry<String, Set<Node>> entry : g.getLabelNodes().entrySet()) { | ||
33 | for (Node node : entry.getValue()) { | ||
34 | nodeCerts.put(node, entry.getKey().hashCode()); | ||
35 | temp.put(node, 0); | ||
36 | } | ||
37 | } | ||
38 | int partSize = 1, oldPartSize; | ||
39 | |||
40 | do { | ||
41 | oldPartSize = partSize; | ||
42 | for (Map.Entry<String, Set<List<Node>>> entry : g.getLabelEdges().entrySet()) { | ||
43 | for (List<Node> edge : entry.getValue()) { | ||
44 | int newEdgeCerts = certificate.newCert(edgeCerts.get(edge), entry.getKey(), nodeCerts.get(edge.get(0)), nodeCerts.get(edge.get(1))); | ||
45 | edgeCerts.put(edge, newEdgeCerts); | ||
46 | |||
47 | // propagate the changes | ||
48 | // add one to distinguish the incoming edge and outgoing edge | ||
49 | if(edge.get(0) != edge.get(1)) { | ||
50 | temp.put(edge.get(0), temp.get(edge.get(0)) + newEdgeCerts + 1); | ||
51 | } else { | ||
52 | temp.put(edge.get(0), temp.get(edge.get(0)) + newEdgeCerts + 2); | ||
53 | } | ||
54 | |||
55 | temp.put(edge.get(1), temp.get(edge.get(1)) - newEdgeCerts); | ||
56 | } | ||
57 | } | ||
58 | |||
59 | Set<Integer> certSet = new HashSet<>(); | ||
60 | for (Map.Entry<String, Set<Node>> entry : g.getLabelNodes().entrySet()) { | ||
61 | for (Node node : entry.getValue()) { | ||
62 | nodeCerts.put(node, nodeCerts.get(node) + temp.get(node)); | ||
63 | temp.put(node, 0); | ||
64 | certSet.add(nodeCerts.get(node)); | ||
65 | } | ||
66 | } | ||
67 | partSize = certSet.size(); | ||
68 | } while (partSize > oldPartSize); | ||
69 | |||
70 | return stateCoder.processStateCode(g, nodeCerts); | ||
71 | } | ||
72 | |||
73 | static class BinaryCertificatePropagator implements CertificatePropagator { | ||
74 | @Override | ||
75 | public int newCert(int old, String edgeLabel, int srcCert, int tgtCert) { | ||
76 | int srcShift = 8; | ||
77 | int tgtShift = (edgeLabel.hashCode() & 0xf); | ||
78 | return ((srcCert << srcShift) | (srcCert >>> (32 - srcShift))) + ((tgtCert << tgtShift) | (tgtCert >>> (32 - tgtCert))) + old; | ||
79 | } | ||
80 | } | ||
81 | |||
82 | static class HashCertificatePropagator implements CertificatePropagator { | ||
83 | private static final int PRIME = 31; | ||
84 | |||
85 | @Override | ||
86 | public int newCert(int old, String edgeLabel, int srcCert, int tgtCert) { | ||
87 | int edgeHash = edgeLabel.hashCode(); | ||
88 | int result = (edgeHash ^ (edgeHash >>> (PRIME + 1))); | ||
89 | result = PRIME * result + srcCert; | ||
90 | result = PRIME * result + tgtCert; | ||
91 | return result + old; | ||
92 | } | ||
93 | } | ||
94 | |||
95 | static class NativeHashCertificatePropagator implements CertificatePropagator { | ||
96 | @Override | ||
97 | public int newCert(int old, String edgeLabel, int srcCert, int tgtCert) { | ||
98 | return Objects.hash(edgeLabel, srcCert, tgtCert) + old; | ||
99 | } | ||
100 | } | ||
101 | } | ||
diff --git a/org.eclipse.viatra.coding/src/main/java/org/eclipse/viatra/coding/Graph.java b/org.eclipse.viatra.coding/src/main/java/org/eclipse/viatra/coding/Graph.java new file mode 100644 index 00000000..71787875 --- /dev/null +++ b/org.eclipse.viatra.coding/src/main/java/org/eclipse/viatra/coding/Graph.java | |||
@@ -0,0 +1,113 @@ | |||
1 | package org.eclipse.viatra.coding; | ||
2 | |||
3 | import java.util.*; | ||
4 | |||
5 | public class Graph{ | ||
6 | private Map<String, Set<List<Node>>> labelEdges; | ||
7 | private Map<String, Set<Node>> labelNodes; | ||
8 | private List<Node> nodeOrdering; | ||
9 | |||
10 | public Graph(List<String> nodeLabels, List<String> edgeLabels) { | ||
11 | labelNodes = new HashMap<>(); | ||
12 | labelEdges = new HashMap<>(); | ||
13 | for (String nodeLabel : nodeLabels) { | ||
14 | labelNodes.put(nodeLabel, new HashSet<>()); | ||
15 | } | ||
16 | |||
17 | for (String edgeLabel : edgeLabels) { | ||
18 | labelEdges.put(edgeLabel, new HashSet<>()); | ||
19 | } | ||
20 | nodeOrdering = new ArrayList<>(); | ||
21 | } | ||
22 | |||
23 | // clone a graph | ||
24 | public Graph(Graph other) { | ||
25 | labelNodes = new HashMap<>(); | ||
26 | labelEdges = new HashMap<>(); | ||
27 | for (Map.Entry<String, Set<Node>> entry : other.labelNodes.entrySet()) { | ||
28 | labelNodes.put(entry.getKey(), new HashSet<>(entry.getValue())); | ||
29 | } | ||
30 | |||
31 | for (Map.Entry<String, Set<List<Node>>> entry : other.labelEdges.entrySet()) { | ||
32 | Set<List<Node>> value = new HashSet<>(); | ||
33 | for (List<Node> edge : entry.getValue()) { | ||
34 | value.add(new ArrayList<>(edge)); | ||
35 | } | ||
36 | |||
37 | labelEdges.put(entry.getKey(), value); | ||
38 | } | ||
39 | |||
40 | nodeOrdering = new ArrayList<>(other.nodeOrdering); | ||
41 | } | ||
42 | |||
43 | public void addNode(Node node, String label) { | ||
44 | if (labelNodes.containsKey(label)) { | ||
45 | labelNodes.get(label).add(node); | ||
46 | nodeOrdering.add(node); | ||
47 | } | ||
48 | } | ||
49 | |||
50 | public void addEdge(Node src, Node tgt, String label) { | ||
51 | if (nodeOrdering.contains(src) && nodeOrdering.contains(tgt) && labelEdges.containsKey(label)) { | ||
52 | labelEdges.get(label).add(Arrays.asList(src, tgt)); | ||
53 | } | ||
54 | } | ||
55 | |||
56 | public void removeEdge(Node src, Node tgt, String label) { | ||
57 | if (!labelEdges.containsKey(label)) { | ||
58 | return; | ||
59 | } | ||
60 | |||
61 | labelEdges.get(label).remove(Arrays.asList(src, tgt)); | ||
62 | } | ||
63 | |||
64 | public Map<String, Set<List<Node>>> getLabelEdges() { | ||
65 | return labelEdges; | ||
66 | } | ||
67 | |||
68 | public List<String> getEdgeLabels() { | ||
69 | return new ArrayList<>(labelEdges.keySet()); | ||
70 | } | ||
71 | |||
72 | public Map<String, Set<Node>> getLabelNodes() { | ||
73 | return labelNodes; | ||
74 | } | ||
75 | |||
76 | public int getNodeSize() { | ||
77 | return nodeOrdering.size(); | ||
78 | } | ||
79 | |||
80 | public List<Node> getNodeOrdering() { | ||
81 | return nodeOrdering; | ||
82 | } | ||
83 | |||
84 | public void clear() { | ||
85 | for (Map.Entry<String, Set<Node>> entry : labelNodes.entrySet()) { | ||
86 | entry.getValue().clear(); | ||
87 | } | ||
88 | |||
89 | for (Map.Entry<String, Set<List<Node>>> entry : labelEdges.entrySet()) { | ||
90 | entry.getValue().clear(); | ||
91 | } | ||
92 | |||
93 | nodeOrdering.clear(); | ||
94 | } | ||
95 | |||
96 | public void setNodeOrdering(List<Node> nodeOrdering) { | ||
97 | this.nodeOrdering = nodeOrdering; | ||
98 | } | ||
99 | |||
100 | public String toString() { | ||
101 | StringBuilder sb = new StringBuilder(); | ||
102 | sb.append("Nodes: \n"); | ||
103 | for (Map.Entry<String, Set<Node>> entry : labelNodes.entrySet()) { | ||
104 | sb.append("\t").append(entry.getKey()).append(":").append(entry.getValue()); | ||
105 | } | ||
106 | sb.append("Edges: \n"); | ||
107 | for (Map.Entry<String, Set<List<Node>>> entry : labelEdges.entrySet()) { | ||
108 | sb.append("\t").append(entry.getKey()).append(":").append(entry.getValue()); | ||
109 | } | ||
110 | |||
111 | return sb.toString(); | ||
112 | } | ||
113 | } | ||
diff --git a/org.eclipse.viatra.coding/src/main/java/org/eclipse/viatra/coding/IStateCode.java b/org.eclipse.viatra.coding/src/main/java/org/eclipse/viatra/coding/IStateCode.java new file mode 100644 index 00000000..b1a1b441 --- /dev/null +++ b/org.eclipse.viatra.coding/src/main/java/org/eclipse/viatra/coding/IStateCode.java | |||
@@ -0,0 +1,9 @@ | |||
1 | package org.eclipse.viatra.coding; | ||
2 | |||
3 | |||
4 | import java.util.List; | ||
5 | import java.util.Map; | ||
6 | |||
7 | public interface IStateCode { | ||
8 | Object processStateCode(Graph graph, Map<Node, Integer> nodeCerts); | ||
9 | } | ||
diff --git a/org.eclipse.viatra.coding/src/main/java/org/eclipse/viatra/coding/MultiLevelStateCoder.java b/org.eclipse.viatra.coding/src/main/java/org/eclipse/viatra/coding/MultiLevelStateCoder.java new file mode 100644 index 00000000..97691ed3 --- /dev/null +++ b/org.eclipse.viatra.coding/src/main/java/org/eclipse/viatra/coding/MultiLevelStateCoder.java | |||
@@ -0,0 +1,4 @@ | |||
1 | package org.eclipse.viatra.coding; | ||
2 | |||
3 | public class MultiLevelStateCoder { | ||
4 | } | ||
diff --git a/org.eclipse.viatra.coding/src/main/java/org/eclipse/viatra/coding/Node.java b/org.eclipse.viatra.coding/src/main/java/org/eclipse/viatra/coding/Node.java new file mode 100644 index 00000000..77b27bfe --- /dev/null +++ b/org.eclipse.viatra.coding/src/main/java/org/eclipse/viatra/coding/Node.java | |||
@@ -0,0 +1,19 @@ | |||
1 | package org.eclipse.viatra.coding; | ||
2 | |||
3 | public class Node { | ||
4 | String id; | ||
5 | |||
6 | public Node(String id) { | ||
7 | this.id = id; | ||
8 | } | ||
9 | |||
10 | public Node() { | ||
11 | |||
12 | } | ||
13 | |||
14 | @Override | ||
15 | public String toString(){ | ||
16 | return id; | ||
17 | } | ||
18 | |||
19 | } | ||
diff --git a/org.eclipse.viatra.coding/src/main/java/org/eclipse/viatra/coding/Utils.java b/org.eclipse.viatra.coding/src/main/java/org/eclipse/viatra/coding/Utils.java new file mode 100644 index 00000000..761065f4 --- /dev/null +++ b/org.eclipse.viatra.coding/src/main/java/org/eclipse/viatra/coding/Utils.java | |||
@@ -0,0 +1,58 @@ | |||
1 | package org.eclipse.viatra.coding; | ||
2 | |||
3 | import java.util.*; | ||
4 | import java.util.stream.Collectors; | ||
5 | |||
6 | public final class Utils { | ||
7 | public static final Comparator<List<Integer>> edgeComparator = (o1, o2) -> !o1.get(0).equals(o2.get(0)) ? o1.get(0) - o2.get(0) : o1.get(1) - o2.get(1); | ||
8 | |||
9 | /** | ||
10 | * get adjacency matrix of the graph, currently only work for graphs with one edge label. O(E) | ||
11 | * @param graph: graph with one edge label | ||
12 | * @param nodeOrdering: node ordering for ordering the adjacency matrix, node not in the graph will just having | ||
13 | * false entries to any other node (including itself) | ||
14 | * @return The adjacency matrix of the graph for the specific node ordering | ||
15 | */ | ||
16 | public static boolean[][] adjacencyMatrix(Graph graph, List<Node> nodeOrdering) { | ||
17 | if (graph.getLabelEdges().keySet().size() != 1) { | ||
18 | throw new IllegalArgumentException("There must be exactly one edge label to calculate the adjacency matrix!"); | ||
19 | } | ||
20 | |||
21 | boolean[][] adjacency = new boolean[nodeOrdering.size()][nodeOrdering.size()]; | ||
22 | Set<List<Node>> edges = graph.getLabelEdges().get(graph.getEdgeLabels().get(0)); | ||
23 | Map<Node, Integer> nodeToIndex = new HashMap<>(); | ||
24 | for (int i = 0; i < nodeOrdering.size(); i++) { | ||
25 | nodeToIndex.put(nodeOrdering.get(i), i); | ||
26 | } | ||
27 | |||
28 | try { | ||
29 | for (List<Node> edge : edges) { | ||
30 | adjacency[nodeToIndex.get(edge.get(0))][nodeToIndex.get(edge.get(1))] = true; | ||
31 | } | ||
32 | } catch (NullPointerException e) { | ||
33 | throw new IllegalArgumentException("The node ordering does not contain all nodes of the graph", e); | ||
34 | } | ||
35 | |||
36 | return adjacency; | ||
37 | } | ||
38 | |||
39 | public static SortedMap<String, List<List<Integer>>> adjacencyMap(Graph graph, List<Node> nodeOrdering) { | ||
40 | Map<Node, Integer> nodeToIndex = new HashMap<>(); | ||
41 | SortedMap<String, List<List<Integer>>> adjacencyMap = new TreeMap<>(); | ||
42 | |||
43 | for (int i = 0; i < nodeOrdering.size(); i++) { | ||
44 | nodeToIndex.put(nodeOrdering.get(i), i); | ||
45 | } | ||
46 | |||
47 | List<String> edgeLabels = graph.getEdgeLabels(); | ||
48 | for (String label : edgeLabels) { | ||
49 | List<List<Integer>> sortedEdges = graph.getLabelEdges().get(label).stream() | ||
50 | .map(edge -> Arrays.asList(nodeToIndex.get(edge.get(0)), nodeToIndex.get(edge.get(1)))) | ||
51 | .sorted(edgeComparator).collect(Collectors.toList()); | ||
52 | adjacencyMap.put(label, sortedEdges); | ||
53 | } | ||
54 | |||
55 | return adjacencyMap; | ||
56 | } | ||
57 | |||
58 | } | ||
diff --git a/org.eclipse.viatra.coding/src/test/java/org/eclipse/viatra/coding/GraphPermutationTest.java b/org.eclipse.viatra.coding/src/test/java/org/eclipse/viatra/coding/GraphPermutationTest.java new file mode 100644 index 00000000..572350f9 --- /dev/null +++ b/org.eclipse.viatra.coding/src/test/java/org/eclipse/viatra/coding/GraphPermutationTest.java | |||
@@ -0,0 +1,301 @@ | |||
1 | package org.eclipse.viatra.coding; | ||
2 | |||
3 | import me.tongfei.progressbar.ProgressBar; | ||
4 | import org.eclipse.viatra.coding.helper.GraphPermutation; | ||
5 | import org.hamcrest.core.Is; | ||
6 | import org.junit.Test; | ||
7 | |||
8 | import java.time.Duration; | ||
9 | import java.time.Instant; | ||
10 | import java.util.*; | ||
11 | |||
12 | import static org.junit.Assert.*; | ||
13 | |||
14 | public class GraphPermutationTest { | ||
15 | @Test | ||
16 | public void testPermutationSize() { | ||
17 | GraphPermutation permutation = new GraphPermutation(true, true); | ||
18 | |||
19 | for (int i = 1; i <= 5; i++) { | ||
20 | int size = permutation.permuteGraphSize(i); | ||
21 | assertEquals(1 << (i * i), size); | ||
22 | } | ||
23 | } | ||
24 | |||
25 | @Test | ||
26 | public void testUniqueGraph() { | ||
27 | int size = 5; | ||
28 | GraphPermutation permutation = new GraphPermutation(false, false); | ||
29 | List<Graph> graphs = permutation.permuteGraph(size); | ||
30 | Map<Object, List<Graph>> map = new HashMap<>(); | ||
31 | Encoder encoder = new Encoder(new Encoder.NativeHashCertificatePropagator(), new AdjacencyStateCode(10)); | ||
32 | for (Graph graph : graphs) { | ||
33 | Object code = encoder.encode(graph); | ||
34 | if (!map.containsKey(code)) { | ||
35 | map.put(code, new ArrayList<>()); | ||
36 | } | ||
37 | List<Graph> isomorphicGraphs = map.get(code); | ||
38 | isomorphicGraphs.add(graph); | ||
39 | } | ||
40 | |||
41 | assertEquals(34, map.size()); | ||
42 | } | ||
43 | |||
44 | @Test | ||
45 | public void testUniqueGraph_4_Directed_SelfLoop() { | ||
46 | int size = 4; | ||
47 | GraphPermutation permutation = new GraphPermutation(true, true); | ||
48 | List<Graph> graphs = permutation.permuteGraph(size); | ||
49 | Map<Integer, List<Graph>> map = new HashMap<>(); | ||
50 | Encoder encoder = new Encoder(new Encoder.NativeHashCertificatePropagator(), new AdjacencyStateCode(10)); | ||
51 | for (Graph graph : graphs) { | ||
52 | Integer code = encoder.encode(graph).hashCode(); | ||
53 | if (!map.containsKey(code)) { | ||
54 | map.put(code, new ArrayList<>()); | ||
55 | } | ||
56 | List<Graph> isomorphicGraphs = map.get(code); | ||
57 | isomorphicGraphs.add(graph); | ||
58 | } | ||
59 | |||
60 | //assertEquals(34, map.keySet().size()); | ||
61 | } | ||
62 | |||
63 | @Test | ||
64 | public void testUniqueGraph_4_Directed_SelfLoop_FirstFail() { | ||
65 | int size = 4; | ||
66 | GraphPermutation permutation = new GraphPermutation(true, true); | ||
67 | List<Graph> graphs = permutation.permuteGraph(size); | ||
68 | Map<Object, List<Graph>> map = new HashMap<>(); | ||
69 | Encoder encoder = new Encoder(new AdjacencyStateCode(10)); | ||
70 | for (Graph graph : graphs) { | ||
71 | Object code = encoder.encode(graph); | ||
72 | if (!map.containsKey(code)) { | ||
73 | map.put(code, new ArrayList<>()); | ||
74 | } | ||
75 | List<Graph> isomorphicGraphs = map.get(code); | ||
76 | isomorphicGraphs.add(graph); | ||
77 | } | ||
78 | //assertEquals(34, map.keySet().size()); | ||
79 | System.out.println(map.size()); | ||
80 | int failCount = 0; | ||
81 | for (Map.Entry<Object, List<Graph>> entry : map.entrySet()) { | ||
82 | List<Graph> isoGraphs = entry.getValue(); | ||
83 | if (isoGraphs.size() <= 1) { | ||
84 | continue; | ||
85 | } | ||
86 | |||
87 | for (int j = 0; j < isoGraphs.size() - 1; j++) { | ||
88 | boolean[][] refAdj = Utils.adjacencyMatrix(isoGraphs.get(j), isoGraphs.get(j).getNodeOrdering()); | ||
89 | |||
90 | for (int i = j + 1; i < isoGraphs.size(); i++) { | ||
91 | List<List<Node>> allPerms = new ArrayList<>(); | ||
92 | permute(isoGraphs.get(i).getNodeOrdering(), 0, isoGraphs.get(i).getNodeOrdering().size() - 1, allPerms); | ||
93 | boolean equal = false; | ||
94 | for (List<Node> ordering : allPerms) { | ||
95 | if (Arrays.deepEquals(refAdj, Utils.adjacencyMatrix(isoGraphs.get(i), ordering))) { | ||
96 | equal = true; | ||
97 | break; | ||
98 | } | ||
99 | } | ||
100 | |||
101 | if (!equal) { | ||
102 | System.out.println(adjacencyMatrix2String(refAdj)); | ||
103 | System.out.println(adjacencyMatrix2String(Utils.adjacencyMatrix(isoGraphs.get(i), allPerms.get(0)))); | ||
104 | fail(); | ||
105 | } | ||
106 | } | ||
107 | } | ||
108 | } | ||
109 | } | ||
110 | |||
111 | @Test | ||
112 | public void testUniqueGraph_4_Directional_SelfLoop_Statistics() { | ||
113 | int size = 4; | ||
114 | GraphPermutation permutation = new GraphPermutation(true, true); | ||
115 | List<Graph> graphs = permutation.permuteGraph(size); | ||
116 | Map<Object, List<Graph>> map = new HashMap<>(); | ||
117 | Encoder encoder = new Encoder(new AdjacencyStateCode(10)); | ||
118 | Instant start = Instant.now(); | ||
119 | |||
120 | for (Graph graph : graphs) { | ||
121 | Object code = encoder.encode(graph); | ||
122 | if (!map.containsKey(code)) { | ||
123 | map.put(code, new ArrayList<>()); | ||
124 | } | ||
125 | List<Graph> isomorphicGraphs = map.get(code); | ||
126 | isomorphicGraphs.add(graph); | ||
127 | } | ||
128 | |||
129 | Instant end = Instant.now(); | ||
130 | System.out.println("Process Duration: " + Duration.between(start, end)); | ||
131 | |||
132 | //assertEquals(34, map.keySet().size()); | ||
133 | System.out.println("# Of distinct graph codes: " + map.size()); | ||
134 | int failCount = 0; | ||
135 | for (Map.Entry<Object, List<Graph>> entry : map.entrySet()) { | ||
136 | List<Graph> isoGraphs = entry.getValue(); | ||
137 | if (isoGraphs.size() <= 1) { | ||
138 | continue; | ||
139 | } | ||
140 | |||
141 | for (int j = 0; j < isoGraphs.size() - 1; j++) { | ||
142 | boolean[][] refAdj = Utils.adjacencyMatrix(isoGraphs.get(j), isoGraphs.get(j).getNodeOrdering()); | ||
143 | |||
144 | for (int i = j + 1; i < isoGraphs.size(); i++) { | ||
145 | if (!bruteForceIsomorphismCheck(refAdj, isoGraphs.get(j))) { | ||
146 | failCount++; | ||
147 | } | ||
148 | } | ||
149 | } | ||
150 | } | ||
151 | if (failCount > 0) { | ||
152 | System.out.println("Pairwise Failure Count: " + failCount); | ||
153 | System.out.println("Failure Count / # of graphs: " + (float)failCount / (1 << (size * size))); | ||
154 | fail(); | ||
155 | } | ||
156 | } | ||
157 | |||
158 | @Test | ||
159 | public void testUniqueGraph_Directional_SelfLoop_Soundness_Statistics() throws InterruptedException { | ||
160 | int size = 3; | ||
161 | GraphPermutation permutation = new GraphPermutation(true, true); | ||
162 | List<Graph> graphs = permutation.permuteGraph(size); | ||
163 | Map<Graph, Object> map = new HashMap<>(); | ||
164 | Encoder encoder = new Encoder(new AdjacencyStateCode(10)); | ||
165 | Instant start = Instant.now(); | ||
166 | for (int i = 0; i < graphs.size(); i++) { | ||
167 | Graph graph = graphs.get(i); | ||
168 | Object code = encoder.encode(graph); | ||
169 | map.put(graph, code); | ||
170 | } | ||
171 | |||
172 | Instant end = Instant.now(); | ||
173 | System.out.println("Process Duration: " + Duration.between(start, end)); | ||
174 | |||
175 | //assertEquals(34, map.keySet().size()); | ||
176 | System.out.println("# of generated Graphs: " + map.size()); | ||
177 | long fn = 0; | ||
178 | long tp = 0; | ||
179 | long fp = 0; | ||
180 | for (int i = 0; i < graphs.size() - 1; i++) { | ||
181 | Graph g1 = graphs.get(i); | ||
182 | boolean[][] refAdj = Utils.adjacencyMatrix(g1, g1.getNodeOrdering()); | ||
183 | for (int j = i + 1; j < graphs.size(); j++) { | ||
184 | Graph g2 = graphs.get(j); | ||
185 | boolean equal = bruteForceIsomorphismCheck(refAdj, g2); | ||
186 | Object code = map.get(g1); | ||
187 | boolean proposed = map.get(g1).equals(map.get(g2)) && map.get(g1).hashCode() == map.get(g2).hashCode(); | ||
188 | if(equal && !proposed) { | ||
189 | fn++; | ||
190 | } else if(equal && proposed) { | ||
191 | tp++; | ||
192 | } else if (!equal & proposed) { | ||
193 | fp++; | ||
194 | } | ||
195 | } | ||
196 | |||
197 | } | ||
198 | |||
199 | |||
200 | System.out.println("True Positives:" + tp); | ||
201 | System.out.println("False Negatives: " + fn); | ||
202 | System.out.println("False Positives: " + fp); | ||
203 | System.out.println("Precision: " + (double)tp/(tp + fp)); | ||
204 | System.out.println("Recall: " + (double)tp / (tp + fn)); | ||
205 | |||
206 | if (fn > 0 ||fp > 0) { | ||
207 | fail(); | ||
208 | } | ||
209 | } | ||
210 | |||
211 | static void testProgress(int all, int now) { | ||
212 | final int MAX_PIPE_CHAR = 10; | ||
213 | float num = now * MAX_PIPE_CHAR * 1.01f; // 1.01f to account for any round off | ||
214 | int current = (int) (num / all); | ||
215 | int rest = MAX_PIPE_CHAR - current; | ||
216 | |||
217 | System.out.print("\r["); | ||
218 | for (int a = 1; a <= current; a++) { | ||
219 | System.out.print("|"); | ||
220 | } | ||
221 | for (int b = 1; b <= rest; b++) { | ||
222 | System.out.print(" "); | ||
223 | } | ||
224 | System.out.print("]"); | ||
225 | |||
226 | } | ||
227 | |||
228 | private void permute(List<Node> nodes, int l, int r, List<List<Node>> result) | ||
229 | { | ||
230 | if (l == r) | ||
231 | result.add(new ArrayList<>(nodes)); | ||
232 | else | ||
233 | { | ||
234 | for (int i = l; i <= r; i++) | ||
235 | { | ||
236 | swap(nodes,l,i); | ||
237 | permute(nodes, l+1, r, result); | ||
238 | swap(nodes,l,i); | ||
239 | } | ||
240 | } | ||
241 | } | ||
242 | |||
243 | private void swap(List<Node> list, int l, int r) { | ||
244 | Node temp = list.get(l); | ||
245 | list.set(l, list.get(r)); | ||
246 | list.set(r, temp); | ||
247 | } | ||
248 | |||
249 | private boolean bruteForceIsomorphismCheck(boolean[][] refAdj, Graph graph2) { | ||
250 | List<List<Node>> allPerms = new ArrayList<>(); | ||
251 | permute(graph2.getNodeOrdering(), 0, graph2.getNodeOrdering().size() - 1, allPerms); | ||
252 | |||
253 | for (List<Node> ordering : allPerms) { | ||
254 | if (Arrays.deepEquals(refAdj, Utils.adjacencyMatrix(graph2, ordering))) { | ||
255 | return true; | ||
256 | } | ||
257 | } | ||
258 | |||
259 | return false; | ||
260 | } | ||
261 | |||
262 | private String adjacencyMatrix2String(boolean[][] adj) { | ||
263 | StringBuilder sb = new StringBuilder(); | ||
264 | for (int i = 0; i < adj.length; i++) { | ||
265 | for (int j = 0; j < adj[i].length; j++) { | ||
266 | sb.append(adj[i][j]).append(" "); | ||
267 | } | ||
268 | sb.append("\n"); | ||
269 | } | ||
270 | |||
271 | return sb.toString(); | ||
272 | } | ||
273 | |||
274 | @Test | ||
275 | public void testUniqueStateCodes_4_Directed_SelfLoop() { | ||
276 | int size = 4; | ||
277 | GraphPermutation permutation = new GraphPermutation(true, true); | ||
278 | Set<Object> set = new HashSet<>(permutation.permuteStateCode(size, new Encoder(new Encoder.HashCertificatePropagator(), new AdjacencyStateCode(10)))); | ||
279 | System.out.println(set.size()); | ||
280 | //assertEquals(34, set.size()); | ||
281 | } | ||
282 | |||
283 | @Test | ||
284 | public void testUniqueStateCodes() { | ||
285 | int size = 5; | ||
286 | GraphPermutation permutation = new GraphPermutation(false, false); | ||
287 | Set<Object> set = new HashSet<>(permutation.permuteStateCode(size, new Encoder(new Encoder.HashCertificatePropagator(), new ArrayStateCode()))); | ||
288 | |||
289 | assertEquals(34, set.size()); | ||
290 | } | ||
291 | |||
292 | @Test | ||
293 | public void testPermutation() { | ||
294 | int size = 5; | ||
295 | assertEquals(1 << 10, (new GraphPermutation(false, false)).permuteGraphSize(size)); | ||
296 | assertEquals(1 << 20, (new GraphPermutation(false, true)).permuteGraphSize(size)); | ||
297 | assertEquals(1 << 15, (new GraphPermutation(true, false)).permuteGraphSize(size)); | ||
298 | assertEquals(1 << 25, (new GraphPermutation(true, true)).permuteGraphSize(size)); | ||
299 | } | ||
300 | |||
301 | } | ||
diff --git a/org.eclipse.viatra.coding/src/test/java/org/eclipse/viatra/coding/PreliminaryTest.java b/org.eclipse.viatra.coding/src/test/java/org/eclipse/viatra/coding/PreliminaryTest.java new file mode 100644 index 00000000..7e0fb409 --- /dev/null +++ b/org.eclipse.viatra.coding/src/test/java/org/eclipse/viatra/coding/PreliminaryTest.java | |||
@@ -0,0 +1,85 @@ | |||
1 | package org.eclipse.viatra.coding; | ||
2 | |||
3 | import org.junit.Before; | ||
4 | import org.junit.Test; | ||
5 | |||
6 | import java.util.*; | ||
7 | |||
8 | import static org.junit.Assert.*; | ||
9 | |||
10 | public class PreliminaryTest { | ||
11 | Graph graph; | ||
12 | Graph isomorphicGraph; | ||
13 | |||
14 | @Before | ||
15 | public void setup(){ | ||
16 | List<String> nodeLabels = Collections.singletonList("1"); | ||
17 | List<String> edgeLabels = Arrays.asList("a", "b"); | ||
18 | |||
19 | graph = new Graph(nodeLabels, edgeLabels); | ||
20 | List<Node> nodes = new ArrayList<>(); | ||
21 | for (int i = 0; i < 5; i++) { | ||
22 | nodes.add(new Node(Integer.toString(i))); | ||
23 | graph.addNode(nodes.get(i), "1"); | ||
24 | } | ||
25 | |||
26 | graph.addEdge(nodes.get(4), nodes.get(3), "a"); | ||
27 | graph.addEdge(nodes.get(3), nodes.get(1), "b"); | ||
28 | graph.addEdge(nodes.get(2), nodes.get(4), "b"); | ||
29 | graph.addEdge(nodes.get(1), nodes.get(2), "a"); | ||
30 | graph.addEdge(nodes.get(1), nodes.get(0), "a"); | ||
31 | graph.addEdge(nodes.get(0), nodes.get(4), "b"); | ||
32 | |||
33 | isomorphicGraph = new Graph(nodeLabels, edgeLabels); | ||
34 | nodes = new ArrayList<>(); | ||
35 | for (int i = 1; i <= 5; i++) { | ||
36 | nodes.add(new Node(Integer.toString(i))); | ||
37 | isomorphicGraph.addNode(nodes.get(i - 1), "1"); | ||
38 | } | ||
39 | isomorphicGraph.addEdge(nodes.get(3), nodes.get(4), "a"); | ||
40 | isomorphicGraph.addEdge(nodes.get(1), nodes.get(3), "b"); | ||
41 | isomorphicGraph.addEdge(nodes.get(3), nodes.get(2), "a"); | ||
42 | isomorphicGraph.addEdge(nodes.get(2), nodes.get(0), "b"); | ||
43 | isomorphicGraph.addEdge(nodes.get(4), nodes.get(0), "b"); | ||
44 | isomorphicGraph.addEdge(nodes.get(0), nodes.get(1), "a"); | ||
45 | } | ||
46 | |||
47 | @Test | ||
48 | public void testEncoding() { | ||
49 | assertNotNull(graph); | ||
50 | Encoder e = new Encoder(new Encoder.NativeHashCertificatePropagator(), new AdjacencyStateCode(10)); | ||
51 | Object value = e.encode(graph); | ||
52 | Object isomorphicValue = e.encode(isomorphicGraph); | ||
53 | assertEquals(value.hashCode(), isomorphicValue.hashCode()); | ||
54 | assertEquals(value, isomorphicValue); | ||
55 | // assertEquals(1618256179, value.hashCode()); | ||
56 | } | ||
57 | |||
58 | @Test | ||
59 | public void adjacencyMatrixTest() { | ||
60 | List<String> nodeLabel = Collections.singletonList("node"); | ||
61 | List<String> edgeLabel = Collections.singletonList("edge"); | ||
62 | graph = new Graph(nodeLabel, edgeLabel); | ||
63 | List<Node> nodes = new ArrayList<>(); | ||
64 | for (int i = 0; i < 4; i++) { | ||
65 | nodes.add(new Node()); | ||
66 | graph.addNode(nodes.get(i), nodeLabel.get(0)); | ||
67 | } | ||
68 | |||
69 | // for (Node from : nodes) { | ||
70 | // for (Node to : nodes) { | ||
71 | // graph.addEdge(from ,to, edgeLabel.get(0)); | ||
72 | // } | ||
73 | // } | ||
74 | |||
75 | graph.addEdge(nodes.get(0), nodes.get(1), edgeLabel.get(0)); | ||
76 | graph.addEdge(nodes.get(0), nodes.get(0), edgeLabel.get(0)); | ||
77 | graph.addEdge(nodes.get(0), nodes.get(2), edgeLabel.get(0)); | ||
78 | graph.addEdge(nodes.get(2), nodes.get(3), edgeLabel.get(0)); | ||
79 | |||
80 | |||
81 | boolean[][] adj = Utils.adjacencyMatrix(graph, nodes); | ||
82 | System.out.println(Arrays.deepToString(adj)); | ||
83 | } | ||
84 | |||
85 | } | ||
diff --git a/org.eclipse.viatra.coding/src/test/java/org/eclipse/viatra/coding/TestAdjacencyStateCode.java b/org.eclipse.viatra.coding/src/test/java/org/eclipse/viatra/coding/TestAdjacencyStateCode.java new file mode 100644 index 00000000..5bd29984 --- /dev/null +++ b/org.eclipse.viatra.coding/src/test/java/org/eclipse/viatra/coding/TestAdjacencyStateCode.java | |||
@@ -0,0 +1,40 @@ | |||
1 | package org.eclipse.viatra.coding; | ||
2 | |||
3 | import org.junit.Before; | ||
4 | import org.junit.Test; | ||
5 | |||
6 | import java.util.ArrayList; | ||
7 | import java.util.Arrays; | ||
8 | import java.util.Collections; | ||
9 | import java.util.List; | ||
10 | |||
11 | public class TestAdjacencyStateCode { | ||
12 | Graph graph; | ||
13 | |||
14 | @Before | ||
15 | public void setup(){ | ||
16 | List<String> nodeLabels = Collections.singletonList("1"); | ||
17 | List<String> edgeLabels = Arrays.asList("a", "b"); | ||
18 | |||
19 | graph = new Graph(nodeLabels, edgeLabels); | ||
20 | List<Node> nodes = new ArrayList<>(); | ||
21 | for (int i = 0; i < 5; i++) { | ||
22 | nodes.add(new Node(Integer.toString(i))); | ||
23 | graph.addNode(nodes.get(i), "1"); | ||
24 | } | ||
25 | |||
26 | graph.addEdge(nodes.get(4), nodes.get(3), "a"); | ||
27 | graph.addEdge(nodes.get(3), nodes.get(1), "b"); | ||
28 | graph.addEdge(nodes.get(2), nodes.get(4), "b"); | ||
29 | graph.addEdge(nodes.get(1), nodes.get(2), "a"); | ||
30 | graph.addEdge(nodes.get(1), nodes.get(0), "a"); | ||
31 | graph.addEdge(nodes.get(0), nodes.get(4), "b"); | ||
32 | } | ||
33 | |||
34 | @Test | ||
35 | public void testAdjacencyStateCode () { | ||
36 | Encoder encoder = new Encoder(new AdjacencyStateCode(10)); | ||
37 | AdjacencyStateCode adj = (AdjacencyStateCode) encoder.encode(graph); | ||
38 | System.out.println(adj.toString()); | ||
39 | } | ||
40 | } | ||
diff --git a/org.eclipse.viatra.coding/src/test/java/org/eclipse/viatra/coding/helper/GraphPermutation.java b/org.eclipse.viatra.coding/src/test/java/org/eclipse/viatra/coding/helper/GraphPermutation.java new file mode 100644 index 00000000..588a7719 --- /dev/null +++ b/org.eclipse.viatra.coding/src/test/java/org/eclipse/viatra/coding/helper/GraphPermutation.java | |||
@@ -0,0 +1,124 @@ | |||
1 | package org.eclipse.viatra.coding.helper; | ||
2 | |||
3 | import org.eclipse.viatra.coding.*; | ||
4 | |||
5 | import java.util.ArrayList; | ||
6 | import java.util.Collections; | ||
7 | import java.util.List; | ||
8 | import java.util.concurrent.atomic.AtomicInteger; | ||
9 | import java.util.function.Consumer; | ||
10 | |||
11 | /** | ||
12 | * generate all the graph with certain number of nodes by permute the edges, | ||
13 | * currently only support one edge type and one node type | ||
14 | */ | ||
15 | public class GraphPermutation { | ||
16 | private final static String NODE_TYPE = "node"; | ||
17 | private final static String EDGE_TYPE = "edge"; | ||
18 | private boolean allowSelfLoop; | ||
19 | private boolean isDirectional; | ||
20 | |||
21 | public GraphPermutation() { | ||
22 | allowSelfLoop = false; | ||
23 | isDirectional = false; | ||
24 | } | ||
25 | |||
26 | public GraphPermutation(boolean allowSelfLoop, boolean isDirectional) { | ||
27 | this.allowSelfLoop = allowSelfLoop; | ||
28 | this.isDirectional = isDirectional; | ||
29 | } | ||
30 | |||
31 | public boolean isAllowSelfLoop() { | ||
32 | return allowSelfLoop; | ||
33 | } | ||
34 | |||
35 | public void setAllowSelfLoop(boolean allowSelfLoop) { | ||
36 | this.allowSelfLoop = allowSelfLoop; | ||
37 | } | ||
38 | |||
39 | public boolean isDirectional() { | ||
40 | return isDirectional; | ||
41 | } | ||
42 | |||
43 | public void setDirectional(boolean directional) { | ||
44 | isDirectional = directional; | ||
45 | } | ||
46 | |||
47 | public List<Graph> permuteGraph(int n) { | ||
48 | List<Graph> graphs = new ArrayList<>(); | ||
49 | permute(n, g -> graphs.add(new Graph(g))); | ||
50 | return graphs; | ||
51 | } | ||
52 | |||
53 | public List<Object> permuteStateCode(int n, Encoder encoder) { | ||
54 | List<Object> stateCodes = new ArrayList<>(); | ||
55 | permute(n, g -> stateCodes.add(encoder.encode(g))); | ||
56 | return stateCodes; | ||
57 | } | ||
58 | |||
59 | public int permuteGraphSize(int n) { | ||
60 | AtomicInteger num = new AtomicInteger(); | ||
61 | permute(n, g -> num.addAndGet(1)); | ||
62 | return num.get(); | ||
63 | } | ||
64 | |||
65 | public void permute(int n, Consumer<Graph> processor) { | ||
66 | Graph graph = prepareGraph(n); | ||
67 | List<Node> nodes = new ArrayList<>(graph.getLabelNodes().get(NODE_TYPE)); | ||
68 | assert nodes.size() == n; | ||
69 | int startingTgt = allowSelfLoop? 0 : 1; | ||
70 | recursiveGraphPermutation(graph, nodes, 0, startingTgt, EDGE_TYPE, processor); | ||
71 | } | ||
72 | |||
73 | private Graph prepareGraph(int n) { | ||
74 | List<String> nodeLabels = Collections.singletonList(NODE_TYPE); | ||
75 | List<String> edgeLabels = Collections.singletonList(EDGE_TYPE); | ||
76 | Graph graph = new Graph(nodeLabels, edgeLabels); | ||
77 | |||
78 | for (int i = 0; i < n; i++) { | ||
79 | graph.addNode(new Node(Integer.toString(i)), NODE_TYPE); | ||
80 | } | ||
81 | |||
82 | return graph; | ||
83 | } | ||
84 | |||
85 | private void recursiveGraphPermutation(Graph graph, List<Node> nodes, int src, int tgt, String edgeType, Consumer<Graph> processNewFoundGraph) { | ||
86 | if (src >= nodes.size()) { | ||
87 | processNewFoundGraph.accept(graph); | ||
88 | return; | ||
89 | } | ||
90 | |||
91 | if (tgt >= nodes.size()) { | ||
92 | if (!isDirectional) { | ||
93 | recursiveGraphPermutation(graph, nodes, src + 1, src + 1, edgeType, processNewFoundGraph); | ||
94 | } else { | ||
95 | recursiveGraphPermutation(graph, nodes, src + 1, 0, edgeType, processNewFoundGraph); | ||
96 | } | ||
97 | |||
98 | return; | ||
99 | } | ||
100 | |||
101 | // recurse without this edge | ||
102 | recursiveGraphPermutation(graph, nodes, src, tgt + 1, edgeType, processNewFoundGraph); | ||
103 | |||
104 | //add the edge and recurse with the edge | ||
105 | // no self loop check | ||
106 | if (allowSelfLoop || src != tgt) { | ||
107 | graph.addEdge(nodes.get(src), nodes.get(tgt), edgeType); | ||
108 | |||
109 | // if not direction, add both directions | ||
110 | if (!isDirectional) { | ||
111 | graph.addEdge(nodes.get(tgt), nodes.get(src), edgeType); | ||
112 | } | ||
113 | |||
114 | recursiveGraphPermutation(graph, nodes, src, tgt + 1, edgeType, processNewFoundGraph); | ||
115 | graph.removeEdge(nodes.get(src), nodes.get(tgt), edgeType); | ||
116 | |||
117 | // if not direction, remove both directions | ||
118 | if (!isDirectional) { | ||
119 | graph.removeEdge(nodes.get(tgt), nodes.get(src), edgeType); | ||
120 | } | ||
121 | } | ||
122 | } | ||
123 | |||
124 | } | ||