Catalog Endpoints

class graphdatascience.procedure_surface.api.catalog.Aggregation

Specifies how to aggregate parallel relationships in a graph.

COUNT = 'COUNT'
MAX = 'MAX'
MIN = 'MIN'
NONE = 'NONE'
SINGLE = 'SINGLE'
SUM = 'SUM'
__new__(value)
classmethod of(aggregation: Aggregation | str) → Aggregation

Normalize an Aggregation or a plain string into an Aggregation.

Parameters:

aggregation (Aggregation | str)

Return type:

Aggregation

class graphdatascience.procedure_surface.api.catalog.CatalogEndpoints
abstractmethod construct(graph_name: str, nodes: DataFrame | list[DataFrame], relationships: DataFrame | list[DataFrame] | None = None, concurrency: int | None = None, undirected_relationship_types: list[str] | None = None, inverse_indexed_relationship_types: list[str] | None = None, batch_size: int = 100000, overwrite: bool = False) → Graph

Construct a graph from a list of node and relationship dataframes.

Parameters:
  • graph_name (str) – Name of the graph to be created

  • nodes (DataFrame | list[DataFrame]) –

    Node dataframes. A dataframe should follow the schema:

    • nodeId to identify uniquely the node overall dataframes

    • labels to specify the labels of the node as a list of strings (optional)

    • other columns are treated as node properties

  • relationships (DataFrame | list[DataFrame] | None) –

    Relationship dataframes. A dataframe should follow the schema:

    • sourceNodeId to identify the start node of the relationship

    • targetNodeId to identify the end node of the relationship

    • relationshipType to specify the type of the relationship (optional)

    • other columns are treated as relationship properties

  • concurrency (int | None) – Number of concurrent threads to use.

  • undirected_relationship_types (list[str] | None) – List of relationship types to treat as undirected.

  • inverse_indexed_relationship_types (list[str] | None) – List of relationship types for which to create an inverse index.

  • batch_size (int) – Batch size to use when sending data to GDS.

  • overwrite (bool) – If True, drop an existing graph with the same name before constructing the new one. Defaults to False.

Returns:

Constructed graph object.

Return type:

Graph

property datasets: DatasetEndpoints

Endpoints for loading predefined datasets into the graph catalog.

abstractmethod exists(graph_name: str) → bool

Check if a graph exists in the catalog.

Parameters:

graph_name (str) – Name of the graph

Returns:

True if the graph exists, False otherwise.

Return type:

bool

abstract property export: GraphExportEndpoints

Endpoints for exporting graphs to a new database or CSV files.

abstractmethod filter(G: Graph, graph_name: str, node_filter: str, relationship_filter: str, parameters: dict[str, Any] | None = None, concurrency: int | None = None, job_id: str | None = None, sudo: bool = False, log_progress: bool = True, username: str | None = None, overwrite: bool = False) → GraphWithFilterResult

Create a subgraph of a graph based on a filter expression.

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

  • graph_name (str) – Name of the graph to be created

  • node_filter (str) – Filter expression for nodes

  • relationship_filter (str) – Filter expression for relationships

  • parameters (dict[str, Any] | None) – A map of user-defined query parameters that are passed into the node and relationship filters.

  • concurrency (int | None) – Number of concurrent threads to use.

  • job_id (str | None) – Identifier for the computation.

  • sudo (bool) – Disable the memory guard.

  • log_progress (bool) – Display progress logging.

  • username (str | None) – As an administrator, impersonate a different user for accessing their graphs.

  • overwrite (bool) – If True, drop an existing graph with the same name before creating the filtered subgraph. Defaults to False.

Returns:

tuple of the filtered graph object and the information like graph name, node count, relationship count, etc.

Return type:

GraphWithFilterResult

abstractmethod generate(graph_name: str, node_count: int, average_degree: float, *, relationship_distribution: str | None = 'UNIFORM', relationship_seed: int | None = None, relationship_property: RelationshipPropertySpec | None = None, orientation: str | None = 'NATURAL', aggregation: str | None = 'NONE', allow_self_loops: bool | None = False, read_concurrency: int | None = None, job_id: str | None = None, sudo: bool = False, log_progress: bool = True, username: str | None = None, overwrite: bool = False) → GraphWithGenerationStats

Generates a random graph and store it in the graph catalog.

Parameters:
  • graph_name (str) – Name of the graph to be created

  • node_count (int) – The number of nodes in the generated graph

  • average_degree (float) – The average out-degree of the generated nodes

  • relationship_distribution (str | None) – Determines the relationship distribution strategy.

  • relationship_seed (int | None) – Seed value for generating deterministic relationships.

  • relationship_property (RelationshipPropertySpec | None) – Configure generated relationship properties.

  • orientation (str | None) – Specifies the orientation of the generated relationships.

  • aggregation (str | None) – The relationship aggregation method of Relationship Projection.

  • allow_self_loops (bool | None) – Whether nodes in the graph can have relationships where start and end nodes are the same.

  • read_concurrency (int | None) – Number of concurrent threads/processes to use during graph generation.

  • job_id (str | None) – Identifier for the computation.

  • sudo (bool) – Disable the memory guard.

  • log_progress (bool) – Display progress logging.

  • username (str | None) – As an administrator, impersonate a different user for accessing their graphs.

  • overwrite (bool) – If True, drop an existing graph with the same name before generating the new one. Defaults to False.

