An entity has a unique, comparable identity which defines whether or not two entities are equal.
An entity is assigned a set of properties, each of which are uniquely identified in the set by the irrespective property keys.
Simple Entities
GraphId: Simple entities are assigned a unique graphid. A graphid is a unique composition of the entityโs label id and a unique sequence assigned to each label. Note that there will be overlap in ids when comparing entities from different graphs.
Labels: A label is an identifier that classifies vertices and edges into certain categories. Edges are required to have a label, but vertices do not. The names of labels between vertices and edges cannot overlap.
Properties: Both vertices and edges may have properties. Properties are attribute values, and each attribute name should be defined only as a string type.
Vertex: A vertex is the basic entity of the graph, with the unique attribute of being able to exist in and of itself.
# typecasting a map to vertex
SELECT *
FROM cypher('graph', $$
WITH {id: 0, label: "label_name", properties: {i: 0}}::vertex as v
RETURN v
$$) AS (v agtype);
- Edge: An edge is an entity that encodes a directed connection between exactly two nodes, the source node and the target node. An edge is assigned exactly one edge type.
# typecasting a map to vertex
SELECT *
FROM cypher('graph', $$
WITH {id: 2, start_id: 0, end_id: 1, label: "label_name", properties: {i: 0}}::edge as e
RETURN e
$$) AS (e agtype);
Composite Entities
It is combination of multiple simple entities.
- Path: A path is a series of alternating vertices and edges. A path must start with a vertex, and have at least one edge.
# typecasting a list to path
SELECT *
FROM cypher('graph', $$
WITH [{id: 0, label: "label_name_1", properties: {i: 0}}::vertex,
{id: 2, start_id: 0, end_id: 1, label: "edge_label", properties: {i: 0}}::edge,
{id: 1, label: "label_name_2", properties: {}}::vertex
]::path as p
RETURN p
$$) AS (p agtype);
Top comments (0)