grafeo.Node¶
Represents a graph node.
Properties¶
| Property | Type | Description |
|---|---|---|
id |
int |
Internal node ID |
labels |
List[str] |
Node labels |
Methods¶
get()¶
Get a property value by key. Returns None if the property does not exist.
properties()¶
Get all properties as a dictionary.
has_label()¶
Check whether the node has a specific label.
keys()¶
Return a list of all property key names on this node.
items()¶
Return a list of (key, value) pairs for all properties.
Operators¶
node["key"]¶
Access a property by key. Raises KeyError if the property does not exist.
"key" in node¶
Check whether the node has a property with the given key.
Example¶
result = db.execute("MATCH (n:Person) RETURN n LIMIT 1")
row = next(iter(result))
node = row['n']
print(f"ID: {node.id}")
print(f"Labels: {node.labels}")
print(f"Name: {node.get('name')}")
print(f"Is a Person: {node.has_label('Person')}")
print(f"All properties: {node.properties()}")
Direct Node Creation¶
# Create node with direct API
node = db.create_node(["Person"], {"name": "Alix", "age": 30})
print(f"Created node with ID: {node.id}")
# Manage labels
db.add_node_label(node.id, "Employee")
db.remove_node_label(node.id, "Contractor")
labels = db.get_node_labels(node.id)