Returns:

tuple of the generated graph object and the result object containing stats about the generation.

Return type:

GraphWithGenerationStats

abstractmethod get(graph_name: str) → Graph

Retrieve a handle to a graph from the graph catalog.

Parameters:

graph_name (str) – Name of the graph

Returns:

A handle to the graph.

Return type:

Graph

abstractmethod list(G: Graph | str | None = None) → list[GraphInfoWithDegrees]

List graphs in the graph catalog.

Parameters:

G (Graph | str | None) – GraphV2 object or name to filter results. If None, list all graphs.

Returns:

List of graph metadata objects containing information like node count.

Return type:

list[GraphInfoWithDegrees]

abstract property node_labels: NodeLabelEndpoints

Endpoints for node label operations.

abstract property node_properties: NodePropertiesEndpoints

Endpoints for node property operations.

property node_property: NodePropertyEndpoints

Endpoints for streaming a single node property.

property relationship_properties: RelationshipPropertiesEndpoints

Endpoints for streaming several relationship properties.

property relationship_property: RelationshipPropertyEndpoints

Endpoints for streaming a single relationship property.

abstract property relationships: RelationshipsEndpoints

Endpoints for relationship operations.

abstract property sample: GraphSamplingEndpoints

Endpoints for graph sampling.

class graphdatascience.procedure_surface.api.catalog.DatasetEndpoints
load_cora(graph_name: str = 'cora', undirected: bool = False) → Graph

A citation network introduced.

Parameters:
  • graph_name (str) – Name of the graph to be created

  • undirected (bool) – Whether the graph should be undirected

Returns:

A handle to the graph.

Return type:

Graph

load_imdb(graph_name: str = 'imdb', undirected: bool = True) → Graph

A heterogeneous graph that is used to benchmark node classification or link prediction models.

The graph contains Actors, Directors, Movies (and UnclassifiedMovies) as nodes, and relationships between actors and movies that they acted in, and between directors and movies which they directed for.

Parameters:
  • graph_name (str) – Name of the graph to be created

  • undirected (bool) – Whether the graph should be undirected

Returns:

A handle to the graph.

Return type:

Graph

load_karate_club(graph_name: str = 'karate_club', undirected: bool = False) → Graph

A social network introduced by http://konect.cc/networks/ucidata-zachary/[Zachary].

Parameters:
  • graph_name (str) – Name of the graph to be created

  • undirected (bool) – Whether the graph should be undirected

Returns:

A handle to the graph.

Return type:

Graph

load_lastfm(graph_name: str = 'lastfm', undirected: bool = True) → Graph

A heterogeneous graph that is used to benchmark link prediction models. The original raw data is from http://www.lastfm.com/[LastFM].

The graph contains User and Artists as nodes, each with a rawId field that corresponds to the ids from the raw data. The rawId could be used, for example, to check the artist names by referring back to the HetRec’11 .dat files.

Parameters:
  • graph_name (str) – Name of the graph to be created

  • undirected (bool) – Whether the graph should be undirected

Returns:

A handle to the graph.

Return type:

Graph

property networkx: NXLoader

Convenience wrapper to load networkx graphs into the graph catalog.

Returns:

A loader to load networkx graphs into the graph catalog.

Return type:

NXLoader

property ogbl: OGBLLoader

Datasets used for link property prediction.

property ogbn: OGBNLoader

Datasets used for node property prediction.

class graphdatascience.procedure_surface.api.catalog.GraphExportCsvResult
export_name: str
graph_name: str
node_count: int
node_property_count: int
relationship_count: int
relationship_property_count: int
relationship_type_count: int
write_millis: int
class graphdatascience.procedure_surface.api.catalog.GraphExportEndpoints
abstractmethod csv(G: Graph, export_name: str, *, additional_node_properties: str | list[str] | dict[str, Any] | None = None, batch_size: int = 10000, default_relationship_type: str = '__ALL__', include_meta_data: bool = False, log_progress: bool = True, sudo: bool = False, use_label_mapping: bool = False, username: str | None = None, write_concurrency: int | None = None) → GraphExportCsvResult

Export a graph from the graph catalog to CSV files.

The files are written to a subdirectory of the export location configured on the server via gds.export.location.

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

  • export_name (str) – Name of the directory to which the CSV files are exported, relative to the configured export location.

  • additional_node_properties (str | list[str] | dict[str, Any] | None) – Allows for exporting additional node properties from the original graph backing the in-memory graph.

  • batch_size (int) – Number of entities to process in each batch.

  • default_relationship_type (str) – Relationship type used for * relationship projections.

  • include_meta_data (bool) – Include meta data files such as node labels and relationship types in the export.

  • log_progress (bool) – Display progress logging.

  • sudo (bool) – Disable the memory guard.

  • use_label_mapping (bool) – Map node labels to numeric identifiers in the exported files.

  • username (str | None) – As an administrator, impersonate a different user for accessing their graphs.

  • write_concurrency (int | None) – Number of concurrent threads to use for writing.

Returns:

The result of the export, including the export name and counts of the exported entities.

Return type:

GraphExportCsvResult

