The vertex and edge are assigned to the graphid based on the cypher query is being called (i.e. the first parameter) it is checked on the backend and gets the Object ID of that graph with the matched graph name and assigning that to them.
You need to check the source code to get everything connected.
In your queries:
1- A graph named 'graph_name' has got a unique Object ID and get added to the graphs table as well as it is stored in a hash-table for quick-accessing the current exiting tables
SELECT create_graph('graph_name');
2- Get the Object ID of the graph with name 'graph_name' and create a vertex and connect them together and store it
SELECT *
FROM cypher('graph_name', $$
CREATE (n)
$$) as (v agtype);
3- Do similar.
AGE uses a custom data type called agtype, which is the only data type returned by AGE. Agtype is a superset of Json and a custom implementation of JsonB.
Here is the data-structure used, also you can check that on the source code on github.
/*
* agtype_value: In-memory representation of agtype. This is a convenient
* deserialized representation, that can easily support using the "val"
* union across underlying types during manipulation. The agtype on-disk
* representation has various alignment considerations.
*/
struct agtype_value
{
enum agtype_value_type type; /* Influences sort order */
union
{
int64 int_value; /* Cypher 8 byte Integer */
float8 float_value; /* Cypher 8 byte Float */
Numeric numeric;
bool boolean;
struct
{
int len;
char *val; /* Not necessarily null-terminated */
} string; /* String primitive type */
struct
{
int num_elems;
agtype_value *elems;
bool raw_scalar; /* Top-level "raw scalar" array? */
} array; /* Array container type */
struct
{
int num_pairs; /* 1 pair, 2 elements */
agtype_pair *pairs;
} object; /* Associative container type */
struct
{
int len;
agtype_container *data;
} binary; /* Array or object, in on-disk format */
} val;
};
References: