Utility Endpoints

class graphdatascience.procedure_surface.api.util_endpoints.UtilEndpoints
abstract as_node(node_id: int) → Node

Get a node from a node id.

Parameters:

node_id (int) – The id of the node to get.

Returns:

The node with the given id.

Return type:

neo4j.graph.Node

abstract as_nodes(node_ids: list[int]) → list[Node]

Get a list of nodes from a list of node ids.

Parameters:

node_ids (list[int]) – The ids of the nodes to get.

Returns:

The nodes with the given ids.

Return type:

list[neo4j.graph.Node]

abstract find_node_id(labels: list[str] | None = None, properties: dict[str, Any] | None = None) → int

Find the node id of a node with the given labels and properties.

Exactly one node must match the given labels and properties, otherwise an error is raised.

Parameters:
  • labels (list[str] | None) – The labels the node must have.

  • properties (dict[str, Any] | None) – The properties the node must match.

Returns:

The node id of the matching node.

Return type:

int

abstract node_property(G: Graph, node_id: int, property_key: str, node_label: str = '*') → Any

Get the property of a node with the given id from an in-memory graph.

Not available in AGA sessions; stream the node properties once (gds.graph.node_properties.stream) and filter on the client side instead.

Parameters:
  • G (Graph) – Graph object to use

  • node_id (int) – The id of the node to get the property from.

  • property_key (str) – The key of the property to get.

  • node_label (str) – The label of the node to get the property from.

Returns:

The property of the node with the given id.

Return type:

Any

one_hot_encoding(available_values: list[Any] | None, selected_values: list[Any] | None) → list[int]

One hot encode a list of values.

Parameters:
  • available_values (list[Any] | None) – The available values to encode.

  • selected_values (list[Any] | None) – The selected values.

Returns:

The one hot encoded values.

Return type:

list[int]