class graphdatascience.procedure_surface.api.catalog.GraphExportResult
db_name: str
graph_name: str
node_count: int
node_property_count: int
relationship_count: int
relationship_property_count: int
relationship_type_count: int
write_millis: int
class graphdatascience.procedure_surface.api.catalog.GraphFilterResult
from_graph_name: str
graph_name: str
node_count: int
node_filter: str
project_millis: int
relationship_count: int
relationship_filter: str
class graphdatascience.procedure_surface.api.catalog.GraphGenerationStats
average_degree: float
generate_millis: int
name: str
nodes: int
relationship_distribution: str
relationship_property: RelationshipPropertySpec | None
relationship_seed: int | None
relationships: int
class graphdatascience.procedure_surface.api.catalog.GraphSamplingEndpoints
abstractmethod cnarw(G: Graph, graph_name: str, start_nodes: list[int] | None = None, restart_probability: float = 0.1, sampling_ratio: float = 0.15, node_label_stratification: bool = False, relationship_weight_property: str | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], random_seed: int | None = None, sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None, overwrite: bool = False) → GraphWithSamplingResult

Common Neighbour Aware Random Walk (CNARW) samples the graph by taking random walks from a set of start nodes

CNARW is a graph sampling technique that involves optimizing the selection of the next-hop node. It takes into account the number of common neighbours between the current node and the next-hop candidates. On each step of a random walk, there is a probability that the walk stops, and a new walk from one of the start nodes starts instead (i.e. the walk restarts). Each node visited on these walks will be part of the sampled subgraph. The resulting subgraph is stored as a new graph in the Graph Catalog.

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

  • graph_name (str) – Name of the graph to be created

  • start_nodes (list[int] | None) –

    IDs of the initial set of nodes in the original graph from which the sampling random walks will start.

    By default, a single node is chosen uniformly at random.

  • restart_probability (float) – The probability that a sampling random walk restarts from one of the start nodes. Default is 0.1.

  • sampling_ratio (float) – The fraction of nodes in the original graph to be sampled. Default is 0.15.

  • node_label_stratification (bool) – If true, preserves the node label distribution of the original graph. Default is False.

  • relationship_weight_property (str | None) – Name of the property to be used as weights.

  • relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.

  • node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.

  • random_seed (int | None) – Seed for random number generation to ensure reproducible results.

  • sudo (bool) – Disable the memory guard.

  • log_progress (bool) – Display progress logging.

  • username (str | None) – As an administrator, impersonate a different user for accessing their graphs.

  • concurrency (int | None) – Number of concurrent threads to use.

  • job_id (str | None) – Identifier for the computation.

  • overwrite (bool) – If True, drop an existing graph with the same name before sampling the new one. Defaults to False.

Returns:

tuple of the graph object and the result of the Common Neighbour Aware Random Walk (CNARW), including the dimensions of the sampled graph.

Return type:

GraphWithSamplingResult

abstractmethod estimate(G: Graph, start_nodes: list[int] | None = None, restart_probability: float = 0.1, sampling_ratio: float = 0.15, node_label_stratification: bool = False, relationship_weight_property: str | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], concurrency: int | None = None) → EstimationResult

Estimate the memory consumption of a CNARW algorithm run.

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

  • start_nodes (list[int] | None) – IDs of the initial set of nodes in the original graph from which the sampling random walks will start. By default, a single node is chosen uniformly at random.

  • restart_probability (float) – The probability that a sampling random walk restarts from one of the start nodes. Default is 0.1.

  • sampling_ratio (float) – The fraction of nodes in the original graph to be sampled. Default is 0.15.

  • node_label_stratification (bool) – If true, preserves the node label distribution of the original graph. Default is False.

  • relationship_weight_property (str | None) – Name of the property to be used as weights.

  • relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.

  • node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.

  • concurrency (int | None) – Number of concurrent threads to use.

Returns:

Memory estimation details

Return type:

EstimationResult

abstractmethod rwr(G: Graph, graph_name: str, start_nodes: list[int] | None = None, restart_probability: float = 0.1, sampling_ratio: float = 0.15, node_label_stratification: bool = False, relationship_weight_property: str | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], random_seed: int | None = None, sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None, overwrite: bool = False) → GraphWithSamplingResult

Random walk with restarts (RWR) samples the graph by taking random walks from a set of start nodes.

On each step of a random walk, there is a probability that the walk stops, and a new walk from one of the start nodes starts instead (i.e. the walk restarts). Each node visited on these walks will be part of the sampled subgraph. The resulting subgraph is stored as a new graph in the Graph Catalog.

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

  • graph_name (str) – Name of the graph to be created

  • start_nodes (list[int] | None) – IDs of the initial set of nodes in the original graph from which the sampling random walks will start. By default, a single node is chosen uniformly at random.

  • restart_probability (float) – The probability that a sampling random walk restarts from one of the start nodes. Default is 0.1.

  • sampling_ratio (float) – The fraction of nodes in the original graph to be sampled. Default is 0.15.

  • node_label_stratification (bool) – If true, preserves the node label distribution of the original graph. Default is False.

  • relationship_weight_property (str | None) – Name of the property to be used as weights.

  • relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.

  • node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.

  • random_seed (int | None) – Seed for random number generation to ensure reproducible results.

  • sudo (bool) – Disable the memory guard.

  • log_progress (bool) – Display progress logging.

  • username (str | None) – As an administrator, impersonate a different user for accessing their graphs.

  • concurrency (int | None) – Number of concurrent threads to use.

  • job_id (str | None) – Identifier for the computation.

  • overwrite (bool) – If True, drop an existing graph with the same name before sampling the new one. Defaults to False.

