Edge Methods

This page lists all built-in edge methods that can be accessed by edge aliases using the dot (.) operator.

getAttr()

Syntax

e.getAttr( attrName, attrType )

Description

Returns the value of an attribute of the edge.

Return type

The data type of the attribute itself.

Parameters

Parameter Description Data type

attrName

The name of the attribute.

STRING

attrType

The type of the attribute

STRING

Example

If we have the following edge:

{
      "e_type": "User_Video",
      "directed": false,
      "from_id": "0",
      "from_type": "VidUser",
      "to_id": "2",
      "to_type": "Video",
      "attributes": {
        "rating": 5.2,
        "date_time": 0
}

Assume the alias of the edge is e:

e.getAttr("rating", "DOUBLE") -> 5.2

isDirected()

Syntax

e.isDirected()

Description

Returns a boolean value indicating whether the edge is directed or undirected.

Return type

BOOL

Parameters

None.

setAttr()

Syntax

e.setAttr( attrName, attrNewValue )

Description

Sets an attribute of an edge to a new value.

Return type

No return value.

Parameters

Parameter Description Data type

attrName

The name of the attribute. This argument must be a query parameter.

STRING

attrNewValue

The new value of the attribute

The type of the attribute.

Example

CREATE QUERY setAttrExample(STRING attr){ (1)
    Current = {v_type.*}
    S = SELECT s
            FROM Current:s -(e_type:e) - v_type:t
            WHERE t.attribute1 == "example_value"
            ACCUM e.setAttr(attr, TRUE); (2)
}
1 The first argument of e.setAttr must be a query parameter. Therefore, in this example we are passing a string value in the query parameter attr. The string value should be the name of the attribute you want to call the function with.
2 Selected edges will have their specified attribute set to TRUE.