Package dev.roanh.gmark.conjunct.cpq
Interface CPQ
- All Known Implementing Classes:
ConcatCPQ
,EdgeCPQ
,IdentityCPQ
,IntersectionCPQ
Interface for conjunctive path queries (CPQs).
- See Also:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault QueryGraphCPQ
Computes and returns the core of the query graph for this CPQ.static CPQ
Returns a CPQ representing the concatenation in order of the given CPQs.static CPQ
Returns a CPQ representing the concatenation in order of the given CPQs.static CPQ
generateRandomCPQ
(int ruleApplications, int labels) Generates a random CPQ created by applying the intersection (conjunction) and concatenation steps from the CPQ grammar the given number of times.int
Returns the diameter of this CPQ.static CPQ
id()
Returns the identity CPQ.static CPQ
Returns a CPQ representing the intersection of the given CPQs from left to right.static CPQ
Returns a CPQ representing the intersection (conjunction) of the two given single edge label traversals.static CPQ
Returns a CPQ representing the intersection of the given CPQs from left to right.default boolean
isHomomorphicTo
(CPQ other) Tests if the query graph for this CPQ is homomorphic to the query graph for the given other CPQ.boolean
isLoop()
Tests if this CPQ is a loop, meaning its source and target are the same.static CPQ
Returns a CPQ representing a single labelled edge traversal.static CPQ
Returns a CPQ representing a chain of labelled edge traversals.static CPQ
Returns a CPQ representing a chain of labelled edge traversals.static CPQ
Parses the given CPQ in string form to a CPQ instance.default QueryGraphCPQ
Computes and returns the query graph for this CPQ.toQueryGraph
(QueryGraphCPQ.Vertex source, QueryGraphCPQ.Vertex target) Computes and returns the query graph for this CPQ using the given source and target vertices for the computation.
-
Field Details
-
CHAR_CAP
static final char CHAR_CAPThe character used to denote the intersection/conjunction operator.- See Also:
-
CHAR_JOIN
static final char CHAR_JOINThe character used to denote the join/concatenation operator.- See Also:
-
IDENTITY
Constant for the special identity CPQ.
-
-
Method Details
-
toQueryGraph
Computes and returns the query graph for this CPQ.- Returns:
- The query graph for this CPQ.
- See Also:
-
computeCore
Computes and returns the core of the query graph for this CPQ.- Returns:
- The core of this CPQ.
- See Also:
-
isHomomorphicTo
Tests if the query graph for this CPQ is homomorphic to the query graph for the given other CPQ.- Parameters:
other
- The other CPQ to test against.- Returns:
- True if this CPQ is homorphic to the other CPQ.
- See Also:
-
toQueryGraph
Computes and returns the query graph for this CPQ using the given source and target vertices for the computation. Usually usingtoQueryGraph()
instead should be sufficient for most use cases, using this version instead can lead to unexpected results.- Parameters:
source
- The source vertex to use.target
- The target vertex to use.- Returns:
- The query graph for this CPQ.
- See Also:
-
getDiameter
int getDiameter()Returns the diameter of this CPQ. The diameter of a CPQ is the largest number of labels to which the join operation is applied. A simpler way to think of this concept is the length of the largest path through the CPQ from source to target.- Returns:
- The diameter of this CPQ.
-
isLoop
boolean isLoop()Tests if this CPQ is a loop, meaning its source and target are the same. When visualised as a query graph this means that the source and target node are the same node. In its grammar form this means that there is an intersection with identity at the highest level in the CPQ.- Returns:
- True if this CPQ is a loop.
- See Also:
-
id
Returns the identity CPQ.- Returns:
- The identity CPQ.
- See Also:
-
intersect
Returns a CPQ representing the intersection (conjunction) of the two given single edge label traversals.- Parameters:
predicates
- The labels to traverse.- Returns:
- The intersection of the given label traversals.
- Throws:
IllegalArgumentException
- When less than 2 predicates are provided.
-
intersect
Returns a CPQ representing the intersection of the given CPQs from left to right. For example((q1 ∩ q2) ∩ q3)
.- Parameters:
cpqs
- The CPQs to intersect.- Returns:
- The intersection of the given CPQs.
- Throws:
IllegalArgumentException
- When less than 2 CPQs are provided.
-
intersect
Returns a CPQ representing the intersection of the given CPQs from left to right. For example((q1 ∩ q2) ∩ q3)
. Note that the given list is not copied.- Parameters:
cpqs
- The CPQs to intersect.- Returns:
- The intersection of the given CPQs.
- Throws:
IllegalArgumentException
- When less than 2 CPQs are provided.
-
concat
Returns a CPQ representing the concatenation in order of the given CPQs.- Parameters:
cpqs
- The CPQs to concatenate (in order).- Returns:
- The concatenation of the given CPQs.
- Throws:
IllegalArgumentException
- When the given list of CPQs is empty.
-
concat
Returns a CPQ representing the concatenation in order of the given CPQs. Note that the given list is not copied.- Parameters:
cpqs
- The CPQs to concatenate (in order).- Returns:
- The concatenation of the given CPQs.
- Throws:
IllegalArgumentException
- When the given list of CPQs is empty.
-
label
Returns a CPQ representing a single labelled edge traversal.- Parameters:
label
- The label of the traversed edge.- Returns:
- The label traversal CPQ.
-
labels
Returns a CPQ representing a chain of labelled edge traversals.- Parameters:
labels
- The labels of the traversed edges.- Returns:
- The label traversal CPQ.
-
labels
Returns a CPQ representing a chain of labelled edge traversals.- Parameters:
labels
- The labels of the traversed edges.- Returns:
- The label traversal CPQ.
-
generateRandomCPQ
Generates a random CPQ created by applying the intersection (conjunction) and concatenation steps from the CPQ grammar the given number of times. A set of labels of the given size is automatically generated together with corresponding inverse labels for each label. Three relatively meaningless but technically valid patterns are intentionally never generated:- Concatenation with identity.
- Intersection of identity with identity.
- The query consisting of only identity and nothing else.
- Parameters:
ruleApplications
- The number of times the intersection and concatenation steps are allowed to be applied.labels
- The number of distinct labels to use (upper limit).- Returns:
- The randomly generated CPQ.
- Throws:
IllegalArgumentException
- When the list of labels is empty.- See Also:
-
parse
Parses the given CPQ in string form to a CPQ instance. The input is assumed to use brackets where possible and to use the 'id
', ''\u25e6'', ''\u2229'' and ''\u207b'' symbols to denote operations. Example input:(0◦(((1◦0) ∩ (1◦1))◦1⁻))
.- Parameters:
query
- The CPQ to parse.- Returns:
- The parsed CPQ.
- Throws:
IllegalArgumentException
- When the given string is not a valid CPQ.- See Also:
-