Returns:

tuple of the graph object and the result of the Random Walk with Restart (RWR), including the dimensions of the sampled graph.

Return type:

GraphWithSamplingResult

class graphdatascience.procedure_surface.api.catalog.GraphSamplingResult
from_graph_name: str
graph_name: str
node_count: int
project_millis: int
relationship_count: int
start_node_count: int
class graphdatascience.procedure_surface.api.catalog.GraphWithFilterResult

GraphWithFilterResult(graph, result)

static __new__(_cls, graph: Graph, result: GraphFilterResult)

Create new instance of GraphWithFilterResult(graph, result)

Parameters:
graph: Graph

Alias for field number 0

result: GraphFilterResult

Alias for field number 1

class graphdatascience.procedure_surface.api.catalog.GraphWithGenerationStats

GraphWithGenerationStats(graph, result)

static __new__(_cls, graph: Graph, result: GraphGenerationStats)

Create new instance of GraphWithGenerationStats(graph, result)

Parameters:
graph: Graph

Alias for field number 0

result: GraphGenerationStats

Alias for field number 1

class graphdatascience.procedure_surface.api.catalog.GraphWithSamplingResult

GraphWithSamplingResult(graph, result)

static __new__(_cls, graph: Graph, result: GraphSamplingResult)

Create new instance of GraphWithSamplingResult(graph, result)

Parameters:
graph: Graph

Alias for field number 0

result: GraphSamplingResult

Alias for field number 1

class graphdatascience.procedure_surface.api.catalog.NodeLabelEndpoints
abstractmethod mutate(G: Graph, node_label: str, *, node_filter: str, sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None) → NodeLabelMutateResult

Attaches the specified node label to the filtered nodes in the graph.

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

  • node_label (str) – The node label to write back.

  • node_filter (str) – A Cypher predicate for filtering nodes in the input graph.

  • sudo (bool) – Disable the memory guard.

  • log_progress (bool) – Display progress logging.

  • username (str | None) – As an administrator, impersonate a different user for accessing their graphs.

  • concurrency (int | None) – Number of concurrent threads to use.

Returns:

Execution metrics and statistics

Return type:

NodeLabelMutateResult

abstractmethod write(G: Graph, node_label: str, *, node_filter: str, sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, write_concurrency: int | None = None, job_id: str | None = None) → NodeLabelWriteResult

Writes the specified node label to the filtered nodes in the database.

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

  • node_label (str) – The node label to write back.

  • node_filter (str) – A Cypher predicate for filtering nodes in the input graph.

  • sudo (bool) – Disable the memory guard.

  • log_progress (bool) – Display progress logging.

  • username (str | None) – As an administrator, impersonate a different user for accessing their graphs.

  • concurrency (int | None) – Number of concurrent threads to use.

  • write_concurrency (int | None) – Number of concurrent threads to use for writing.

  • job_id (str | None) – Identifier for the computation.

Returns:

Execution metrics and statistics

Return type:

NodeLabelWriteResult

class graphdatascience.procedure_surface.api.catalog.NodeLabelMutateResult
mutate_millis: int
class graphdatascience.procedure_surface.api.catalog.NodeLabelPersistenceResult
configuration: dict[str, object]
graph_name: str
node_count: int
node_label: str
node_labels_written: int
class graphdatascience.procedure_surface.api.catalog.NodeLabelWriteResult
write_millis: int
class graphdatascience.procedure_surface.api.catalog.NodePropertiesDropResult
graph_name: str
node_properties: list[str]
properties_removed: int
class graphdatascience.procedure_surface.api.catalog.NodePropertiesEndpoints
abstractmethod drop(G: Graph, node_properties: list[str], *, fail_if_missing: bool = True, concurrency: int | None = None, username: str | None = None) → NodePropertiesDropResult

Drops the specified node properties from the graph.

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

  • node_properties (list[str]) – The node properties to drop

  • fail_if_missing (bool) – Whether to fail if any of the node properties are missing.

  • concurrency (int | None) – Number of concurrent threads to use.

  • username (str | None) – As an administrator, impersonate a different user for accessing their graphs.

Returns:

Execution metrics and statistics

Return type:

NodePropertiesDropResult

abstractmethod stream(G: Graph, node_properties: str | list[str], *, list_node_labels: bool | None = False, node_labels: list[str] = ['*'], concurrency: int | None = None, sudo: bool = False, log_progress: bool = True, username: str | None = None, job_id: str | None = None, db_node_properties: list[str] | None = None) → DataFrame

Streams the specified node properties from the graph.

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

  • node_properties (str | list[str]) – The node properties to stream

  • list_node_labels (bool | None) – Whether to include node labels in the stream

  • node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.

  • concurrency (int | None) – Number of concurrent threads to use.

  • sudo (bool) – Disable the memory guard.

  • log_progress (bool) – Display progress logging.

  • username (str | None) – As an administrator, impersonate a different user for accessing their graphs.

  • job_id (str | None) – Identifier for the computation.

  • db_node_properties (list[str] | None) – Retrieves additional node properties from the database and attaches them to the stream.

Returns:

The streamed node properties

Return type:

pandas.DataFrame

abstractmethod write(G: Graph, node_properties: str | list[str] | dict[str, str], *, node_labels: list[str] = ['*'], concurrency: int | None = None, write_concurrency: int | None = None, sudo: bool = False, log_progress: bool = True, username: str | None = None, job_id: str | None = None) → NodePropertiesWriteResult

Writes the specified node properties from the graph to the database.

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

  • node_properties (str | list[str] | dict[str, str]) –

    Node properties to write. Can be:

    • A string representing a single property name.

    • A list of strings representing multiple property names.

    • A dictionary mapping from property names in the GDS graph to property names in the database.

  • node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.

  • concurrency (int | None) – Number of concurrent threads to use.

  • write_concurrency (int | None) – Number of concurrent threads to use for writing.

  • sudo (bool) – Disable the memory guard.

  • log_progress (bool) – Display progress logging.

  • username (str | None) – As an administrator, impersonate a different user for accessing their graphs.

  • job_id (str | None) – Identifier for the computation.

Returns:

Execution metrics and statistics

Return type:

NodePropertiesWriteResult

class graphdatascience.procedure_surface.api.catalog.NodePropertiesWriteResult
configuration: dict[str, Any]
graph_name: str
node_properties: list[str]
properties_written: int
write_millis: int
class graphdatascience.procedure_surface.api.catalog.NodePropertyEndpoints

Endpoints for streaming a single node property

stream(G: Graph, node_property: str, *, list_node_labels: bool | None = False, node_labels: list[str] = ['*'], concurrency: int | None = None, sudo: bool = False, log_progress: bool = True, username: str | None = None, job_id: str | None = None, db_node_properties: list[str] | None = None) → DataFrame

Streams the specified node property from the graph.

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

  • node_property (str) – The node property to stream

  • list_node_labels (bool | None) – Whether to include node labels in the stream

  • node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.

  • concurrency (int | None) – Number of concurrent threads to use.

  • sudo (bool) – Disable the memory guard.

  • log_progress (bool) – Display progress logging.

  • username (str | None) – As an administrator, impersonate a different user for accessing their graphs.

  • job_id (str | None) – Identifier for the computation.

  • db_node_properties (list[str] | None) – Retrieves additional node properties from the database and attaches them to the stream.

Returns:

The streamed node property as nodeId and propertyValue columns, plus a nodeLabels column if list_node_labels is set and one column per requested db_node_properties.

Return type:

pandas.DataFrame

class graphdatascience.procedure_surface.api.catalog.NodePropertySpec

NodePropertySpec(node_properties: ‘str | list[str] | dict[str, str]’) -> ‘None’

property_names() → list[str]
Return type:

list[str]

to_dict() → dict[str, str]
Return type:

dict[str, str]

class graphdatascience.procedure_surface.api.catalog.RelationshipPropertiesEndpoints

Endpoints for streaming several relationship properties

stream(G: Graph, relationship_properties: list[str], relationship_types: list[str] = ['*'], *, concurrency: int | None = None, sudo: bool = False, log_progress: bool = True, username: str | None = None, job_id: str | None = None) → RelationshipsDataFrame

Streams the specified relationship properties for all relationships of the specified types.

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

  • relationship_properties (list[str]) – The relationship properties to stream

  • relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.

  • concurrency (int | None) – Number of concurrent threads to use.

  • sudo (bool) – Disable the memory guard.

  • log_progress (bool) – Display progress logging.

  • username (str | None) – As an administrator, impersonate a different user for accessing their graphs.

  • job_id (str | None) – Identifier for the computation.

Returns:

The streamed relationships [sourceNodeId, targetNodeId, relationshipType], followed by one column per streamed relationship property. Offers a by_rel_type() method to reshape the relationships by relationship type.

Return type:

RelationshipsDataFrame

write(G: Graph, relationship_type: str, relationship_properties: list[str], *, concurrency: int | None = None, write_concurrency: int | None = None, sudo: bool = False, log_progress: bool = True, username: str | None = None, job_id: str | None = None) → RelationshipsWriteResult

Writes the specified relationship properties of the given relationship type from the graph to the database.

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

  • relationship_type (str) – The relationship type to write to the database

  • relationship_properties (list[str]) – The relationship properties to write

  • concurrency (int | None) – Number of concurrent threads to use.

  • write_concurrency (int | None) – Number of concurrent threads to use for writing.

  • sudo (bool) – Disable the memory guard.

  • log_progress (bool) – Display progress logging.

  • username (str | None) – As an administrator, impersonate a different user for accessing their graphs.

  • job_id (str | None) – Identifier for the computation.

Returns:

Execution metrics and statistics

Return type:

RelationshipsWriteResult

class graphdatascience.procedure_surface.api.catalog.RelationshipPropertyEndpoints

Endpoints for streaming a single relationship property, delegating to the relationships endpoints.

stream(G: Graph, relationship_property: str, relationship_types: list[str] = ['*'], *, concurrency: int | None = None, sudo: bool = False, log_progress: bool = True, username: str | None = None, job_id: str | None = None) → RelationshipsDataFrame

