Centrality Algorithms

class graphdatascience.procedure_surface.api.centrality.ArticleRankEndpoints

Bases:

abstractmethod estimate(G: Graph | dict[str, Any], *, damping_factor: float = 0.85, tolerance: float = 1e-07, max_iterations: int = 20, scaler: str | dict[str, str | int | float] | ScalerConfig = 'NONE', relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], concurrency: int | None = None, relationship_weight_property: str | None = None, source_nodes: int | list[int] | list[tuple[int, float]] | 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.

  • damping_factor (float) – Probability of a jump to a random node.

  • tolerance (float) – Minimum change in scores between iterations.

  • max_iterations (int) – Maximum number of iterations to run.

  • 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})

  • 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.

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

  • source_nodes (int | list[int] | list[tuple[int, float]] | None) – node ids to use as starting points. Can be: - single node id (e.g., 42) - list of node id (e.g., [42, 43, 44]) - list of tuples to associate each node with a bias > 0 (e.g., [(42, 0.5), (43, 1.0)])

Returns:

Memory estimation details

Return type:

EstimationResult

abstractmethod mutate(G: Graph, mutate_property: str, *, damping_factor: float = 0.85, tolerance: float = 1e-07, max_iterations: int = 20, scaler: str | dict[str, str | int | float] | ScalerConfig = 'NONE', relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None, relationship_weight_property: str | None = None, source_nodes: int | list[int] | list[tuple[int, float]] | None = None) → ArticleRankMutateResult

Runs the Article Rank algorithm and stores the results in the graph catalog as a new node property.

ArticleRank is a variant of the Page Rank algorithm, which measures the transitive influence of nodes. Page Rank follows the assumption that relationships originating from low-degree nodes have a higher influence than relationships from high-degree nodes. Article Rank lowers the influence of low-degree nodes by lowering the scores being sent to their neighbors in each iteration.

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

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

  • damping_factor (float) – Probability of a jump to a random node.

  • tolerance (float) – Minimum change in scores between iterations.

  • max_iterations (int) – Maximum number of iterations to run.

  • 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})

  • 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.

  • 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.

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

  • source_nodes (int | list[int] | list[tuple[int, float]] | None) – node ids to use as starting points. Can be: - single node id (e.g., 42) - list of node id (e.g., [42, 43, 44]) - list of tuples to associate each node with a bias > 0 (e.g., [(42, 0.5), (43, 1.0)])

Returns:

Algorithm metrics and statistics

Return type:

ArticleRankMutateResult

abstractmethod stats(G: Graph, *, damping_factor: float = 0.85, tolerance: float = 1e-07, max_iterations: int = 20, scaler: str | dict[str, str | int | float] | ScalerConfig = 'NONE', relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None, relationship_weight_property: str | None = None, source_nodes: int | list[int] | list[tuple[int, float]] | None = None) → ArticleRankStatsResult

Runs the Article Rank algorithm and returns result statistics without storing the results.

ArticleRank is a variant of the Page Rank algorithm, which measures the transitive influence of nodes. Page Rank follows the assumption that relationships originating from low-degree nodes have a higher influence than relationships from high-degree nodes. Article Rank lowers the influence of low-degree nodes by lowering the scores being sent to their neighbors in each iteration.

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

  • damping_factor (float) – Probability of a jump to a random node.

  • tolerance (float) – Minimum change in scores between iterations.

  • max_iterations (int) – Maximum number of iterations to run.

  • 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})

  • 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.

  • 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.

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

  • source_nodes (int | list[int] | list[tuple[int, float]] | None) – node ids to use as starting points. Can be: - single node id (e.g., 42) - list of node id (e.g., [42, 43, 44]) - list of tuples to associate each node with a bias > 0 (e.g., [(42, 0.5), (43, 1.0)])

Returns:

Algorithm statistics

Return type:

ArticleRankStatsResult

abstractmethod stream(G: Graph, *, damping_factor: float = 0.85, tolerance: float = 1e-07, max_iterations: int = 20, scaler: str | dict[str, str | int | float] | ScalerConfig = 'NONE', relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None, relationship_weight_property: str | None = None, source_nodes: int | list[int] | list[tuple[int, float]] | None = None) → DataFrame

Executes the ArticleRank algorithm and returns the results as a stream.

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

  • damping_factor (float) – Probability of a jump to a random node.

  • tolerance (float) – Minimum change in scores between iterations.

  • max_iterations (int) – Maximum number of iterations to run.

  • 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})

  • 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.

  • 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.

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

  • source_nodes (int | list[int] | list[tuple[int, float]] | None) – node ids to use as starting points. Can be: - single node id (e.g., 42) - list of node id (e.g., [42, 43, 44]) - list of tuples to associate each node with a bias > 0 (e.g., [(42, 0.5), (43, 1.0)])

Returns:

DataFrame with node IDs and their ArticleRank scores

Return type:

pandas.DataFrame

abstractmethod write(G: Graph, write_property: str, *, damping_factor: float = 0.85, tolerance: float = 1e-07, max_iterations: int = 20, scaler: str | dict[str, str | int | float] | ScalerConfig = 'NONE', relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None, relationship_weight_property: str | None = None, source_nodes: int | list[int] | list[tuple[int, float]] | None = None, write_concurrency: int | None = None) → ArticleRankWriteResult

Runs the Article Rank algorithm and stores the result in the Neo4j database as a new node property.

ArticleRank is a variant of the Page Rank algorithm, which measures the transitive influence of nodes. Page Rank follows the assumption that relationships originating from low-degree nodes have a higher influence than relationships from high-degree nodes. Article Rank lowers the influence of low-degree nodes by lowering the scores being sent to their neighbors in each iteration.

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

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

  • damping_factor (float) – Probability of a jump to a random node.

  • tolerance (float) – Minimum change in scores between iterations.

  • max_iterations (int) – Maximum number of iterations to run.

  • 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})

  • 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.

  • 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.

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

  • source_nodes (int | list[int] | list[tuple[int, float]] | None) – node ids to use as starting points. Can be: - single node id (e.g., 42) - list of node id (e.g., [42, 43, 44]) - list of tuples to associate each node with a bias > 0 (e.g., [(42, 0.5), (43, 1.0)])

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

  • -------

  • ArticleRankWriteResult – Algorithm metrics and statistics

Return type:

ArticleRankWriteResult

class graphdatascience.procedure_surface.api.centrality.ArticleRankMutateResult

Bases: BaseResult

centrality_distribution: dict[str, Any]
compute_millis: int
configuration: dict[str, Any]
did_converge: bool
mutate_millis: int
node_properties_written: int
post_processing_millis: int
pre_processing_millis: int
ran_iterations: int
class graphdatascience.procedure_surface.api.centrality.ArticleRankSessionEndpoints

Bases: ArticleRankEndpoints

Article Rank endpoints as exposed by a GDS Session.

abstractmethod compute(G: Graph, *, damping_factor: float = 0.85, tolerance: float = 1e-07, max_iterations: int = 20, scaler: str | dict[str, str | int | float] | ScalerConfig = 'NONE', relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None, relationship_weight_property: str | None = None, source_nodes: int | list[int] | list[tuple[int, float]] | None = None) → JobHandle

