Rocs in a Nutshell

In this section we provide a compact overview of the core elements of Rocs. We explain the important notions of data structures, data structure backends, and element types. Understanding of these concepts is useful to understand how data structures can be created and modified in Rocs.

In general Rocs works with projects: when opening Rocs an empty project is created and you can replace it by loading or importing another project. Hereby, a project itself consists of graph documents and scripts.

Graph Documents and Data Structure Backends

A graph document represents the content of a whiteboard in the visual graph editor. Hereby, a graph document can contain several data structures at once, but only one data structure backends. Data structure backends are present for several graph types (general graphs, linked lists, rooted trees) and provide for their specific graph types additional functionality. That can be automatic positioning of the elements, special icon sets, or an extended set of script functions for use in your algorithms. (for details look at the corresponding handbook section). It is possible to change the data structure backend of a graph document, though information can be lost (e.g., edges of a circle in a general graph won't be added to a tree, if you switch to the rooted tree backend).

Graph documents form also the base for defining pointer types and data types.

Data Structures

Data structures are the base of all work in Rocs. You can add one or several of them to a graph document, add data elements (nodes, datums) and pointers to them, and modify them by scripts. For this, each data structure has its unique name by which it can be accessed from your scripts. Due to your choice of the current data structure backend it can happen that you cannot modify the data structures arbitrarily (e.g., a tree should never contain a cycle). The data structure backend is determined by the data structure backend associated with the corresponding graph document that contains the data structure.

Pointer Types

By pointer types you can define different types of pointers to be used in your data structures. This is, a pointer type can get an individual layout (essentially a color) and it is easy to access only pointers of a specific type from your scripts. Typical use cases for pointers can be to implement meta-edges at your data structures that visualize relationships between data elements (e.g., visualize communication interests). But also, if your scripts shall identify specific kinds of edges (e.g., tree and cross edges at the depth first search algorithm), pointer types can be an elegant way to implement that.

Data Types

In several data structure problems, a set of data elements should be parted into groups of different types (e.g., clustering problems or covering problems). Or it is useful for the execution of an algorithm to specify a data element type to express a specific type (e.g., breath first search). For such use cases you can define data types. Each data type has its own icon and data types of some type can easily be accessed from your scripts.

Dynamic Properties

Every data element and pointer can have many properties. Some of these properties are default from data structure backend. See the documentation of the data structure backend for more details. To add further properties to the data elements and pointers, you can add dynamic properties to them. Each dynamic property is identified by its name and can contain any value associated with it. The name must start with a letter (a-z or A-Z) and can contain only letters, numbers and '_'. If you try to use any invalid character in the property name, the property will not be changed.

To add dynamic properties, use the Data Element Properties and Pointer Properties dialogs from the context menus of the respective elements or the script functions as explained in the section called “Scripting API for every Data Structure”.

You can also use the scripts. You just need to use the add_property with the name and value of your property. After that, you can use node/pointer.propertyName to set/get the values.

Here is an example of how to use dynamic properties with data structure backend "Graph".

nodes = myGraph.list_nodes()
for (var i = 0; i < nodes.length; ++i ){
    nodes[i].add_property("MyProperty", 0)
nodes[0].MyProperty = 2
nodes[1].MyProperty = nodes[0].MyProperty + 2