Streams the specified relationship property for all relationships of the specified types.

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

  • relationship_property (str) – The relationship property to stream

  • relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.

  • concurrency (int | None) – Number of concurrent threads to use.

  • sudo (bool) – Disable the memory guard.

  • log_progress (bool) – Display progress logging.

  • username (str | None) – As an administrator, impersonate a different user for accessing their graphs.

  • job_id (str | None) – Identifier for the computation.

Returns:

The streamed relationships [sourceNodeId, targetNodeId, relationshipType, propertyValue]. Offers a by_rel_type() method to reshape the relationships by relationship type.

Return type:

RelationshipsDataFrame

class graphdatascience.procedure_surface.api.catalog.RelationshipPropertySpec
static fixed(name: str, value: float) → RelationshipPropertySpec
Parameters:
Return type:

RelationshipPropertySpec

max: float | None
min: float | None
name: str
static random(name: str, min: float, max: float) → RelationshipPropertySpec
Parameters:
Return type:

RelationshipPropertySpec

type: str
value: float | None
class graphdatascience.procedure_surface.api.catalog.RelationshipsDataFrame

A DataFrame of streamed relationships (with sourceNodeId, targetNodeId and relationshipType columns, plus a column per streamed relationship property) that additionally offers the by_rel_type() convenience method for reshaping the relationships into a GNN-framework-friendly format.

by_rel_type() → dict[str, list[list[Any]]]

Group the relationships by their type.

Returns:

A mapping of relationship type to [[source_node_ids], [target_node_ids]]. If relationship properties were streamed, a list of their values is appended for each property (in column order), i.e. [[source_node_ids], [target_node_ids], [property_values], ...].

Return type:

dict[str, list[list[Any]]]

class graphdatascience.procedure_surface.api.catalog.RelationshipsDropResult
deleted_properties: dict[str, int]
deleted_relationships: int
graph_name: str
relationship_type: str
class graphdatascience.procedure_surface.api.catalog.RelationshipsEndpoints
abstractmethod collapse_path(G: Graph, path_templates: list[list[str]], mutate_relationship_type: str, *, node_labels: list[str] = ['*'], allow_self_loops: bool = False, concurrency: int | None = None, job_id: str | None = None, sudo: bool = False, log_progress: bool = True, username: str | None = None) → CollapsePathResult

Collapse each existing path in the graph into a single relationship.

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

  • path_templates (list[list[str]]) – A path template is an ordered list of relationship types used for the traversal. The same relationship type can be added multiple times, in order to traverse them as indicated. And, you may specify several path templates to process in one go.

  • mutate_relationship_type (str) – Name of the relationship type to store the results in.

  • node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.

  • allow_self_loops (bool) – Whether nodes in the graph can have relationships where start and end nodes are the same.

  • concurrency (int | None) – Number of concurrent threads to use.

  • job_id (str | None) – Identifier for the computation.

  • sudo (bool) – Disable the memory guard.

  • log_progress (bool) – Display progress logging.

  • username (str | None) – As an administrator, impersonate a different user for accessing their graphs.

Returns:

Meta data about the generated relationships.

Return type:

CollapsePathResult

abstractmethod drop(G: Graph, relationship_type: str, *, fail_if_missing: bool = True) → RelationshipsDropResult

Drops all relationships of the specified relationship type, including all their properties, from the graph.

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

  • relationship_type (str) – The relationship type to drop

  • fail_if_missing (bool) – If set to true, the procedure will fail if the relationship type does not exist in the graph.

Returns:

Execution metrics and statistics

Return type:

RelationshipsDropResult

abstractmethod index_inverse(G: Graph, relationship_types: list[str], *, concurrency: int | None = None, sudo: bool = False, log_progress: bool = True, username: str | None = None, job_id: str | None = None) → RelationshipsInverseIndexResult

Creates an index of the specified relationships indexing the reverse direction of each relationship. This index can be used by some algorithm to speed up the computation.

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

  • relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.

  • concurrency (int | None) – Number of concurrent threads to use.

  • sudo (bool) – Disable the memory guard.

  • log_progress (bool) – Display progress logging.

  • username (str | None) – As an administrator, impersonate a different user for accessing their graphs.

  • job_id (str | None) – Identifier for the computation.

Returns:

Execution metrics and statistics

Return type:

RelationshipsInverseIndexResult

abstractmethod stream(G: Graph, relationship_types: list[str] = ['*'], relationship_properties: list[str] | None = None, *, concurrency: int | None = None, sudo: bool = False, log_progress: bool = True, username: str | None = None, job_id: str | None = None) → RelationshipsDataFrame

Streams all relationships of the specified types with the specified properties.

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

  • relationship_types (list[str]) – Filter the graph using the given relationship types. Relationships with any of the given types will be included.

  • relationship_properties (list[str] | None) – The relationship properties to stream. If not specified, no properties will be streamed.

  • concurrency (int | None) – Number of concurrent threads to use.

  • sudo (bool) – Disable the memory guard.

  • log_progress (bool) – Display progress logging.

  • username (str | None) – As an administrator, impersonate a different user for accessing their graphs.

  • job_id (str | None) – Identifier for the computation.

Returns:

The streamed relationships [sourceNodeId, targetNodeId, relationshipType] with a column for each property. Offers a by_rel_type() method to reshape the relationships by relationship type.

Return type:

RelationshipsDataFrame