Starts the computation as a job and returns a handle to it.

The computation runs without materializing its result. Use the returned handle to mutate, write or stream the result afterwards.

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

  • damping_factor (float) – Probability of a jump to a random node.

  • tolerance (float) – Minimum change in scores between iterations.

  • max_iterations (int) – Maximum number of iterations to run.

  • 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}) - - A ScalerConfig instance

  • 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.

  • 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.

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

  • source_nodes (int | list[int] | list[tuple[int, float]] | None) – node ids to use as starting points. Can be: - single node id (e.g., 42) - list of node id (e.g., [42, 43, 44]) - list of tuples to associate each node with a bias > 0 (e.g., [(42, 0.5), (43, 1.0)])

Returns:

Handle to the started computation

Return type:

JobHandle

class graphdatascience.procedure_surface.api.centrality.ArticleRankStatsResult

Bases: BaseResult

centrality_distribution: dict[str, Any]
compute_millis: int
configuration: dict[str, Any]
did_converge: bool
post_processing_millis: int
pre_processing_millis: int
ran_iterations: int
class graphdatascience.procedure_surface.api.centrality.ArticleRankWriteResult

Bases: BaseResult

centrality_distribution: dict[str, Any]
compute_millis: int
configuration: dict[str, Any]
did_converge: bool
node_properties_written: int
post_processing_millis: int
pre_processing_millis: int
ran_iterations: int
write_millis: int
class graphdatascience.procedure_surface.api.centrality.ArticulationPointsEndpoints

Bases:

