Library Elements Graph_reachable …

This article explains the usage of the library functions Graph_reachableOfType, Graph_reachableIncomingOfType and Graph_reachableOutgoingOfType. These functions allow the creation of sets of nodes reachable from a specified node, with the specification of the type of the nodes.

Graph_reachableOfType

Syntax

Graph_reachableOfType(NODE_INSTANCE, EDGE_TYPE,ADJACENT_NODE_TYPE,TARGET_NODE_TYPE):NODE_SET

This is a function and needs to be called accordingly in rules, sequences, functions or procedures.

Input Parameters

  • NODE_INSTANCE: Node – node instance.
  • EDGE_TYPE: edgetype – edge class name of the edge class to follow.
  • ADJACENT_NODE_TYPE: nodetype – node class name of nodes which are allowed to be passed.
  • TARGET_NODE_TYPE: nodetype – node class name of the nodes to be included in the set.

Returns

  • NODE_SET: set – a set of nodes (of type Node) that match the specified criteria.

The library function returns a NODE_SET of class Node containing only nodes of the TARGET_NODE_TYPE that can be reached from a start node NODE_INSTANCE following edges of type EDGE_TYPE and passing only nodes of type ADJACENT_NODE_TYPE.

Example

sequence Graph_reachableOfType_demo{
    for{module:Module in nodes(Module);
        Moduleset:set<Node> = set<Node>{} &
        {Moduleset = Graph_reachableOfType(module, HasFlowOfMaterialTo, Module, Module)}
    }
}

This example sequence builds a set for each module node in the graph (class: Module). The set contains all nodes of class Module which are reachable from module by following edges of type HasFlowOfMaterialTo and passing only nodes of type Module.

Graph_reachableIncomingOfType

This function is works in the same way as the function Graph_reachableOfType, but instead of returning all reachable nodes, it returns only the nodes reachable via incoming edges.

Graph_reachableOutgoingOfType

This function is works in the same way as the function Graph_reachableOfType, but instead of returning all reachable nodes, it returns only the nodes reachable via outgoing edges.

Was this article helpful?

Related Articles