abstractmethod to_undirected(G: Graph, relationship_type: str, mutate_relationship_type: str, *, aggregation: Aggregation | str | dict[str, Aggregation | str] | None = None, concurrency: int | None = None, sudo: bool = False, log_progress: bool = True, username: str | None = None, job_id: str | None = None) → RelationshipsToUndirectedResult

Creates a new relationship type in the graph. The relationship will be based on an existing relationship type, however, the relationships will be stored undirected.

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

  • relationship_type (str,) – The input relationship type

  • mutate_relationship_type (str,) – Name of the relationship type to store the results in.

  • aggregation (Aggregation | str | dict[str, Aggregation | str] | None) – Specifies how to aggregate parallel relationships in the graph. If a single aggregation is provided, it will be used for properties of the specified relationships. A dictionary can be provided to specify property specific aggregations.

  • concurrency (int | None) – Number of concurrent threads to use.

  • sudo (bool) – Disable the memory guard.

  • log_progress (bool) – Display progress logging.

  • username (str | None) – As an administrator, impersonate a different user for accessing their graphs.

  • job_id (str | None) – Identifier for the computation.

Returns:

Execution metrics and statistics

Return type:

RelationshipsToUndirectedResult

abstractmethod write(G: Graph, relationship_type: str, relationship_properties: list[str] | None = None, *, concurrency: int | None = None, write_concurrency: int | None = None, sudo: bool = False, log_progress: bool = True, username: str | None = None, job_id: str | None = None) → RelationshipsWriteResult

Writes all relationships of the specified relationship type with the specified properties from the graph to the database.

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

  • relationship_type (str) – The relationship type to write to the database

  • relationship_properties (list[str] | None) – The relationship properties to write. If not specified, no properties will be written.

  • concurrency (int | None) – Number of concurrent threads to use.

  • write_concurrency (int | None) – Number of concurrent threads to use for writing.

  • sudo (bool) – Disable the memory guard.

  • log_progress (bool) – Display progress logging.

  • username (str | None) – As an administrator, impersonate a different user for accessing their graphs.

  • job_id (str | None) – Identifier for the computation.

Returns:

Execution metrics and statistics

Return type:

RelationshipsWriteResult

class graphdatascience.procedure_surface.api.catalog.RelationshipsInverseIndexResult
compute_millis: int
configuration: dict[str, Any]
input_relationships: int
mutate_millis: int
post_processing_millis: int
pre_processing_millis: int
class graphdatascience.procedure_surface.api.catalog.RelationshipsToUndirectedResult
relationships_written: int
class graphdatascience.procedure_surface.api.catalog.RelationshipsWriteResult
configuration: dict[str, Any]
graph_name: str
properties_written: int
relationship_properties: list[str]
relationship_type: str
relationships_written: int
write_millis: int
class graphdatascience.procedure_surface.api.catalog.ScalePropertiesEndpoints
abstractmethod estimate(G: Graph | dict[str, Any], node_properties: list[str], scaler: str | dict[str, str | int | float] | ScalerConfig, node_labels: list[str] = ['*'], concurrency: int | None = None) → EstimationResult

Estimate the memory consumption of an algorithm run.

Parameters:
  • G (Graph | dict[str, Any]) – Graph object to use or a dictionary representing the graph dimensions.

  • node_properties (list[str]) – The node properties to scale. Can be a list of property names or a dictionary mapping property names to configurations.

  • scaler (str | dict[str, str | int | float] | ScalerConfig) –

    The scaler to use. Can be:

    • A string (e.g., ‘MinMax’, ‘Mean’, ‘Max’, ‘Log’, ‘StdScore’, ‘Center’, ‘NONE’)

    • A dictionary with scaler configuration (e.g., {‘type’: ‘Log’, ‘offset’: 1.0})

  • node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.

  • concurrency (int | None) – Number of concurrent threads to use.

Returns:

Memory estimation details

Return type:

EstimationResult

abstractmethod mutate(G: Graph, mutate_property: str, node_properties: list[str], scaler: str | dict[str, str | int | float] | ScalerConfig, node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None) → ScalePropertiesMutateResult

Runs the Scale Properties algorithm and stores the results in the graph catalog as a new node property.

Scale Properties scales node properties using a specified scaler (e.g., MinMax, Mean, Max, Log, StdScore, Center).

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

  • mutate_property (str) – Name of the node property to store the results in.

  • node_properties (list[str]) – The node properties to scale. Can be a list of property names or a dictionary mapping property names to configurations.

  • scaler (str | dict[str, str | int | float] | ScalerConfig) –

    The scaler to use. Can be:

    • A string (e.g., ‘MinMax’, ‘Mean’, ‘Max’, ‘Log’, ‘StdScore’, ‘Center’, ‘NONE’)

    • A dictionary with scaler configuration (e.g., {‘type’: ‘Log’, ‘offset’: 1.0})

  • node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.

  • sudo (bool) – Disable the memory guard.

  • log_progress (bool) – Display progress logging.

  • username (str | None) – As an administrator, impersonate a different user for accessing their graphs.

  • concurrency (int | None) – Number of concurrent threads to use.

  • job_id (str | None) – Identifier for the computation.

Returns:

Algorithm metrics and statistics including the scaler statistics

Return type:

ScalePropertiesMutateResult

abstractmethod stats(G: Graph, node_properties: list[str], scaler: str | dict[str, str | int | float] | ScalerConfig, node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None) → ScalePropertiesStatsResult