abstractmethod estimate(G: Graph | dict[str, Any], relationship_types: list[str] = ['*'], 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.

  • 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:

An object containing the result of the estimation including memory requirements

Return type:

EstimationResult

abstractmethod mutate(G: Graph, mutate_property: str, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None) → ArticulationPointsMutateResult

Runs the Articulation Points algorithm and stores the results in the graph catalog as a new node property.

Given a graph, an articulation point is a node whose removal increases the number of connected components in the graph.

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

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

  • 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.

  • 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 count of articulation points found

Return type:

ArticulationPointsMutateResult

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

Runs the Articulation Points algorithm and returns result statistics without storing the results.

Given a graph, an articulation point is a node whose removal increases the number of connected components in the graph.

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.

  • 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 count of articulation points found

Return type:

ArticulationPointsStatsResult

abstractmethod stream(G: Graph, relationship_types: list[str] = ['*'], 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 ArticulationPoints algorithm and returns results as a stream.

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.

  • 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:

A DataFrame with ‘nodeId’ and ‘resultingComponents’ columns. The ‘resultingComponents’ column contains a map with ‘min’, ‘max’, and ‘count’ keys describing the resulting components when the node is removed (null for non-articulation-point nodes).

Return type:

pandas.DataFrame

abstractmethod write(G: Graph, write_property: str, relationship_types: list[str] = ['*'], 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) → ArticulationPointsWriteResult

Runs the Articulation Points algorithm and stores the result in the Neo4j database as a new node property.

Given a graph, an articulation point is a node whose removal increases the number of connected components in the graph.

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

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

  • 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.

  • 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

  • -------

  • ArticulationPointsWriteResult – Algorithm metrics and statistics including the count of articulation points found

Return type:

ArticulationPointsWriteResult

class graphdatascience.procedure_surface.api.centrality.ArticulationPointsMutateResult

Bases: BaseResult

Result of running ArticulationPoints algorithm with mutate mode.

articulation_point_count: int
compute_millis: int
configuration: dict[str, Any]
mutate_millis: int
node_properties_written: int
class graphdatascience.procedure_surface.api.centrality.ArticulationPointsSessionEndpoints

Bases: ArticulationPointsEndpoints

ArticulationPoints endpoints as exposed by a GDS Session.

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

Starts the computation as a job and returns a handle to it.

The computation runs without materializing its result. Use the returned handle to mutate, write or stream the result afterwards.

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.

  • 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:

Handle to the started computation

Return type:

JobHandle

class graphdatascience.procedure_surface.api.centrality.ArticulationPointsStatsResult

Bases: BaseResult

Result of running ArticulationPoints algorithm with stats mode.

articulation_point_count: int
compute_millis: int
configuration: dict[str, Any]
class graphdatascience.procedure_surface.api.centrality.ArticulationPointsWriteResult

Bases: BaseResult

Result of running ArticulationPoints algorithm with write mode.

articulation_point_count: int
compute_millis: int
configuration: dict[str, Any]
node_properties_written: int
write_millis: int
class graphdatascience.procedure_surface.api.centrality.BetweennessEndpoints

Bases:

abstractmethod estimate(G: Graph | dict[str, Any], sampling_size: int | None = None, sampling_seed: int | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], concurrency: int | None = None, relationship_weight_property: str | 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.

  • sampling_size (int | None) – The number of nodes to use for sampling.

  • sampling_seed (int | None) – The seed value for sampling randomization

  • 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.

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

Returns:

Memory estimation details

Return type:

EstimationResult

abstractmethod mutate(G: Graph, mutate_property: str, sampling_size: int | None = None, sampling_seed: int | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None, relationship_weight_property: str | None = None) → BetweennessMutateResult

Runs the Betweenness Centrality algorithm and stores the results in the graph catalog as a new node property.

Betweenness centrality is a way of detecting the amount of influence a node has over the flow of information in a graph. It is often used to find nodes that serve as a bridge from one part of a graph to another. The algorithm calculates shortest paths between all pairs of nodes in a graph. Each node receives a score, based on the number of shortest paths that pass through the node.

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

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

  • sampling_size (int | None) – Number of source nodes to consider for computing centrality scores.

  • sampling_seed (int | None) – Seed value for the random number generator that selects source nodes.

  • 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.

  • 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.

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

Returns:

Algorithm metrics and statistics including centrality distribution

Return type:

BetweennessMutateResult

abstractmethod stats(G: Graph, sampling_size: int | None = None, sampling_seed: int | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None, relationship_weight_property: str | None = None) → BetweennessStatsResult

Runs the Betweenness Centrality algorithm and returns result statistics without storing the results.

Betweenness centrality is a way of detecting the amount of influence a node has over the flow of information in a graph. It is often used to find nodes that serve as a bridge from one part of a graph to another. The algorithm calculates shortest paths between all pairs of nodes in a graph. Each node receives a score, based on the number of shortest paths that pass through the node.

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

  • sampling_size (int | None) – Number of source nodes to consider for computing centrality scores.

  • sampling_seed (int | None) – Seed value for the random number generator that selects source nodes.

  • 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.

  • 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.

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

Returns:

Algorithm statistics including centrality distribution

Return type:

BetweennessStatsResult

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

Executes the Betweenness Centrality algorithm and returns the results as a stream.

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

  • sampling_size (int | None) – The number of nodes to use for sampling.

  • sampling_seed (int | None) – The seed value for sampling randomization

  • 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.

  • 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.

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

Returns:

DataFrame with nodeId and score columns containing betweenness centrality results

Return type:

pandas.DataFrame

abstractmethod write(G: Graph, write_property: str, sampling_size: int | None = None, sampling_seed: int | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None, relationship_weight_property: str | None = None, write_concurrency: int | None = None) → BetweennessWriteResult

Runs the Betweenness Centrality algorithm and stores the result in the Neo4j database as a new node property.

Betweenness centrality is a way of detecting the amount of influence a node has over the flow of information in a graph. It is often used to find nodes that serve as a bridge from one part of a graph to another. The algorithm calculates shortest paths between all pairs of nodes in a graph. Each node receives a score, based on the number of shortest paths that pass through the node.

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

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

  • sampling_size (int | None) – Number of source nodes to consider for computing centrality scores.

  • sampling_seed (int | None) – Seed value for the random number generator that selects source nodes.

  • 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.

  • 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.

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

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

  • -------

  • BetweennessWriteResult – Algorithm metrics and statistics including centrality distribution

Return type:

BetweennessWriteResult

class graphdatascience.procedure_surface.api.centrality.BetweennessMutateResult

Bases: BaseResult

Result of running Betweenness Centrality algorithm with mutate mode.

centrality_distribution: dict[str, Any]
compute_millis: int
configuration: dict[str, Any]
mutate_millis: int
node_properties_written: int
post_processing_millis: int
pre_processing_millis: int
class graphdatascience.procedure_surface.api.centrality.BetweennessSessionEndpoints

Bases: BetweennessEndpoints

Betweenness endpoints as exposed by a GDS Session.

abstractmethod compute(G: Graph, *, sampling_size: int | None = None, sampling_seed: int | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None, relationship_weight_property: str | None = None) → JobHandle

Starts the computation as a job and returns a handle to it.

The computation runs without materializing its result. Use the returned handle to mutate, write or stream the result afterwards.

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

  • sampling_size (int | None) – Number of source nodes to consider for computing centrality scores.

  • sampling_seed (int | None) – Seed value for the random number generator that selects source nodes.

  • 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.

  • 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.

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

Returns:

Handle to the started computation

Return type:

JobHandle

class graphdatascience.procedure_surface.api.centrality.BetweennessStatsResult

Bases: BaseResult

Result of running Betweenness Centrality algorithm with stats mode.

centrality_distribution: dict[str, Any]
compute_millis: int
configuration: dict[str, Any]
post_processing_millis: int
pre_processing_millis: int
class graphdatascience.procedure_surface.api.centrality.BetweennessWriteResult

Bases: BaseResult

Result of running Betweenness Centrality algorithm with write mode.

centrality_distribution: dict[str, Any]
compute_millis: int
configuration: dict[str, Any]
node_properties_written: int
post_processing_millis: int
pre_processing_millis: int
write_millis: int
class graphdatascience.procedure_surface.api.centrality.BridgesEndpoints

Bases:

abstractmethod estimate(G: Graph | dict[str, Any], relationship_types: list[str] = ['*'], 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.

  • 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 stream(G: Graph, relationship_types: list[str] = ['*'], 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 Bridges algorithm and returns a stream of results.

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.

  • 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 ‘from’, ‘to’ and ‘remainingSizes’ columns. The remainingSizes column contains the sizes of the remaining connected components after removing the bridge relationship.

Return type:

pandas.DataFrame

class graphdatascience.procedure_surface.api.centrality.BridgesSessionEndpoints

Bases: BridgesEndpoints

Bridges endpoints as exposed by a GDS Session.

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

Starts the computation as a job and returns a handle to it.

The computation runs without materializing its result. Use the returned handle to mutate, write or stream the result afterwards.

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.

  • 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:

Handle to the started computation

Return type:

JobHandle

class graphdatascience.procedure_surface.api.centrality.CelfEndpoints

Bases:

abstractmethod estimate(G: Graph | dict[str, Any], seed_set_size: int, propagation_probability: float = 0.1, monte_carlo_simulations: int = 100, random_seed: int | None = None, relationship_types: list[str] = ['*'], 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.

  • seed_set_size (int) – The number of nodes to select as the seed set for influence maximization.

  • propagation_probability (float) – The probability that influence spreads from one node to another.

  • monte_carlo_simulations (int) – The number of Monte-Carlo simulations.

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

  • 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:

An object containing the result of the estimation including memory requirements

Return type:

EstimationResult

abstractmethod mutate(G: Graph, seed_set_size: int, mutate_property: str, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], monte_carlo_simulations: int = 100, propagation_probability: float = 0.1, 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) → CelfMutateResult

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

The influence maximization problem asks for a set of k nodes that maximize the expected spread of influence in the network.

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

  • seed_set_size (int) – The number of nodes to select as the seed set for influence maximization

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

  • propagation_probability (float) – Probability of a node being activated by an active neighbour node.

  • monte_carlo_simulations (int) – Number of Monte-Carlo simulations.

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

  • 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.

  • 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 total influence spread

Return type:

CelfMutateResult

abstractmethod stats(G: Graph, seed_set_size: int, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], monte_carlo_simulations: int = 100, propagation_probability: float = 0.1, 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) → CelfStatsResult

Runs the CELF algorithm and returns result statistics without storing the results.

The influence maximization problem asks for a set of k nodes that maximize the expected spread of influence in the network.

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

  • seed_set_size (int) – The number of nodes to select as the seed set for influence maximization

  • propagation_probability (float) – Probability of a node being activated by an active neighbour node.

  • monte_carlo_simulations (int) – Number of Monte-Carlo simulations.

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

  • 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.

  • 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 total influence spread

Return type:

CelfStatsResult

abstractmethod stream(G: Graph, seed_set_size: int, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], monte_carlo_simulations: int = 100, propagation_probability: float = 0.1, 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) → DataFrame

Executes the CELF algorithm and returns a stream of results.

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

  • seed_set_size (int) – The number of nodes to select as the seed set for influence maximization

  • propagation_probability (float) – The probability that influence spreads from one node to another.

  • monte_carlo_simulations (int) – The number of Monte-Carlo simulations.

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

  • 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.

  • 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 spread columns containing CELF results. Each row represents a selected node with its corresponding influence spread value.

Return type:

pandas.DataFrame

abstractmethod write(G: Graph, seed_set_size: int, write_property: str, propagation_probability: float = 0.1, monte_carlo_simulations: int = 100, random_seed: int | None = None, relationship_types: list[str] = ['*'], 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) → CelfWriteResult

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

The influence maximization problem asks for a set of k nodes that maximize the expected spread of influence in the network.

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

  • seed_set_size (int) – The number of nodes to select as the seed set for influence maximization

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

  • propagation_probability (float) – Probability of a node being activated by an active neighbour node.

  • monte_carlo_simulations (int) – Number of Monte-Carlo simulations.

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

  • 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.

  • 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

  • -------

  • CelfWriteResult – Algorithm metrics and statistics including the total influence spread and write timing

Return type:

CelfWriteResult

class graphdatascience.procedure_surface.api.centrality.CelfMutateResult

Bases: BaseResult

Result of running CELF algorithm with mutate mode.

compute_millis: int
configuration: dict[str, Any]
mutate_millis: int
node_count: int
node_properties_written: int
total_spread: float
class graphdatascience.procedure_surface.api.centrality.CelfSessionEndpoints

Bases: CelfEndpoints

Celf endpoints as exposed by a GDS Session.

abstractmethod compute(G: Graph, seed_set_size: int, *, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], monte_carlo_simulations: int = 100, propagation_probability: float = 0.1, 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) → JobHandle

Starts the computation as a job and returns a handle to it.

The computation runs without materializing its result. Use the returned handle to mutate, write or stream the result afterwards.

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

  • seed_set_size (int) – The number of nodes to select as the seed set for influence maximization

  • 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.

  • monte_carlo_simulations (int) – Number of Monte-Carlo simulations.

  • propagation_probability (float) – Probability of a node being activated by an active neighbour node.

  • 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.

Returns:

Handle to the started computation

Return type:

JobHandle

class graphdatascience.procedure_surface.api.centrality.CelfStatsResult

Bases: BaseResult

Result of running CELF algorithm with stats mode.

compute_millis: int
configuration: dict[str, Any]
node_count: int
total_spread: float
class graphdatascience.procedure_surface.api.centrality.CelfWriteResult

Bases: BaseResult

Result of running CELF algorithm with write mode.

compute_millis: int
configuration: dict[str, Any]
node_count: int
node_properties_written: int
total_spread: float
write_millis: int
class graphdatascience.procedure_surface.api.centrality.ClosenessEndpoints

Bases:

abstractmethod estimate(G: Graph | dict[str, Any], use_wasserman_faust: bool = False, relationship_types: list[str] = ['*'], 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.

  • use_wasserman_faust (bool) – Use the improved Wasserman-Faust formula for closeness computation.

  • 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:

An object containing the result of the estimation

Return type:

EstimationResult

abstract property harmonic: ClosenessHarmonicEndpoints

Return endpoints for the harmonic centrality algorithm, a variant of closeness centrality.

abstractmethod mutate(G: Graph, mutate_property: str, use_wasserman_faust: bool = False, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None) → ClosenessMutateResult

Runs the Closeness Centrality algorithm and stores the results in the graph catalog as a new node property.

Closeness centrality is a way of detecting nodes that are able to spread information very efficiently through a graph. The closeness centrality of a node measures its average farness (inverse distance) to all other nodes. Nodes with a high closeness score have the shortest distances to all other nodes.

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

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

  • use_wasserman_faust (bool) – Use the improved Wasserman-Faust formula for closeness computation.

  • 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.

  • 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 centrality distribution

Return type:

ClosenessMutateResult

abstractmethod stats(G: Graph, use_wasserman_faust: bool = False, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None) → ClosenessStatsResult

Runs the Closeness Centrality algorithm and returns result statistics without storing the results.

Closeness centrality is a way of detecting nodes that are able to spread information very efficiently through a graph. The closeness centrality of a node measures its average farness (inverse distance) to all other nodes. Nodes with a high closeness score have the shortest distances to all other nodes.

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

  • use_wasserman_faust (bool) – Use the improved Wasserman-Faust formula for closeness computation.

  • 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.

  • 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 centrality distribution

Return type:

ClosenessStatsResult

abstractmethod stream(G: Graph, use_wasserman_faust: bool = False, relationship_types: list[str] = ['*'], 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 Closeness Centrality algorithm and returns a stream of results.

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

  • use_wasserman_faust (bool) – Use the improved Wasserman-Faust formula for closeness computation.

  • 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.

  • 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 score columns containing closeness centrality results. Each row represents a node with its corresponding closeness centrality score.

Return type:

pandas.DataFrame

abstractmethod write(G: Graph, write_property: str, use_wasserman_faust: bool = False, relationship_types: list[str] = ['*'], 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) → ClosenessWriteResult

Runs the Closeness Centrality algorithm and stores the result in the Neo4j database as a new node property.

Closeness centrality is a way of detecting nodes that are able to spread information very efficiently through a graph. The closeness centrality of a node measures its average farness (inverse distance) to all other nodes. Nodes with a high closeness score have the shortest distances to all other nodes.

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

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

  • use_wasserman_faust (bool) – Use the improved Wasserman-Faust formula for closeness computation.

  • 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.

  • 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

  • -------

  • ClosenessWriteResult – Algorithm metrics and statistics including the number of properties written

Return type:

ClosenessWriteResult

class graphdatascience.procedure_surface.api.centrality.ClosenessHarmonicEndpoints

Bases:

abstractmethod estimate(G: Graph | dict[str, Any], relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], concurrency: int | None = None) → EstimationResult

Estimate the memory consumption of a Harmonic Closeness Centrality algorithm run.

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

  • 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:

An object containing the result of the estimation

Return type:

EstimationResult

abstractmethod mutate(G: Graph, mutate_property: str, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None) → ClosenessHarmonicMutateResult

Runs the Harmonic Centrality algorithm and stores the results in the graph catalog as a new node property.

Harmonic centrality (also known as valued centrality) is a variant of closeness centrality, that was invented to solve the problem the original formula had when dealing with unconnected graphs.

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

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

  • 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.

  • 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 centrality distribution

Return type:

ClosenessHarmonicMutateResult

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

Runs the Harmonic Centrality algorithm and returns result statistics without storing the results.

Harmonic centrality was proposed by Marchiori and Latora while trying to come up with a sensible notion of “average shortest path”. They suggested a different way of calculating the average distance to that used in the Closeness Centrality algorithm. Rather than summing the distances of a node to all other nodes, the harmonic centrality algorithm sums the inverse of those distances. This enables it deal with infinite values.

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.

  • 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 centrality distribution

Return type:

ClosenessHarmonicStatsResult

abstractmethod stream(G: Graph, relationship_types: list[str] = ['*'], 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 Harmonic Closeness Centrality algorithm and returns a stream of results.

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.

  • 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 the algorithm results containing nodeId and score columns

Return type:

pandas.DataFrame

abstractmethod write(G: Graph, write_property: str, relationship_types: list[str] = ['*'], 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) → ClosenessHarmonicWriteResult

Runs the Harmonic Centrality algorithm and stores the result in the Neo4j database as a new node property.

Harmonic centrality was proposed by Marchiori and Latora while trying to come up with a sensible notion of “average shortest path”. They suggested a different way of calculating the average distance to that used in the Closeness Centrality algorithm. Rather than summing the distances of a node to all other nodes, the harmonic centrality algorithm sums the inverse of those distances. This enables it deal with infinite values.

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

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

  • 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.

  • 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

  • -------

  • ClosenessHarmonicWriteResult – Algorithm metrics and statistics including the centrality distribution

Return type:

ClosenessHarmonicWriteResult

class graphdatascience.procedure_surface.api.centrality.ClosenessHarmonicMutateResult

Bases: BaseResult

Result of running Harmonic Closeness Centrality algorithm with mutate mode.

centrality_distribution: dict[str, Any]
compute_millis: int
configuration: dict[str, Any]
mutate_millis: int
node_properties_written: int
post_processing_millis: int
pre_processing_millis: int
class graphdatascience.procedure_surface.api.centrality.ClosenessHarmonicSessionEndpoints

Bases: ClosenessHarmonicEndpoints

ClosenessHarmonic endpoints as exposed by a GDS Session.

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

Starts the computation as a job and returns a handle to it.

The computation runs without materializing its result. Use the returned handle to mutate, write or stream the result afterwards.

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.

  • 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:

Handle to the started computation

Return type:

JobHandle

class graphdatascience.procedure_surface.api.centrality.ClosenessHarmonicStatsResult

Bases: BaseResult

Result of running Harmonic Closeness Centrality algorithm with stats mode.

centrality_distribution: dict[str, Any]
compute_millis: int
configuration: dict[str, Any]
post_processing_millis: int
pre_processing_millis: int
class graphdatascience.procedure_surface.api.centrality.ClosenessHarmonicWriteResult

Bases: BaseResult

Result of running Harmonic Closeness Centrality algorithm with write mode.

centrality_distribution: dict[str, Any]
compute_millis: int
configuration: dict[str, Any]
node_properties_written: int
post_processing_millis: int
pre_processing_millis: int
write_millis: int
class graphdatascience.procedure_surface.api.centrality.ClosenessMutateResult

Bases: BaseResult

Result of running Closeness Centrality algorithm with mutate mode.

centrality_distribution: dict[str, Any]
compute_millis: int
configuration: dict[str, Any]
mutate_millis: int
node_properties_written: int
post_processing_millis: int
pre_processing_millis: int
class graphdatascience.procedure_surface.api.centrality.ClosenessSessionEndpoints

Bases: ClosenessEndpoints

Closeness endpoints as exposed by a GDS Session.

abstractmethod compute(G: Graph, *, use_wasserman_faust: bool = False, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None) → JobHandle

Starts the computation as a job and returns a handle to it.

The computation runs without materializing its result. Use the returned handle to mutate, write or stream the result afterwards.

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

  • use_wasserman_faust (bool) – Use the improved Wasserman-Faust formula for closeness computation.

  • 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.

  • 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:

Handle to the started computation

Return type:

JobHandle

abstract property harmonic: ClosenessHarmonicSessionEndpoints

Return endpoints for the harmonic centrality algorithm, a variant of closeness centrality.

class graphdatascience.procedure_surface.api.centrality.ClosenessStatsResult

Bases: BaseResult

Result of running Closeness Centrality algorithm with stats mode.

centrality_distribution: dict[str, Any]
compute_millis: int
configuration: dict[str, Any]
post_processing_millis: int
pre_processing_millis: int
class graphdatascience.procedure_surface.api.centrality.ClosenessWriteResult

Bases: BaseResult

Result of running Closeness Centrality algorithm with write mode.

centrality_distribution: dict[str, Any]
compute_millis: int
configuration: dict[str, Any]
node_properties_written: int
post_processing_millis: int
pre_processing_millis: int
write_millis: int
class graphdatascience.procedure_surface.api.centrality.DegreeEndpoints

Bases:

abstractmethod estimate(G: Graph | dict[str, Any], orientation: str = 'NATURAL', relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], concurrency: int | None = None, relationship_weight_property: str | 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.

  • orientation (str) – The orientation of relationships to consider. Can be ‘NATURAL’, ‘REVERSE’, or ‘UNDIRECTED’.

  • 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.

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

Returns:

Memory estimation details

Return type:

EstimationResult

abstractmethod mutate(G: Graph, mutate_property: str, orientation: str = 'NATURAL', relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None, relationship_weight_property: str | None = None) → DegreeMutateResult

Runs the Degree Centrality algorithm and stores the results in the graph catalog as a new node property.

The Degree Centrality algorithm can be used to find popular nodes within a graph. The degree centrality measures the number of incoming or outgoing (or both) relationships from a node, which can be defined by the orientation of a relationship projection. It can be applied to either weighted or unweighted graphs. In the weighted case the algorithm computes the sum of all positive weights of adjacent relationships of a node, for each node in the graph.

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

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

  • orientation (str) – The orientation of relationships to consider. Can be ‘NATURAL’, ‘REVERSE’, or ‘UNDIRECTED’.

  • 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.

  • 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.

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

Returns:

Algorithm metrics and statistics including the centrality distribution

Return type:

DegreeMutateResult

abstractmethod stats(G: Graph, orientation: str = 'NATURAL', relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None, relationship_weight_property: str | None = None) → DegreeStatsResult

Runs the Degree Centrality algorithm and returns result statistics without storing the results.

The Degree Centrality algorithm can be used to find popular nodes within a graph. The degree centrality measures the number of incoming or outgoing (or both) relationships from a node, which can be defined by the orientation of a relationship projection. It can be applied to either weighted or unweighted graphs. In the weighted case the algorithm computes the sum of all positive weights of adjacent relationships of a node, for each node in the graph.

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

  • orientation (str) – The orientation of relationships to consider. Can be ‘NATURAL’, ‘REVERSE’, or ‘UNDIRECTED’.

  • 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.

  • 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.

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

Returns:

Algorithm statistics including the centrality distribution

Return type:

DegreeStatsResult

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

Executes the Degree Centrality algorithm and returns a stream of results.

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

  • orientation (str) – The orientation of relationships to consider. Can be ‘NATURAL’, ‘REVERSE’, or ‘UNDIRECTED’. ‘NATURAL’ (default) respects the direction of relationships as they are stored in the graph. ‘REVERSE’ treats each relationship as if it were directed in the opposite direction. ‘UNDIRECTED’ treats all relationships as undirected, effectively counting both directions.

  • 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.

  • 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.

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

Returns:

DataFrame with nodeId and score columns containing degree centrality results. Each row represents a node with its corresponding degree centrality score.

Return type:

pandas.DataFrame

abstractmethod write(G: Graph, write_property: str, orientation: str = 'NATURAL', relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None, relationship_weight_property: str | None = None, write_concurrency: int | None = None) → DegreeWriteResult

Runs the Degree Centrality algorithm and stores the result in the Neo4j database as a new node property.

The Degree Centrality algorithm can be used to find popular nodes within a graph. The degree centrality measures the number of incoming or outgoing (or both) relationships from a node, which can be defined by the orientation of a relationship projection. It can be applied to either weighted or unweighted graphs. In the weighted case the algorithm computes the sum of all positive weights of adjacent relationships of a node, for each node in the graph.

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

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

  • orientation (str) – The orientation of relationships to consider. Can be ‘NATURAL’, ‘REVERSE’, or ‘UNDIRECTED’.

  • 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.

  • 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.

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

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

  • -------

  • DegreeWriteResult – Algorithm metrics and statistics including the centrality distribution and write timing

Return type:

DegreeWriteResult

class graphdatascience.procedure_surface.api.centrality.DegreeMutateResult

Bases: BaseResult

Result of running Degree Centrality algorithm with mutate mode.

centrality_distribution: dict[str, Any]
compute_millis: int
configuration: dict[str, Any]
mutate_millis: int
node_properties_written: int
post_processing_millis: int
pre_processing_millis: int
class graphdatascience.procedure_surface.api.centrality.DegreeSessionEndpoints

Bases: DegreeEndpoints

Degree endpoints as exposed by a GDS Session.

abstractmethod compute(G: Graph, *, orientation: str = 'NATURAL', relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None, relationship_weight_property: str | None = None) → JobHandle

Starts the computation as a job and returns a handle to it.

The computation runs without materializing its result. Use the returned handle to mutate, write or stream the result afterwards.

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

  • orientation (str) – The orientation of relationships to consider. Can be ‘NATURAL’, ‘REVERSE’, or ‘UNDIRECTED’.

  • 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.

  • 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.

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

Returns:

Handle to the started computation

Return type:

JobHandle

class graphdatascience.procedure_surface.api.centrality.DegreeStatsResult

Bases: BaseResult

Result of running Degree Centrality algorithm with stats mode.

centrality_distribution: dict[str, Any]
compute_millis: int
configuration: dict[str, Any]
post_processing_millis: int
pre_processing_millis: int
class graphdatascience.procedure_surface.api.centrality.DegreeWriteResult

Bases: BaseResult

Result of running Degree Centrality algorithm with write mode.

centrality_distribution: dict[str, Any]
compute_millis: int
configuration: dict[str, Any]
node_properties_written: int
post_processing_millis: int
pre_processing_millis: int
write_millis: int
class graphdatascience.procedure_surface.api.centrality.EigenvectorEndpoints

Bases:

abstractmethod estimate(G: Graph | dict[str, Any], max_iterations: int = 20, tolerance: float = 1e-07, source_nodes: int | list[int] | None = None, scaler: str | dict[str, str | int | float] | ScalerConfig = 'NONE', relationship_weight_property: str | None = None, relationship_types: list[str] = ['*'], 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.

  • max_iterations (int) – Maximum number of iterations to run.

  • tolerance (float) – Minimum change in scores between iterations.

  • source_nodes (int | list[int] | None) – node ids to use as starting points. Can be: - single node id (e.g., 42) - list of node id (e.g., [42, 43, 44])

  • 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})

  • 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:

An object containing the result of the estimation

Return type:

EstimationResult

abstractmethod mutate(G: Graph, mutate_property: str, max_iterations: int = 20, tolerance: float = 1e-07, source_nodes: int | list[int] | None = None, scaler: str | dict[str, str | int | float] | ScalerConfig = 'NONE', relationship_weight_property: str | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None) → EigenvectorMutateResult

Runs the Eigenvector Centrality algorithm and stores the results in the graph catalog as a new node property.

Eigenvector Centrality is an algorithm that measures the transitive influence of nodes. Relationships originating from high-scoring nodes contribute more to the score of a node than connections from low-scoring nodes. A high eigenvector score means that a node is connected to many nodes who themselves have high scores. The algorithm computes the eigenvector associated with the largest absolute eigenvalue.

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

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

  • max_iterations (int) – Maximum number of iterations to run.

  • tolerance (float) – Minimum change in scores between iterations.

  • source_nodes (int | list[int] | None) – node ids to use as starting points. Can be: - single node id (e.g., 42) - list of node id (e.g., [42, 43, 44])

  • 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})

  • 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.

  • 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 centrality distribution

