Overview
An HDC projection resides in the memory of a HDC (High-Density Computing) server, containing either full or partial data from a graphset loaded from the physcial storage of shard servers.
HDC projections support all graph algorithms and data-retrieving graph queries.
Managing HDC Projections
Showing HDC Projections
Retrieves information about all HDC projections of the current graphset by calling the hdc.graph.show()
procedure:
CALL hdc.graph.show()
Or retrieves a specific projection, such as the one named hdcGraph_1
:
CALL hdc.graph.show("hdcGraph_1")
It returns a table _projectList
with the following fields:
Field |
Description |
---|---|
project_name |
Name of the projection. |
project_type |
Type of the projection, which is hdc for all HDC projections. |
graph_name |
Name of the current graphset from which the data was loaded. |
status |
Current state of the projection, which can be DONE or CREATING , FAILED or UNKNOWN . |
stats |
Statistics about nodes and edges included in the projection, including their schemas (labels), properties and total counts. |
is_default |
Indicates if it is the default HDC projection for the current graphset. |
hdc_server_name |
Name of the HDC server hosting the projection. |
hdc_server_status |
Current state of this HDC server, which can be ACTIVE or DEAD . |
config |
Configurations for the HDC projection. |
When retrieving a specific projection using hdc.graph.show("<projectName>")
, two supplementary tables are returned:
_graph_from_<hdcName>
: Shows all HDC projections created on<hdcName>
._algoList_from_<hdcName>
: Lists all algorithms installed on<hdcName>
.
Here, <hdcName>
is the name of the HDC server where the projection was created.
Creating an HDC Projection
The hdc.graph.create()
precedure can be called to create an in-memory projection of the current graphset to an HDC server. The project creation is executed as a job, you may run CALL job.show()
afterward to verify the success of the creation.
CALL hdc.graph.create("<hdcName>", "<projectName>", {
nodes: {
"<label?>": ["<property1?>", "<property2?>", ...],
"<label2?>": ["<property1?>", "<property2?>", ...],
...
},
edges: {
"<label1?>": ["<property1?>", "<property2?>", ...],
"<label2?>": ["<property1?>", "<property2?>", ...],
...
},
direction: "<edgeDirection?>",
load_id: <boolean?>,
update: "<dataSyncMode>",
query: "query",
default: <boolean?>
})
Param | Description | Optional | |
---|---|---|---|
<hdcName> |
Name of the HDC server to host the projection. | No | |
<projectName> |
Name of the projection. Each HDC projection name within an HDC server must be unique and cannot duplicate the name of any distributed projection of the same graphset. | No | |
Config Map | nodes |
Specifies nodes to project based on labels and properties. The _uuid is loaded by default, while _id is configurable with load_id . Sets to "*": ["*"] to load all nodes. |
Yes |
edges |
Specifies edges to project based on labels and properties. All system properties are loaded by default. Sets to "*": ["*"] to load all edges. |
Yes | |
direction |
Since each edge is physically stored twice - as an incoming edge along its destination node and an outgoing edge with its source node - you can choose to project only incoming edges with in , only outgoing edges with out , or both (the default setting) with undirected . Please note that in or out restricts graph traversal during computation to the specified direction. |
Yes | |
load_id |
Sets to false to project nodes without _id values to save the memory space; it defaults to true . |
Yes | |
update |
Sets the data sync mode. Only static (default) is supported now where any data change in the physical storage will not be synchronized to the projection. |
Yes | |
query |
This is a reserved parameter to set a query to specify the data to project. Now it can be set to query only. |
No | |
default |
Sets to true to specify this projection as the default HDC projection of the current graphset; it defaults to false . |
Yes |
Examples
To project the entire current graphset to hdc-server-1
as hdcGraph
:
CALL hdc.graph.create("hdc-server-1", "hdcGraph", {
nodes: {"*": ["*"]},
edges: {"*": ["*"]},
direction: "undirected",
load_id: true,
update: "static",
query: "query",
default: true
})
To project nodes labeled account
and movie
with selected properties and incoming edges labeled rate
in the current graphset to hdc-server-1
as hdcGraph_1
, while omitting nodes' _id
values:
CALL hdc.graph.create("hdc-server-1", "hdcGraph_1", {
nodes: {
"account": ["name", "gender"],
"movie": ["name", "year"]
},
edges: {"rate": ["*"]},
direction: "in",
load_id: false,
update: "static",
query: "query",
default: false
})
Dropping an HDC Projection
You can drop any HDC projection of the current graphset from the HDC server by calling the hdc.graph.drop()
procedure.
The following example deletes the HDC projection named hdcGraph_1
:
CALL hdc.graph.drop("hdcGraph_1")
Example Graph and Projection
To create this graph, run the following query against an empty graph:
INSERT (a:entity {_id: "A"}),
(b:entity {_id: "B"}),
(c:entity {_id: "C"}),
(d:entity {_id: "D"}),
(a)-[:link {weight:1}]->(b),
(a)-[:link {weight:1.5}]->(c),
(a)-[:link {weight:0.5}]->(d),
(b)-[:link {weight:2}]->(c),
(c)-[:link {weight:0.5}]->(d)
To create an HDC projection hdcGraph
of the entire graph:
CALL hdc.graph.create("hdc-server-1", "hdcGraph", {
nodes: {"*": ["*"]},
edges: {"*": ["*"]},
direction: "undirected",
load_id: true,
update: "static",
query: "query",
default: false
})
Executing Queries
Execute a GQL query on an HDC projection is not supported yet.
Executing Algorithms
HDC projections run HDC algorithms. HDC algorithms run using one of the six execution modes: File Writeback, DB Writeback, Stats Writeback, Full Return, Stream Return, and Stats Return.
Writeback Modes
To execute an algorithm on an HDC projection using a writeback mode (File, DB, Stats), call the algo.<algoName>("<projectName>", {params:{}, write_params:{}})
procedure.
File Writeback
Runs the Degree Centrality algorithm on hdcGraph
to compute the out-degree of all nodes and write the results back to a file degree.txt
:
CALL algo.degree("hdcGraph", {
params: {
return_id_uuid: "id",
direction: "out"
},
write_params: {
file: {
filename: "degree.txt"
}
}
})
Result:
_id,degree_centrality
D,0
B,1
A,3
C,1
DB Writeback
Runs the Degree Centrality algorithm on hdcGraph
to compute the degree of all nodes and write the results back to the node property degree
:
CALL algo.degree("hdcGraph", {
params: {},
write_params: {
db: {
property: "degree"
}
}
})
Stats Writeback
Runs the Triangle Counting algorithm to count the number of triangles on the hdcGraph
and write the statistical summaries to the job:
CALL algo.triangle_counting("hdcGraph", {
params: {
result_type: 1
},
write_params: {
stats: {}
}
})
Results:
triangle_count |
---|
2 |
Return Modes
To execute an algorithm on an HDC projection using a return mode (Full, Stream, Stats), call the algo.<algoName>("<projectName>", {params:{}, return_params:{}})
procedure.
Full Return
Runs the Degree Centrality algorithm on hdcGraph
to compute the out-degree of all nodes and return the results:
CALL algo.degree("hdcGraph", {
params: {
return_id_uuid: "id",
direction: "out"
},
return_params: {}
}) YIELD r
RETURN r
Results:
_id | degree_centrality |
---|---|
D | 0 |
B | 1 |
A | 3 |
C | 1 |
Stream Return
Runs the Degree Centrality algorithm on hdcGraph
to compute the out-degree of all nodes and return the results:
CALL algo.degree("hdcGraph", {
params: {
return_id_uuid: "id",
direction: "out"
},
return_params: {
type: "stream"
}
}) YIELD r
RETURN r
Results:
_id | degree_centrality |
---|---|
D | 0 |
B | 1 |
A | 3 |
C | 1 |
Stats Return
Runs the Triangle Counting algorithm to count the number of triangles on hdcGraph
and return the statistical summaries:
CALL algo.triangle_counting("hdcGraph", {
params: {
result_type: 1
},
return_params: {
type: "stats"
}
}) YIELD s
RETURN s
Results:
triangle_count |
---|
2 |
Graph Traversal Direction
If an HDC projection is created with the direction
option set to in
or out
, graph traversal is restricted to incoming or outgoing edges, respectively. Queries or algorithms attempting to traverse in the missing direction throws errors or yields empty results.
To create an HDC projection hdcGraph_in_edges
of the graph with nodes and incoming edges:
CALL hdc.graph.create("hdc-server-1", "hdcGraph_in_edges", {
nodes: {"*": ["*"]},
edges: {"*": ["*"]},
direction: "in",
load_id: true,
update: "static",
query: "query",
default: false
})
This Degree Centrality algorithm computes the out-degree of all nodes on hdcGraph_in_edges
, they are all 0.
CALL algo.degree("hdcGraph_in_edges", {
params: {
return_id_uuid: "id",
direction: "out"
},
return_params: {}
}) YIELD r
RETURN r
Results:
_id | degree_centrality |
---|---|
D | 0 |
B | 0 |
A | 0 |
C | 0 |
Exclusion of Node IDs
If an HDC projection is created with the load_id
option set to false
, it does not contain the _id
values for nodes. Queries or algorithms referencing _id
throws errors or yields empty results. In algorithm writeback files, _id
values are replaced with _uuid
values instead.
To create an HDC projection hdcGraph_no_id
of the graph without nodes' _id
values:
CALL hdc.graph.create("hdc-server-1", "hdcGraph_no_id", {
nodes: {"*": ["*"]},
edges: {"*": ["*"]},
direction: "undirected",
load_id: false,
update: "static",
query: "query",
default: false
})
The Degree Centrality algorithm computes the degree of all nodes on hdcGraph_no_id
, since the projection does not include node _id
values, the results will appear empty for that column:
CALL algo.degree("hdcGraph_no_id", {
params: {
return_id_uuid: "id",
},
return_params: {}
}) YIELD r
RETURN r
Results:
_id | degree_centrality |
---|---|
2 | |
2 | |
3 | |
3 |
The Degree Centrality algorithm computes the degree of all nodes on hdcGraph_no_id
and writes the results back to a file degree.txt
, nodes' _id
are replaced with _uuid
:
CALL algo.degree("hdcGraph_no_id", {
params: {
return_id_uuid: "id"
},
write_params: {
file: {
filename: "degree.txt"
}
}
})
Results:
_uuid,degree_centrality
288232575174967298,2
3530824306881724417,2
10016007770295238657,3
12033620403357220866,3
Exclusion of Properties
If an HDC projection is created without certain properties, queries or algorithms referencing those properties throws errors or yields empty results.
To create an HDC projection hdcGraph_no_weight
of the graph containing nodes and only system properties of edges labeled link
:
CALL hdc.graph.create("hdc-server-1", "hdcGraph_no_weight", {
nodes: {"*": ["*"]},
edges: {"link": []},
direction: "undirected",
load_id: true,
update: "static",
query: "query",
default: false
})
The Degree Centrality algorithm computes the degree of all nodes weighted by the edge property @link.weight
on hdcGraph_no_weight
, error occurs as the weight
property is missing:
CALL algo.degree("hdcGraph_no_weight", {
params: {
edge_schema_property: "@link.weight"
},
return_params: {}
}) YIELD r
RETURN r