User Tools

Site Tools


01_user_documentation:07_rgg_xl:02_xl:08_object:02_pattern:01_inrgg

This is an old revision of the document!


In RGG

Custom patterns can be created in RGG with the simple syntax:

class patternName(@In Node a, @Out Node b) (
    // some patterns
    )

Declaring In/Out

Custom patterns requires to declare variable with both annotations @In and @Out. It can be two different variables, or the same one. E.g.

class patternName(@In Node a, @Out Node b) ( ) // different variables for @In and @Out
class patternName(@In @Out Node a) ( ) // same variable for both @In and @Out

Different In/ Out

In the case when the @In and @Out are different variable, the pattern can only be used as a path pattern. In this case the syntax is -patternName-> (or <-p-, <-p-> for backward and bidirectional). The output of the previous pattern is mapped to the @In and the input of the following pattern is mapped to the @Out variables.

The three cases are:

  1. forward: @In -p-> @Out
  2. backward: @Out <-p- @In
  3. bidirectional: (same as forward i.e.) @In <-p-> @Out

The direction of the pattern only correspond to the @In and @Out mapping, not to the direction of possible edges. For instance, the following custom pattern p matches to the same value as Node < Node :

class p(@In Node a, @Out Node b) ( a < b )
void run()[
 n1:Node -p-> n2:Node ::>; // this matches to n1 < n2
]

Same In/ Out

In the case where both @In and @Out are the same variable, the pattern can be used either as a node pattern or as a path pattern. Thus, the syntax is either Node p Node or Node -p-> Node depending on how the pattern should be resolved.

Using In/Out variables

The variables @In and @Out are required to be declared, but not to be used. For instance:

class p(@In Node a, @Out Node b) ( a > Node ) // the @Out (b) is not used.
class p(@In Node a, @Out Node b) ( Node > b ) // the @In (a) is not used.
class p(@In Node a, @Out Node b) ( a > b ) // both @In and @Out are used.

These three pattern are different

- context - in and out - open ends - custom nodes - combining - node pattern / edge pattern.

Examples

// declaration
class xyzPath(@In Node a, @Out Node b) (
    a -x-> -y-> -z-> b
    )
 
//usage
void rule() [ Node -xyzPath-> Node ==>; ]
01_user_documentation/07_rgg_xl/02_xl/08_object/02_pattern/01_inrgg.1756885933.txt.gz · Last modified: 2025/09/03 09:52 by gaetan