Return type:

EigenvectorMutateResult

abstractmethod stats(G: Graph, max_iterations: int = 20, tolerance: float = 1e-07, source_nodes: int | list[int] | None = None, scaler: str | dict[str, str | int | float] | ScalerConfig = 'NONE', relationship_weight_property: str | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None) → EigenvectorStatsResult

Runs the Eigenvector Centrality algorithm and returns result statistics without storing the results.

Eigenvector Centrality is an algorithm that measures the transitive influence of nodes. Relationships originating from high-scoring nodes contribute more to the score of a node than connections from low-scoring nodes. A high eigenvector score means that a node is connected to many nodes who themselves have high scores. The algorithm computes the eigenvector associated with the largest absolute eigenvalue.

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

  • max_iterations (int) – Maximum number of iterations to run.

  • tolerance (float) – Minimum change in scores between iterations.

  • source_nodes (int | list[int] | None) – node ids to use as starting points. Can be: - single node id (e.g., 42) - list of node id (e.g., [42, 43, 44])

  • 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})

  • 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.

  • 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 centrality distribution

Return type:

EigenvectorStatsResult

abstractmethod stream(G: Graph, max_iterations: int = 20, tolerance: float = 1e-07, source_nodes: int | list[int] | None = None, scaler: str | dict[str, str | int | float] | ScalerConfig = 'NONE', relationship_weight_property: str | None = None, relationship_types: list[str] = ['*'], 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 Eigenvector Centrality algorithm and returns a stream of results.

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

  • max_iterations (int) – Maximum number of iterations to run.

  • tolerance (float) – Minimum change in scores between iterations.

  • source_nodes (int | list[int] | None) – node ids to use as starting points. Can be: - single node id (e.g., 42) - list of node id (e.g., [42, 43, 44])

  • 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})

  • 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.

  • 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 the algorithm results containing nodeId and score columns

