Description Usage Arguments Details Value Examples
View source: R/getOrCreateNode.R
Create a unique node or retrieve it if it already exists.
1 | getOrCreateNode(graph, .label, ...)
|
graph |
A graph object. |
.label |
A character string. |
... |
A named list. Node properties in the form key = value. |
A uniqueness constraint must exist for the given node label and first key = value pair
listed in ...
. Use addConstraint
to add a uniqueness constraint.
A node object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ## Not run:
graph = startGraph("http://localhost:7474/db/data/")
clear(graph)
createNode(graph, "Person", name = "Alice", age = 24)
createNode(graph, "Person", name = "Bob", age = 21)
addConstraint(graph, "Person", "name")
# Alice is retrieved from the graph; a new node is not created.
alice = getOrCreateNode(graph, "Person", name = "Alice")
# Additional properties listed after the unique key = value
# pair are ignored if the node is retrieved instead of
# created.
bob = getOrCreateNode(graph, "Person", name = "Bob", age = 22)
# Node doesn't exist, so it is created.
charles = getOrCreateNode(graph, "Person", name = "Charles")
# There are now three nodes in the graph.
length(getLabeledNodes(graph, "Person"))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.