Manage Graph Vertices
This page explains various methods for managing vertices, also called nodes, in Macrometa graphs.
Create a Vertex
These instructions provide several methods of creating a new vertex in an existing graph.
- Web Console
- REST API
- CLI
Follow these instructions to create a graph vertex using the GDN console web UI.
Click Data > Graphs.
Click the graph that you want to create a vertex for.
Click an empty space on the canvas, then click the plus sign that appears.
(Optional) In the Create node window, enter the vertex _key. If you do not enter a key, then Macrometa automatically generates one for you.
In the Create node window, select the Collection to add the vertex to.
Click Create.
A new vertex appears on the canvas and a new vertex record appears in the collection that you selected. You can now edit the vertex to add attributes or connect the vertex to other vertices with edges.
Use our interactive API Reference with code generation in 18 programming languages to Create a Vertex.
Use the gdnsl graph vertex create CLI command to create a new graph vertex.
View a Vertex
These instructions provide several methods of viewing a graph vertex.
- Web Console
- REST API
- CLI
Follow these instructions to view a graph vertex using the GDN console web UI.
Click Data > Graphs.
Click the graph that you want to view a vertex for.
Click the vertex that you want to view.
Click Edit (the pencil icon).
Macrometa displays the vertex record associated with the vertex that you clicked.
Use our interactive API Reference with code generation in 18 programming languages to Get (View) a Vertex.
Use the gdnsl graph vertex describe CLI command to view a graph vertex.
Update a Vertex
These instructions provide several methods of updating a graph vertex. Updating means that you to specify which vertex properties to update and leave the rest of the properties unchanged. If you want to update all the properties, then you should Replace a Vertex.
- Web Console
- REST API
- CLI
Follow these instructions to update a graph vertex using the GDN console web UI.
Click Data > Graphs.
Click the graph for which you want to update a vertex.
Click the vertex that you want to update.
Click Edit (the pencil icon).
Macrometa opens the vertex record in an editing window.
Update any information necessary.
Click Save.
Use our interactive API Reference with code generation in 18 programming languages to Update a Vertex.
Use the gdnsl graph vertex update CLI command to update a graph vertex.
Replace a Vertex
These instructions provide several methods of replacing a graph vertex. This command completely overwrites the existing vertex document with a new one, including any properties that were not explicitly included in the new document. In other words, all properties not present in the new document are removed. If you only want to update some of the properties, then you should Update a Vertex.
- Web Console
- REST API
- CLI
Follow these instructions to replace a graph vertex using the GDN console web UI.
Click Data > Graphs.
Click the graph for which you want to replace a vertex.
Click the vertex that you want to replace.
Click Edit (the pencil icon).
Macrometa opens the vertex record in an editing window.
Update any information necessary.
Click Save.
Use our interactive API Reference with code generation in 18 programming languages to Replace a Vertex.
Use the gdnsl graph vertex replace CLI command to replace a graph vertex.
Delete a Vertex
These instructions provide several methods of deleting a vertex from a graph.
- Web Console
- REST API
- CLI
- C8QL
Follow these instructions to delete a graph vertex using the GDN console web UI.
- Log in to your Macrometa account.
- Click Data > Graphs.
- Click the graph for which you want to delete a vertex.
- Click the vertex that you want to delete.
- Click Delete (the trash can icon).
- In the Delete node window, indicate whether you want to delete the edges and then click Delete.
- Macrometa asks you to confirm the deletion. Click Yes.
Use our interactive API Reference with code generation in 18 programming languages to Remove (Delete) a Vertex.
Use the gdnsl graph vertex delete CLI command to delete a graph vertex.
C8QL does not provide a direct method to remove vertices with associated edges. However, you can achieve this using a combination of queries. The examples below demonstrate how to remove a vertex and its associated edges from different graphs.
Remove a Vertex from One Collection
This example, demonstrates how to remove a vertex and its associated edges from a graph. The query removes the vertex eve from this example graph, as well as the edges eve -> alice
and eve -> bob
.
This query deletes eve and its adjacent edges:
LET edgeKeys = (FOR v, e IN 1..1 ANY 'persons/eve' GRAPH 'knows_graph' RETURN e._key)
LET r = (FOR key IN edgeKeys REMOVE key IN knows)
REMOVE 'eve' IN persons
The query performs the following actions:
- Traverses the graph with a depth of 1 to retrieve the
_key
of all edges connected to eve. - Removes all these edges from the
knows
collection. - Removes the vertex eve from the
persons
collection.
After you run the query, Macrometa returns an empty list. If you examine knows_graph
, then you will see that the vertex and its associated edges have been removed.
An alternative query to achieve the same result is to combine the edge retrieval and removal within the same graph traversal:
LET edgeKeys = (FOR v, e IN 1..1 ANY 'persons/eve' GRAPH 'knows_graph'
REMOVE e._key IN knows)
REMOVE 'eve' IN persons
Remove a Vertex from Multiple Collections
In the City Graph example graph, there are several vertex collections - germanCity
and frenchCity
, and several edge collections - frenchHighway
, germanHighway
, and internationalHighway
.
To delete city Berlin, you must consider all edge collections. The REMOVE
operation should be applied to all edge collections with OPTIONS { ignoreErrors: true }
. If you don't use this option, then the query will stop whenever it encounters a non-existing key that should be removed from a collection.
LET edgeKeys = (FOR v, e IN 1..1 ANY 'germanCity/Berlin' GRAPH 'routeplanner' RETURN e._key)
LET r = (FOR key IN edgeKeys REMOVE key IN internationalHighway
OPTIONS { ignoreErrors: true } REMOVE key IN germanHighway
OPTIONS { ignoreErrors: true } REMOVE key IN frenchHighway
OPTIONS { ignoreErrors: true })
REMOVE 'Berlin' IN germanCity
The query performs the following actions:
- Traverses the graph with a depth of 1 to retrieve the
_key
of all edges connected to Berlin. - Removes all these edges from the
internationalHighway
,germanHighway
, andfrenchHighway
collections using theignoreErrors
option to avoid stopping the query if a non-existing key is encountered. - Removes the vertex Berlin from the
germanCity
collection.
After you run the query, Macrometa returns an empty list. If you examine the routeplanner
graph, then you will see that the vertex and its associated edges have been removed.
List Vertex Collections
These instructions provide several methods of listing vertex collections associated with a graph.
- REST API
- CLI
Use our interactive API Reference with code generation in 18 programming languages to List Vertex Collections.
Use the gdnsl graph describe CLI command to get a list of vertex collections for a graph.
Add a Vertex Collection
These instructions provide several methods of adding a vertex collection to a graph.
- Web Console
- REST API
- CLI
Follow these instructions to add a vertex collection to a graph using the GDN console web UI.
- Log in to your Macrometa account.
- Click Data > Graphs.
- Click Edit next to the graph that you want to add a vertex collection to.
- Click in the From Collections, To Collections, or Vertex Collections field, and then select the vertex collection that you want to add. You can do this more than once.
- Click Update.
Use our interactive API Reference with code generation in 18 programming languages to Add a Vertex Collection.
Use the gdnsl graph update CLI command to add a vertex collection to a graph.
Remove a Vertex Collection
These instructions provide several methods of removing a vertex collection from a graph.
- Web Console
- REST API
- CLI
Follow these instructions to remove a vertex collection from a graph using the GDN console web UI.
- Log in to your Macrometa account.
- Click Data > Graphs.
- Click Edit next to the graph that you want to remove a vertex collection from.
- In the From Collections, To Collections, or Vertex Collections field, click the X next to the vertex collection that you want to remove. You can do this more than once.
- Click Update.
Use our interactive API Reference with code generation in 18 programming languages to Remove a Vertex Collection.
Use the gdnsl graph update CLI command to remove a vertex collection from a graph.