Return type:

pandas.DataFrame

abstractmethod write(G: Graph, write_property: str, max_iterations: int = 20, tolerance: float = 1e-07, source_nodes: int | list[int] | None = None, scaler: str | dict[str, str | int | float] | ScalerConfig = 'NONE', relationship_weight_property: str | None = None, relationship_types: list[str] = ['*'], 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) → EigenvectorWriteResult

Runs the Eigenvector Centrality algorithm and stores the result in the Neo4j database as a new node property.

Eigenvector Centrality is an algorithm that measures the transitive influence of nodes. Relationships originating from high-scoring nodes contribute more to the score of a node than connections from low-scoring nodes. A high eigenvector score means that a node is connected to many nodes who themselves have high scores. The algorithm computes the eigenvector associated with the largest absolute eigenvalue.

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

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

  • max_iterations (int) – Maximum number of iterations to run.

  • tolerance (float) – Minimum change in scores between iterations.

  • source_nodes (int | list[int] | None) – node ids to use as starting points. Can be: - single node id (e.g., 42) - list of node id (e.g., [42, 43, 44])

  • 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})

  • 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.

  • 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

  • -------

  • EigenvectorWriteResult – Algorithm metrics and statistics including the centrality distribution

Return type:

EigenvectorWriteResult

class graphdatascience.procedure_surface.api.centrality.EigenvectorMutateResult

