Elementary Global Functions

This article contains elementary global functions in a table. The table below indicates the syntax of the function in the first column and a short explanation of it in the second column. For an introduction to the notation syntax please have a look at this article.

Global functions can be used in rules, sequences, functions and procedures on any ruleset in Soley Studio.

Table of elementary global functions

SyntaxDescription
nodes([NodeClass]):set<NodeClass>Looks for all nodes of class NodeClass and returns a set of nodes of this type
edges([EdgeClass]):set<EdgeClass>Looks for all edges of type EdgeClass and returns a set of edges of this type
source(Edge):NodeLooks for the source node of the edge "Edge" and returns the node
target(Edge):NodeLooks for the target node of the edge "Edge" and returns the node
opposite(Edge,Node):NodeLooks for an edge “Edge” connected to a node “Node” and returns the node on the opposite end of the edge, whether it be source or target
inducedSubgraph(set<Node>):graphCreates a subgraph from a set of nodes. The subgraph contains all edges between these nodes.
definedSubgraph(set<Edge>):graphSets a subgraph from a set of edges. The subgraph contains all nodes between these edges.
equalsAny(graph, set<graph>):booleanReturns a boolean true when a subgraph (first argument) equals any of the subgraphs in the set of subgraphs (second argument). Else it returns false.
equalsAnyStructurally (graph,set<graph>):booleanReturns a boolean true when a subgraph (first argument) equals any of the subgraphs in the set of subgraphs (second argument) structurally. Else it returns false. Structural equality means only the graph structure and element classes are compared but not the attribute values.
copy(graph):graphReturns a copy of the subgraph given as input argument.
copy(container):containerReturns a copy of the container given as input argument, e.g. a set
copy(match<r>):match<r> Returns a copy of the match given as input argument
random():doubleReturns a random double value between 0.0 and 1.0
random(int):intReturns a random int value
nameof(Node/Edge/graph):stringReturns the name of a node, edge or graph as a string
uniqueof(Node/Edge/graph):intReturns the unique id of a node, edge or graph as an integer. Make sure you add the line "node edge unique;" to your metamodel. This will add unique IDs to your graph elements.
nodeByName(string):NodeReturns a node identified by its name as input string
edgeByName(string):EdgeReturns an edge identified by its name as input string
nodeByUnique(int):NodeReturns a node identified by its unique ID as input integer.
edgeByUnique(int):EdgeReturns an edge identified by its unique ID as input integer.
countNodes([NodeClass]):intReturns the number of nodes of class NodeClass as an integer
countEdges([EdgeClass]):intReturns the number of edges of class EdgeClass as an integer
File::import(string):graphImports a (graph) file defined by the filepath given as inout string and returns it as a subgraph
File::exists(string):booleanReturns a boolean value true when a file with the filepath given as input string exists. Else returns boolean false.
Time::now():longReturns the current time in DateTime format as long value.

If you couldn’t find the right function for your needs, have a look at the other articles in this article.

Was this article helpful?

Related Articles