---
title: "Edge Methods"
description: "Methods available to edge aliases in a SELECT statement."
component: "gsql-ref"
version: "4.3"
module: "querying"
html_url: "/gsql-ref/4.3/querying/func/edge-methods"
canonical_url: "https://www.tigergraph.com/docs/gsql-ref/4.3/querying/func/edge-methods"
markdown_url: "https://www.tigergraph.com/docs/gsql-ref/4.3/querying/func/edge-methods.md"
---

[View as HTML](https://www.tigergraph.com/docs/gsql-ref/4.3/querying/func/edge-methods)

# Edge Methods

This page lists all built-in edge functions that are available in the GSQL query language. The functions are divided into two categories.

* Dot-syntax methods  
   * Object-oriented methods that are invoked on an edge or edge alias, invoked using the dot (`.`) operator.
* Edge functions  
   * Functions that return an edge, or take in an edge as its parameter.

## Dot-syntax methods

This section includes object-oriented methods that are invoked on an edge or edge alias, invoked 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 an attribute. This can be a query parameter, constant string, or global string variable. | Base types: `STRING`, `INT`, `UINT,` `DATETIME`, `DOUBLE`, `FLOAT`, `BOOL` Container types follow the format `CONTAINER<TYPE>`, where `CONTAINER` can be `LIST` or `SET` and `TYPE` can be `INT`, `DATETIME`, `DOUBLE`, or `STRING`. Type conversion is supported between numerical values and between `LIST` and `SET` types. For example, an edge with an attribute of type `LIST<INT>` can be retrieved as `SET<DOUBLE>`. |
| `attrType` | The type of the attribute | `STRING` |

#### Example

If we have the following edge:

```text
{
      "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`:

```text
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.

Type conversion is not allowed for `setAttr()`. The input variable types must match the types in the attribute.

#### Return type

No return value.

#### Parameters

| Parameter | Description | Data type |
| --- | --- | --- |
| `attrName` | The name of the attribute. This can be a query parameter, constant string, or global string variable. | `STRING` |
| `attrNewValue` | The new value of the attribute | The type of the attribute. |

#### Example

```gsql
CREATE QUERY setAttrExample(STRING attr){
    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); (1)
}
```

| **1** | Selected edges will have their specified attribute set to `TRUE`. |
| --- | --- |

## Edge functions

This section includes functions that return an edge, or take in an edge as its parameter.

### `elementId()`

#### Syntax

`elementId(e)`

#### Description

Returns an internal string id for a vertex or edge.

This internal ID is not the primary ID which the user assigned when creating the edge. It is guaranteed to remain the same across the same query run, but not across different runs.

> [!NOTE]
> See section on vertex functions for more information on `elementId(VERTEX)`.

#### Return type

`STRING`

#### Parameters

| Parameter | Description | Data type |
| --- | --- | --- |
| `e` | An edge | `EDGE` |

#### Example

```gsql
CREATE QUERY elementId_example () {
  MinAccum<STRING> @@min_id;       //each edge's tentative string id

  Start = {Person.*};
  # Gather a sample element id for demonstration purposes
  S = SELECT src FROM Start:src - (:e) - (:tgt)
      ACCUM
         @@min_id += elementId(e);

  PRINT @@min_id;
}
```

```gsql
GSQL > run query elementId_example()
{
  "version": {
    "edition": "enterprise",
    "api": "v2",
    "schema": 1
  },
  "error": false,
  "message": "",
  "results": [
    {
      "@@min_id": "0-2->207878"
    }
  ]
}
```