Bases: BaseResult

Result of running Eigenvector Centrality algorithm with mutate mode.

centrality_distribution: dict[str, Any]
compute_millis: int
configuration: dict[str, Any]
did_converge: bool
mutate_millis: int
node_properties_written: int
post_processing_millis: int
pre_processing_millis: int
ran_iterations: int
class graphdatascience.procedure_surface.api.centrality.EigenvectorSessionEndpoints

Bases: EigenvectorEndpoints

Eigenvector endpoints as exposed by a GDS Session.

abstractmethod compute(G: Graph, *, max_iterations: int = 20, tolerance: float = 1e-07, source_nodes: int | list[int] | None = None, scaler: str | dict[str, str | int | float] | ScalerConfig = 'NONE', relationship_weight_property: str | None = None, relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None) → JobHandle

Starts the computation as a job and returns a handle to it.

The computation runs without materializing its result. Use the returned handle to mutate, write or stream the result afterwards.

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

  • max_iterations (int) – Maximum number of iterations to run.

  • tolerance (float) – Minimum change in scores between iterations.

  • source_nodes (int | list[int] | None) – node ids to use as starting points. Can be: - single node id (e.g., 42) - list of node id (e.g., [42, 43, 44])

  • 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}) - - A ScalerConfig instance

  • 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.

  • 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:

