Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions core/src/main/scala/org/graphframes/pattern/patterns.scala
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,14 @@ private[graphframes] object Pattern {
case reversedEdge(negation, dst, edge, src) =>
s"$negation($src)-[$edge]->($dst)"
case bidirectionalEdge(negation, src, edge, dst) =>
if (!negation.isEmpty) {
throw new InvalidParseException(
s"Motif finding does not support negated bidirectional edge: '$pattern'.")
}
if (edge.isEmpty || edge.contains("*")) {
s"$negation($src)-[$edge]->($dst);($dst)-[$edge]->($src)"
s"($src)-[$edge]->($dst);($dst)-[$edge]->($src)"
} else {
s"$negation($src)-[${edge}1]->($dst);($dst)-[${edge}2]->($src)"
s"($src)-[${edge}1]->($dst);($dst)-[${edge}2]->($src)"
}
case original => original
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ class PatternSuite extends SparkFunSuite {
Pattern.parse("(a)-[e]->(b); ()-[e]->()")
}
}
withClue("Failed to catch parse error with not support negated bidirectional edge") {
intercept[InvalidParseException] {
Pattern.parse("!(u)<-[]->(v)")
}
}
}

test("unsupported parse on the fixed length patterns") {
Expand Down
2 changes: 1 addition & 1 deletion docs/src/04-user-guide/04-motif-finding.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Restrictions:

* Motifs are not allowed to contain edges without any named elements: `"()-[]->()"` and `"!()-[]->()"` are prohibited terms.
* Motifs are not allowed to contain named edges within negated terms (since these named edges would never appear within results). E.g., `"!(a)-[ab]->(b)"` is invalid, but `"!(a)-[]->(b)"` is valid.
* Negation is not supported for the variable-length pattern and undirected pattern: `"!(a)-[*1..3]->(b)"` and `"!(a)-[]-(b)"` are not allowed.
* Negation is not supported for the variable-length pattern, bidirectional pattern and undirected pattern: `"!(a)-[*1..3]->(b)"`, `"!(a)<-[]->(b)"` and `"!(a)-[]-(b)"` are not allowed.
* Unbounded length patten is not supported: `"(a)-[*..3]->(b)"` and `"(a)-[*1..]->(b)"` are not allowed.
* You cannot join additional edges with the variable length pattern: `"(a)-[*1..3]-(b);(b)-[]-(c)"`is not valid.

Expand Down