public class Rule extends NamedObject implements java.lang.Cloneable
Modifier and Type | Field and Description |
---|---|
protected TransformationParams |
params |
Constructor and Description |
---|
Rule(Morphism corr)
Constructs a new rule.
|
Rule(Morphism corr,
TransformationParams params)
Constructs a new rule with given transformation parameters.
|
Modifier and Type | Method and Description |
---|---|
Transition |
applyToMatch(Morphism match)
Applies this rule to a graph with respect to a match.
|
protected boolean |
checkMatch(Morphism m)
Determines if a given match satisfies additional application conditions
for this rule.
|
Rule |
clone() |
int |
countUniqueEdges()
Counts the number of unique edges in this rule.
|
int |
countUniqueNodes()
Counts the number of unique nodes in this rule.
|
Morphism |
getCorrespondence()
Returns the correspondence morphism of this rule.
|
Graph |
getLeft()
Returns the left-hand side of this rule.
|
java.util.Collection<Morphism> |
getMatches(Graph graph)
Returns a collection of matches of this rule to a given graph.
|
Graph |
getRight()
Returns the right-hand side of this rule.
|
de.uni_due.inf.ti.util.Pair<Morphism,Morphism> |
getRuleIsomorphism(Rule other)
Returns a rule isomorphism between this rule and another given rule.
|
java.util.Set<Label> |
getSignature()
Returns the signature of this rule.
|
TransformationParams |
getTransformationParams()
Returns the transformation parameters used by this rule.
|
boolean |
isConflictFree(Morphism match)
Determines whether a match is conflict-free with respect to this rule.
|
boolean |
isIsomorphic(Rule other)
Determines whether this rule is isomorphic to another rule.
|
boolean |
satisfiesDanglingEdgeCondition(Morphism match)
Determines if a morphism satisfies the dangling edge condition
with respect to this rule.
|
void |
setTransformationParams(TransformationParams params)
Sets the transformation parameters for this rule.
|
java.lang.String |
toString()
Returns a string representation of this Rule.
|
java.lang.String |
toString(java.lang.String indent)
Returns a string representation of this Rule with a user-defined
indentation string.
|
protected java.lang.String |
toString(java.lang.String indent,
java.lang.String sub)
Returns a string representation of this Rule with a user-defined
indentation string and a subclass-defined information string.
|
getName, hasName, setName
getAttribute, setAttribute
protected TransformationParams params
public Rule(Morphism corr, TransformationParams params)
Currently, only injective correspondence morphisms are supported.
corr
- correspondence morphism of the new rulepublic Rule(Morphism corr)
Currently, only injective correspondence morphisms are supported.
corr
- correspondence morphism of the new rulepublic Rule clone()
clone
in class java.lang.Object
public final Graph getLeft()
public final Graph getRight()
public final Morphism getCorrespondence()
public java.util.Collection<Morphism> getMatches(Graph graph)
public final Transition applyToMatch(Morphism match)
If it is not possible to apply this rule to the source graph over the
given match (for example because dangling edge conditions are not
satisfied) this method returns null
.
match
- the match with respect to which a rewriting step is performednull
if a transition is not possiblejava.lang.IllegalArgumentException
- if match
is not a total morphism, or if
match.getDomain() != this.getLeft()
public boolean satisfiesDanglingEdgeCondition(Morphism match)
match
- the match of which it is to be determined, if it satisfies the
dangling edge conditiontrue
if match
satisfies the dangling edge
conditionpublic boolean isConflictFree(Morphism match)
Conflict-freeness corresponds to the identification condition in double-pushout graph transformation.
Although match
is not required to be a total morphism, in
most practical situations match
should be total.
match
- the match of which it is to be determined whether or not it is
conflict freetrue
if match
is conflict-free with respect to this
rule, false
otherwisepublic de.uni_due.inf.ti.util.Pair<Morphism,Morphism> getRuleIsomorphism(Rule other)
The returned object is a pair of isomorphisms which have this rule's
left-hand and right-hand sides as domain, and the other rules left- and
right-hand sides as codomain. The returned object's getFirst()
morphism is an isomorphism between the left-hand sides, while its
getSecond()
morphism is an isomorphism between the right-hand
sides.
If the two rules are not isomorphic, null
is returned.
other
- the target rule of the returned isomorphismsnull
if these do not existpublic boolean isIsomorphic(Rule other)
r1.isIsomorphic(r2)
is equivalent to testing
r1.getRuleIsomorphism(r2) != null
.other
- the rule to test whether it is isomorphic to this ruletrue
if this rule is isomorphic to the rule other
,
false
otherwiseBaseRule#getRuleIsomorphism(BaseRule)
protected boolean checkMatch(Morphism m)
The default implementation always returns true
. Subclasses may
override this method if not every match from the left hand side into
the source graph should result in a rewriting step because additional
(negative) application conditions need to be satisfied.
m
- the match to checktrue
if m
satisfies all application conditions for
this rulepublic final TransformationParams getTransformationParams()
public final void setTransformationParams(TransformationParams params)
params
- new transformation parameters of this rulepublic java.util.Set<Label> getSignature()
The returned set is unmodifiable.
public int countUniqueNodes()
Subclasses may override this method so that also other nodes are counted (for example nodes in negative application conditions).
public int countUniqueEdges()
Subclasses may override this method so that also other edges are counted (for example edges in negative application conditions).
protected java.lang.String toString(java.lang.String indent, java.lang.String sub)
The subclass defined information string must do its own formatting;
in particular, it should respect the indentation (the subclass can
assume that the string is printed in the first column). The string
sub
should end with a carriage return.
indent
- indentation string which is inserted before each line of the string
representationsub
- string created by the subclass to represents its datapublic java.lang.String toString(java.lang.String indent)
indent
- string which is displayed to the left of each line of the string
representationpublic java.lang.String toString()
toString("")
.toString
in class java.lang.Object