Handle to the started computation

Return type:

JobHandle

class graphdatascience.procedure_surface.api.centrality.EigenvectorStatsResult

Bases: BaseResult

Result of running Eigenvector Centrality algorithm with stats mode.

centrality_distribution: dict[str, Any]
compute_millis: int
configuration: dict[str, Any]
did_converge: bool
post_processing_millis: int
pre_processing_millis: int
ran_iterations: int
class graphdatascience.procedure_surface.api.centrality.EigenvectorWriteResult

Bases: BaseResult

Result of running Eigenvector Centrality algorithm with write mode.

centrality_distribution: dict[str, Any]
compute_millis: int
configuration: dict[str, Any]
did_converge: bool
node_properties_written: int
post_processing_millis: int
pre_processing_millis: int
ran_iterations: int
write_millis: int
class graphdatascience.procedure_surface.api.centrality.HitsEndpoints

Bases:

abstractmethod estimate(G: Graph | dict[str, Any], *, hits_iterations: int = 20, partitioning: str = 'AUTO', relationship_types: list[str] = ['*'], 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.

  • hits_iterations (int) – Number of iterations to run HITS for.

  • partitioning (str) – The partitioning scheme used to divide the work between threads.

  • 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:

An object containing the result of the estimation including memory requirements

Return type:

EstimationResult

abstractmethod mutate(G: Graph, *, mutate_property: str, hits_iterations: int = 20, auth_property: str = 'auth', hub_property: str = 'hub', partitioning: str = 'AUTO', relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None) → HitsMutateResult

Runs the HITS algorithm and stores the results in the graph catalog as new node properties.

HITS (Hyperlink-Induced Topic Search) is a link analysis algorithm that computes two scores per node, a hub score and an authority score.

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

  • mutate_property (str) – Postfix for the names of the node properties (auth and hub) to store the results in.

  • hits_iterations (int) – Number of iterations to run HITS for.

  • auth_property (str) – Name of the property holding the authority score.

  • hub_property (str) – Name of the property holding the hub score.

  • partitioning (str) – The partitioning scheme used to divide the work between threads.

  • 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.

  • 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

Return type:

HitsMutateResult

abstractmethod stats(G: Graph, *, hits_iterations: int = 20, partitioning: str = 'AUTO', relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None) → HitsStatsResult

Runs the HITS algorithm and returns result statistics without storing the results.

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

  • hits_iterations (int) – Number of iterations to run HITS for.

  • partitioning (str) – The partitioning scheme used to divide the work between threads.

  • 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.

  • 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

Return type:

HitsStatsResult

abstractmethod stream(G: Graph, *, hits_iterations: int = 20, auth_property: str = 'auth', hub_property: str = 'hub', partitioning: str = 'AUTO', relationship_types: list[str] = ['*'], 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 HITS algorithm and returns the results as a stream.

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

  • hits_iterations (int) – Number of iterations to run HITS for.

  • auth_property (str) – Name of the property holding the authority score.

  • hub_property (str) – Name of the property holding the hub score.

  • partitioning (str) – The partitioning scheme used to divide the work between threads.

  • 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.

  • 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 node IDs and their HITS scores (hub and auth) in a values map column

Return type:

pandas.DataFrame

abstractmethod write(G: Graph, *, write_property: str, hits_iterations: int = 20, auth_property: str = 'auth', hub_property: str = 'hub', partitioning: str = 'AUTO', relationship_types: list[str] = ['*'], 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) → HitsWriteResult

Runs the HITS algorithm and stores the results in the Neo4j database as new node properties.

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

  • write_property (str) – Postfix for the names of the node properties (auth and hub) to store the results in.

  • hits_iterations (int) – Number of iterations to run HITS for.

  • auth_property (str) – Name of the property holding the authority score.

  • hub_property (str) – Name of the property holding the hub score.

  • partitioning (str) – The partitioning scheme used to divide the work between threads.

  • 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.

  • 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:

Algorithm metrics and statistics

Return type:

HitsWriteResult

class graphdatascience.procedure_surface.api.centrality.HitsMutateResult

Bases: BaseResult

compute_millis: int
configuration: dict[str, Any]
did_converge: bool
mutate_millis: int
node_properties_written: int
pre_processing_millis: int
ran_iterations: int
class graphdatascience.procedure_surface.api.centrality.HitsSessionEndpoints

Bases: HitsEndpoints

Hits endpoints as exposed by a GDS Session.

abstractmethod compute(G: Graph, *, hits_iterations: int = 20, auth_property: str = 'auth', hub_property: str = 'hub', partitioning: str = 'AUTO', relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None) → JobHandle

Starts the computation as a job and returns a handle to it.

The computation runs without materializing its result. Use the returned handle to mutate, write or stream the result afterwards.

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

  • hits_iterations (int) – Number of iterations to run HITS for.

  • auth_property (str) – Name of the property holding the authority score.

  • hub_property (str) – Name of the property holding the hub score.

  • partitioning (str) – The partitioning scheme used to divide the work between threads.

  • 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.

  • 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:

Handle to the started computation

Return type:

JobHandle

class graphdatascience.procedure_surface.api.centrality.HitsStatsResult

Bases: BaseResult

compute_millis: int
configuration: dict[str, Any]
did_converge: bool
pre_processing_millis: int
ran_iterations: int
class graphdatascience.procedure_surface.api.centrality.HitsWriteResult

Bases: BaseResult

compute_millis: int
configuration: dict[str, Any]
did_converge: bool
node_properties_written: int
pre_processing_millis: int
ran_iterations: int
write_millis: int
class graphdatascience.procedure_surface.api.centrality.PageRankEndpoints

Bases:

abstractmethod estimate(G: Graph | dict[str, Any], damping_factor: float = 0.85, tolerance: float = 1e-07, max_iterations: int = 20, scaler: str | dict[str, str | int | float] | ScalerConfig = 'NONE', relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], concurrency: int | None = None, relationship_weight_property: str | None = None, source_nodes: int | list[int] | list[tuple[int, float]] | 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.

  • damping_factor (float) – Probability of a jump to a random node.

  • tolerance (float) – Minimum change in scores between iterations.

  • max_iterations (int) – Maximum number of iterations to run.

  • 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})

  • 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.

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

  • source_nodes (int | list[int] | list[tuple[int, float]] | None) – The source nodes for personalized PageRank

