Skip to content

Commit

Permalink
#36 done with main task
Browse files Browse the repository at this point in the history
  • Loading branch information
hoechp committed May 22, 2017
1 parent d716366 commit eaf0b7e
Show file tree
Hide file tree
Showing 2 changed files with 243 additions and 368 deletions.
65 changes: 38 additions & 27 deletions src/main/java/org/fujaba/graphengine/PatternEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -776,38 +776,43 @@ public static ArrayList<Match> matchPattern(Graph graph, PatternGraph pattern, b
PatternNode currentSubNode = nodeMatchLists.get(0).get(i);
boolean fail = false;

/* ##### also check for edges to self */
for (PatternEdge p: currentSubNode.getPatternEdges()) {
if (p.getTarget() != currentSubNode) {
continue;
}
boolean exists = false;
if (mapping.get(currentSubNode).getEdges(p.getName()) != null) {
exists = mapping.get(currentSubNode).getEdges(p.getName()).contains(mapping.get(currentSubNode));
}
//##### NEW TTC2017 FEATURE:
ArrayList<String> extractedVariableNames = extractVariableNames(p.getName());
if (extractedVariableNames.size() > 0) {
exists = false;
int numberOfEdgesFound = 0;
for (String ttcTestString: mapping.get(currentSubNode).getEdges().keySet()) {
if (mapping.get(currentSubNode).getEdges(ttcTestString).contains(mapping.get(currentSubNode))) {
edgeMatch.put(extractedVariableNames.get(numberOfEdgesFound), "'" + ttcTestString + "'");
++numberOfEdgesFound;
if (numberOfEdgesFound >= extractedVariableNames.size()) {
exists = true;
break;
for (int j = i == 1 ? i - 1 : i; j <= i; ++j) {
/* ##### also check for edges to self */
for (PatternEdge p: nodeMatchLists.get(0).get(j).getPatternEdges()) {
if (p.getAction() == "+" || p.getTarget() != nodeMatchLists.get(0).get(j)) {
continue;
}
boolean exists = false;
if (mapping.get(nodeMatchLists.get(0).get(j)).getEdges(p.getName()) != null) {
exists = mapping.get(nodeMatchLists.get(0).get(j)).getEdges(p.getName()).contains(mapping.get(nodeMatchLists.get(0).get(j)));
}
//##### NEW TTC2017 FEATURE:
ArrayList<String> extractedVariableNames = extractVariableNames(p.getName());
if (extractedVariableNames.size() > 0) {
exists = false;
int numberOfEdgesFound = 0;
for (String ttcTestString: mapping.get(nodeMatchLists.get(0).get(j)).getEdges().keySet()) {
if (mapping.get(nodeMatchLists.get(0).get(j)).getEdges(ttcTestString).contains(mapping.get(nodeMatchLists.get(0).get(j)))) {
edgeMatch.put(extractedVariableNames.get(numberOfEdgesFound), "'" + ttcTestString + "'");
++numberOfEdgesFound;
if (numberOfEdgesFound >= extractedVariableNames.size()) {
// for (String foundEdge: extractedVariableNames) { // TODO ##### remove debug
// System.err.println(foundEdge + " == " + edgeMatch.get(foundEdge));
// }
exists = true;
break;
}
}
}
}
//#####
if (("!=".equals(p.getAction()) && exists) || (!"!=".equals(p.getAction()) && !exists)) {
fail = true; // failure at incoming edge
break;
}
}
//#####
if (("!=".equals(p.getAction()) && exists) || (!"!=".equals(p.getAction()) && !exists)) {
fail = true; // failure at incoming edge
break;
}
/* ##### */
}
/* ##### */

match: for (int j = 0; j < i; ++j) {
if (fail == true) {
Expand Down Expand Up @@ -840,6 +845,9 @@ public static ArrayList<Match> matchPattern(Graph graph, PatternGraph pattern, b
edgeMatch.put(extractedVariableNames.get(numberOfEdgesFound), "'" + ttcTestString + "'");
++numberOfEdgesFound;
if (numberOfEdgesFound >= extractedVariableNames.size()) {
// for (String foundEdge: extractedVariableNames) { // TODO ##### remove debug
// System.err.println(foundEdge + " == " + edgeMatch.get(foundEdge));
// }
exists = true;
break;
}
Expand Down Expand Up @@ -876,6 +884,9 @@ public static ArrayList<Match> matchPattern(Graph graph, PatternGraph pattern, b
edgeMatch.put(extractedVariableNames.get(numberOfEdgesFound), "'" + ttcTestString + "'");
++numberOfEdgesFound;
if (numberOfEdgesFound >= extractedVariableNames.size()) {
// for (String foundEdge: extractedVariableNames) { // TODO ##### remove debug
// System.err.println(foundEdge + " == " + edgeMatch.get(foundEdge));
// }
exists = true;
break;
}
Expand Down
Loading

0 comments on commit eaf0b7e

Please sign in to comment.