Skip to content

Generator language

telmomenezes edited this page Sep 15, 2014 · 5 revisions

Synthetic generators are expressed in a very simple Lisp-like language. In short, it uses S-Expressions (http://en.wikipedia.org/wiki/S-expression) and prefix notation. So, instead of writing 1 + 1, you write (+ 1 1). Of course, these expression can be nested into things like:

(> $origOutDeg 8.0 
 (AFF $targInDeg 0.0 5.0) $targInDeg)

All values are treated as floating point.

There are 3 types of atomic expressions:

  • Variables
  • Functions
  • Constant values

Variables

Variables are pre-defined and all used to convey local information about origin and target nodes, during the generative process. They are:

  • $origId: Sequential id of the origin node
  • $targId: Sequential id of the target node
  • $origInDeg: In-degree of the origin node (directed networks only)
  • $origOutDeg: Out-degree of the origin node (directed networks only)
  • $targInDeg: In-degree of the target node (directed networks only)
  • $targOutDeg: Out-degree of the target node (directed networks only)
  • $origDeg: Degree of the origin node (undirected networks only)
  • $targDeg: Degree of the target node (undirected networks only)
  • $dist: Simple random-walk distance between nodes, ignores edge direction
  • $dirDist: Direct random-walk distance between nodes (directed networks only)
  • $revDist: Reverse random-walk distance between nodes, transverses edges in the reverse direction (directed networks only)

Functions

  • Basic arithmetic functions: +, -, *, /, EXP, LOG, ABS, ^
  • Comparison: ==, >, <, ZER
  • Affinity: AFF

Examples

(< $targInDeg 3 $targOutDeg $targId)

If target in-degree is less than 3 then return the target out-degree, else return the target id.

The < and == functions have similar semantics. They apply the comparator to the first and second parameters and then return the third parameter if the comparison is true, or the fourth parameter otherwise. The ZER comparator function has one less parameter and works like this:

(ZER $targInDeg $targOutDeg $targId)

If target in-degree is zero then return the target out-degree, else return the target id.

Here's a more nested example, with comparators:

(< $targInDeg
    (+ $targOutDeg $revDist)
  $targOutDeg $targId)

And so on.

Next: [Commands reference](Commands reference)