Returns:

Memory estimation details

Return type:

EstimationResult

abstractmethod mutate(G: Graph, mutate_property: str, damping_factor: float = 0.85, tolerance: float = 1e-07, max_iterations: int = 20, scaler: str | dict[str, str | int | float] | ScalerConfig = 'NONE', relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None, relationship_weight_property: str | None = None, source_nodes: int | list[int] | list[tuple[int, float]] | None = None) → PageRankMutateResult

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

The PageRank algorithm measures the importance of each node within the graph, based on the number of incoming relationships and the importance of the corresponding source nodes. The underlying assumption roughly speaking is that a page is only as important as the pages that link to it.

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

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

  • damping_factor (float) – Probability of a jump to a random node.

  • tolerance (float) – Minimum change in scores between iterations.

  • max_iterations (int) – Maximum number of iterations to run.

  • 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})

  • 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.

  • 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.

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

  • source_nodes (int | list[int] | list[tuple[int, float]] | None) – node ids to use as starting points. Can be: - single node id (e.g., 42) - list of node id (e.g., [42, 43, 44]) - list of tuples to associate each node with a bias > 0 (e.g., [(42, 0.5), (43, 1.0)])

Returns:

Algorithm metrics and statistics

Return type:

PageRankMutateResult

abstractmethod stats(G: Graph, damping_factor: float = 0.85, tolerance: float = 1e-07, max_iterations: int = 20, scaler: str | dict[str, str | int | float] | ScalerConfig = 'NONE', relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None, relationship_weight_property: str | None = None, source_nodes: int | list[int] | list[tuple[int, float]] | None = None) → PageRankStatsResult

Runs the PageRank algorithm and returns result statistics without storing the results.

The PageRank algorithm measures the importance of each node within the graph, based on the number of incoming relationships and the importance of the corresponding source nodes. The underlying assumption roughly speaking is that a page is only as important as the pages that link to it.

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

  • damping_factor (float) – Probability of a jump to a random node.

  • tolerance (float) – Minimum change in scores between iterations.

  • max_iterations (int) – Maximum number of iterations to run.

  • 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})

  • 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.

  • 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.

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

  • source_nodes (int | list[int] | list[tuple[int, float]] | None) –

    node ids to use as starting points. Can be:

    • single node id (e.g., 42)

    • list of node id (e.g., [42, 43, 44])

    • list of tuples to associate each node with a bias > 0 (e.g., [(42, 0.5), (43, 1.0)])

Returns:

Algorithm statistics

Return type:

PageRankStatsResult

abstractmethod stream(G: Graph, damping_factor: float = 0.85, tolerance: float = 1e-07, max_iterations: int = 20, scaler: str | dict[str, str | int | float] | ScalerConfig = 'NONE', relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None, relationship_weight_property: str | None = None, source_nodes: int | list[int] | list[tuple[int, float]] | None = None) → DataFrame

Executes the PageRank algorithm and returns a stream of results.

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

  • damping_factor (float) – Probability of a jump to a random node.

  • tolerance (float) – Minimum change in scores between iterations.

  • max_iterations (int) – Maximum number of iterations to run.

  • 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})

  • 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.

  • 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.

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

  • source_nodes (int | list[int] | list[tuple[int, float]] | None) – The source nodes for personalized PageRank

Returns:

DataFrame with node IDs and their PageRank scores

Return type:

pandas.DataFrame

abstractmethod write(G: Graph, write_property: str, damping_factor: float = 0.85, tolerance: float = 1e-07, max_iterations: int = 20, scaler: str | dict[str, str | int | float] | ScalerConfig = 'NONE', relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None, relationship_weight_property: str | None = None, source_nodes: int | list[int] | list[tuple[int, float]] | None = None, write_concurrency: int | None = None) → PageRankWriteResult

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

The PageRank algorithm measures the importance of each node within the graph, based on the number of incoming relationships and the importance of the corresponding source nodes. The underlying assumption roughly speaking is that a page is only as important as the pages that link to it.

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

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

  • damping_factor (float) – Probability of a jump to a random node.

  • tolerance (float) – Minimum change in scores between iterations.

  • max_iterations (int) – Maximum number of iterations to run.

  • 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})

  • 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.

  • 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.

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

  • source_nodes (int | list[int] | list[tuple[int, float]] | None) – node ids to use as starting points. Can be: - single node id (e.g., 42) - list of node id (e.g., [42, 43, 44]) - list of tuples to associate each node with a bias > 0 (e.g., [(42, 0.5), (43, 1.0)])

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

  • -------

  • PageRankWriteResult – Algorithm metrics and statistics

Return type:

PageRankWriteResult

class graphdatascience.procedure_surface.api.centrality.PageRankMutateResult

Bases: BaseResult

centrality_distribution: dict[str, Any]
compute_millis: int
configuration: dict[str, Any]
did_converge: bool
mutate_millis: int
node_properties_written: int
post_processing_millis: int
pre_processing_millis: int
ran_iterations: int
class graphdatascience.procedure_surface.api.centrality.PageRankSessionEndpoints

Bases: PageRankEndpoints

PageRank endpoints as exposed by a GDS Session.

abstractmethod compute(G: Graph, damping_factor: float = 0.85, tolerance: float = 1e-07, max_iterations: int = 20, scaler: str | dict[str, str | int | float] | ScalerConfig = 'NONE', relationship_types: list[str] = ['*'], node_labels: list[str] = ['*'], sudo: bool = False, log_progress: bool = True, username: str | None = None, concurrency: int | None = None, job_id: str | None = None, relationship_weight_property: str | None = None, source_nodes: int | list[int] | list[tuple[int, float]] | None = None) → JobHandle

Starts the computation as a job and returns a handle to it.

The computation runs without materializing its result. Use the returned handle to mutate, write or stream the result afterwards.

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

  • damping_factor (float) – Probability of a jump to a random node.

  • tolerance (float) – Minimum change in scores between iterations.

  • max_iterations (int) – Maximum number of iterations to run.

  • 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}) - - A ScalerConfig instance

  • 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.

  • 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.

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

  • source_nodes (int | list[int] | list[tuple[int, float]] | None) – node ids to use as starting points. Can be: - single node id (e.g., 42) - list of node id (e.g., [42, 43, 44]) - list of tuples to associate each node with a bias > 0 (e.g., [(42, 0.5), (43, 1.0)])

Returns:

Handle to the started computation

Return type:

JobHandle

class graphdatascience.procedure_surface.api.centrality.PageRankStatsResult

Bases: BaseResult

centrality_distribution: dict[str, Any]
compute_millis: int
configuration: dict[str, Any]
did_converge: bool
post_processing_millis: int
pre_processing_millis: int
ran_iterations: int
class graphdatascience.procedure_surface.api.centrality.PageRankWriteResult

Bases: BaseResult

centrality_distribution: dict[str, Any]
compute_millis: int
configuration: dict[str, Any]
did_converge: bool
node_properties_written: int
post_processing_millis: int
pre_processing_millis: int
ran_iterations: int
write_millis: int