Built-in functions for manipulating graph elements and accessing metadata.
Vertex & Edge Methods
GSQL provides a rich set of built-in methods to interact with vertices and edges directly.
1. Core Vertex Methods
Invoke these on a vertex variable or alias using the dot (.) operator.
| Method | Description | Return Type |
|---|---|---|
.outdegree() | Returns the count of outgoing edges. | INT |
.getAttr() | Dynamically retrieves an attribute value. | BaseType |
.setAttr() | Dynamically updates an attribute value. | void |
.neighbors() | Returns a collection of immediate neighbors. | BagAccum<VERTEX> |
Performance Tip: outdegree()
outdegree() is extremely fast because it reads from metadata. However, in high-concurrency write environments, it may be slightly delayed. For exact real-time counts, use a manual traversal.
2. Core Edge Methods
Invoke these on an edge alias inside a SELECT statement.
.getAttr(name, type): Retrieves an edge attribute..setAttr(name, value): Updates an edge attribute..isDirected(): Returnstrueif the edge is directed.
3. ID & Conversion Functions
These functions handle the mapping between external (user-facing) IDs and internal (engine) IDs.
getvid(v): Returns the internal numeric ID of a vertex. Useful for algorithms like Community Detection where speed is critical.to_vertex(id, type): Converts a string ID and type into aVERTEXobject.to_vertex_set(id_collection, type): Converts a collection of string IDs into aSET<VERTEX>.
[!CAUTION] Performance Warning:
to_vertexandto_vertex_setare relatively expensive operations. Do not use them insideACCUMorPOST-ACCUMblocks, as they will execute for every edge/vertex, severely impacting performance. Instead, resolve IDs at the start of the query.
4. Metadata Functions
elementId(v/e): Returns a persistent internal string ID..type: Returns the type name of the vertex or edge as a string..neighbors().filter(): Allows inline filtering of neighbor collections without a fullSELECTstatement.
On this page
TigerGraph Book
v1.0 Curated