Runs the Scale Properties algorithm and returns result statistics without storing the results.

Scale Properties scales node properties using a specified scaler (e.g., MinMax, Mean, Max, Log, StdScore, Center).

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

  • node_properties (list[str]) – The node properties to scale. Can be a list of property names or a dictionary mapping property names to configurations.

  • scaler (str | dict[str, str | int | float] | ScalerConfig) –

    The scaler to use. Can be:

    • A string (e.g., ‘MinMax’, ‘Mean’, ‘Max’, ‘Log’, ‘StdScore’, ‘Center’, ‘NONE’)

    • A dictionary with scaler configuration (e.g., {‘type’: ‘Log’, ‘offset’: 1.0})

  • node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.

  • sudo (bool) – Disable the memory guard.

  • log_progress (bool) – Display progress logging.

  • username (str | None) – As an administrator, impersonate a different user for accessing their graphs.

  • concurrency (int | None) – Number of concurrent threads to use.

  • job_id (str | None) – Identifier for the computation.

Returns:

Algorithm statistics including the scaler statistics

Return type:

ScalePropertiesStatsResult

abstractmethod stream(G: Graph, node_properties: list[str], scaler: str | dict[str, str | int | float] | ScalerConfig, node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None) → DataFrame

Executes the Scale Properties algorithm and returns a stream of results.

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

  • node_properties (list[str]) – The node properties to scale. Can be a list of property names or a dictionary mapping property names to configurations.

  • scaler (str | dict[str, str | int | float] | ScalerConfig) –

    The scaler to use. Can be:

    • A string (e.g., ‘MinMax’, ‘Mean’, ‘Max’, ‘Log’, ‘StdScore’, ‘Center’, ‘NONE’)

    • A dictionary with scaler configuration (e.g., {‘type’: ‘Log’, ‘offset’: 1.0})

  • node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.

  • sudo (bool) – Disable the memory guard.

  • log_progress (bool) – Display progress logging.

  • username (str | None) – As an administrator, impersonate a different user for accessing their graphs.

  • concurrency (int | None) – Number of concurrent threads to use.

  • job_id (str | None) – Identifier for the computation.

Returns:

DataFrame with nodeId and scaledProperty columns containing scaled property values. Each row represents a node with its corresponding scaled property values.

Return type:

pandas.DataFrame

abstractmethod write(G: Graph, write_property: str, node_properties: list[str], scaler: str | dict[str, str | int | float] | ScalerConfig, node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None, write_concurrency: int | None = None) → ScalePropertiesWriteResult

Runs the Scale Properties algorithm and stores the result in the Neo4j database as a new node property.

Scale Properties scales node properties using a specified scaler (e.g., MinMax, Mean, Max, Log, StdScore, Center).

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

  • write_property (str) – Name of the node property to store the results in.

  • node_properties (list[str]) – The node properties to scale. Can be a list of property names or a dictionary mapping property names to configurations.

  • scaler (str | dict[str, str | int | float] | ScalerConfig) –

    The scaler to use. Can be:

    • A string (e.g., ‘MinMax’, ‘Mean’, ‘Max’, ‘Log’, ‘StdScore’, ‘Center’, ‘NONE’)

    • A dictionary with scaler configuration (e.g., {‘type’: ‘Log’, ‘offset’: 1.0})

  • node_labels (list[str]) – Filter the graph using the given node labels. Nodes with any of the given labels will be included.

  • sudo (bool) – Disable the memory guard.

  • log_progress (bool) – Display progress logging.

  • username (str | None) – As an administrator, impersonate a different user for accessing their graphs.

  • concurrency (int | None) – Number of concurrent threads to use.

  • job_id (str | None) – Identifier for the computation.

  • write_concurrency (int | None) – Number of concurrent threads to use for writing.Returns

  • -------

  • ScalePropertiesWriteResult – Algorithm metrics and statistics including the scaler statistics and write timing

Return type:

ScalePropertiesWriteResult

class graphdatascience.procedure_surface.api.catalog.ScalePropertiesMutateResult

Result of running Scale Properties algorithm with mutate mode.

compute_millis: int
configuration: dict[str, Any]
mutate_millis: int
node_properties_written: int
post_processing_millis: int
pre_processing_millis: int
scaler_statistics: dict[str, Any]
class graphdatascience.procedure_surface.api.catalog.ScalePropertiesStatsResult

Result of running Scale Properties algorithm with stats mode.

compute_millis: int
configuration: dict[str, Any]
post_processing_millis: int
pre_processing_millis: int
scaler_statistics: dict[str, Any]
class graphdatascience.procedure_surface.api.catalog.ScalePropertiesWriteResult

Result of running Scale Properties algorithm with write mode.

compute_millis: int
configuration: dict[str, Any]
node_properties_written: int
post_processing_millis: int
pre_processing_millis: int
scaler_statistics: dict[str, Any]
write_millis: int
class graphdatascience.procedure_surface.api.catalog.ScalerConfig
offset: int | float | None
type: str
class graphdatascience.procedure_surface.api.catalog.relationships_endpoints.CollapsePathResult
classmethod __new__(*args, **kwargs)
class graphdatascience.procedure_surface.api.collapse_path_endpoints.CollapsePathEndpoints
__init__()
classmethod __new__(*args, **kwargs)