GraphDataScience¶
- class graphdatascience.GraphDataScience¶
Primary API class for the Neo4j Graph Data Science Python Client. Always bind this object to a variable called gds.
- __init__(endpoint: str | Driver | QueryRunner, auth: tuple[str, str] | None = None, aura_ds: bool | None = None, database: str | None = None, arrow: str | bool = True, bookmarks: Bookmarks | None = None, show_progress: bool = True, arrow_client_options: dict[str, Any] | None = None)¶
Construct a new GraphDataScience object.
- Parameters:
endpoint (str | Driver | QueryRunner) – The Neo4j endpoint to connect to. Most commonly, this is a Bolt connection URI.
auth (tuple[str, str] | None) – A username, password pair for database authentication.
aura_ds (bool | None) – A flag that indicates that the client is used to connect to a Neo4j AuraDS instance. If not set, the client will automatically derive whether the database is hosted in Aura.
database (str | None) – The Neo4j database to query against.
Arrow connection information. This is either a string or a bool.
If it is a string, it will be interpreted as a connection URL to a GDS Arrow Server.
- If it is a bool:
True will make the client discover the connection URI to the GDS Arrow server via the Neo4j endpoint.
False will make the client use Bolt for all operations.
bookmarks (Bookmarks | None) – The Neo4j bookmarks to require a certain state before the next query gets executed.
show_progress (bool) – A flag to indicate whether to show progress bars for running procedures.
arrow_client_options (dict[str, Any] | None) – Additional options to be passed to the Arrow Flight client.
- property all_shortest_paths: AllShortestPathEndpoints¶
Return endpoints for the all shortest paths algorithm.
- property article_rank: ArticleRankEndpoints¶
Return endpoints for the article rank algorithm.
- property articulation_points: ArticulationPointsEndpoints¶
Return endpoints for the articulation points algorithm.
- property bellman_ford: SingleSourceBellmanFordEndpoints¶
Return endpoints for the single source Bellman-Ford algorithm.
- property betweenness: BetweennessEndpoints¶
Return endpoints for the betweenness centrality algorithm.
- property betweenness_centrality: BetweennessEndpoints¶
Return endpoints for the betweenness centrality algorithm.
- property bfs: BFSEndpoints¶
Return endpoints for the Breadth First Search (BFS) algorithm.
- bookmarks() Bookmarks | None¶
Get the Neo4j bookmarks defining the currently required states for queries to execute
- Returns:
The Neo4j bookmarks defining the currently required state.
- Return type:
neo4j.Bookmarks | None
- property bridges: BridgesEndpoints¶
Return endpoints for the bridges algorithm.
- property clique_counting: CliqueCountingEndpoints¶
Return endpoints for the clique counting algorithm.
- close() None¶
Close the GraphDataScience object and release any resources held by it.
If the GraphDataScience object was instantiated with a Neo4j Driver, the driver will not be closed as we cannot assume sole ownership of it.
- Return type:
None
- property closeness: ClosenessEndpoints¶
Return endpoints for the closeness centrality algorithm.
- property closeness_centrality: ClosenessEndpoints¶
Return endpoints for the closeness centrality algorithm.
- property collapse_path: CollapsePathEndpoints¶
Return endpoints for collapsing relationship paths.
- property conductance: ConductanceEndpoints¶
Return endpoints for the conductance algorithm.
- property config: ConfigEndpoints¶
Return endpoints for configuration.
- property dag: DagCypherEndpoints¶
Return endpoints for Directed Acyclic Graph (DAG) algorithms.
- database() str | None¶
Get the database which queries are run against.
- Returns:
The name of the database.
- Return type:
str | None
- db_driver() Driver¶
Get the Neo4j driver used by this client to communicate with the Neo4j DBMS.
This is mainly useful when the run_cypher() API is too simple for a use case, as the driver allows full control over sessions and transactions.
The driver is closed by close() if the client created it itself, after which it is unusable; a driver supplied at construction is never closed by this client.
- Returns:
The Neo4j driver used by this client.
- Return type:
- property debug: DebugEndpoints¶
Return debug endpoints.
- property degree: DegreeEndpoints¶
Return endpoints for the degree centrality algorithm.
- property degree_centrality: DegreeEndpoints¶
Return endpoints for the degree centrality algorithm.
- property dfs: DFSEndpoints¶
Return endpoints for the Depth First Search (DFS) algorithm.
- driver_config() dict[str, Any]¶
Get the configuration used to create the underlying driver used to make queries to Neo4j.
- property eigenvector: EigenvectorEndpoints¶
Return endpoints for the eigenvector centrality algorithm.
- property eigenvector_centrality: EigenvectorEndpoints¶
Return endpoints for the eigenvector centrality algorithm.
- property fast_rp: FastRPEndpoints¶
Return endpoints for the fast RP algorithm.
- property graph: CatalogCypherEndpoints¶
Return endpoints for graph management.
- property graph_sage: GraphSageEndpoints¶
Return endpoints for the GraphSage algorithm.
- property harmonic: ClosenessHarmonicEndpoints¶
Return endpoints for the harmonic centrality algorithm.
- property harmonic_centrality: ClosenessHarmonicEndpoints¶
Return endpoints for the harmonic centrality algorithm.
- property hash_gnn: HashGNNEndpoints¶
Return endpoints for the HashGNN algorithm.
- property hdbscan: HdbscanEndpoints¶
Return endpoints for the HDBSCAN algorithm.
- property hits: HitsEndpoints¶
Return endpoints for the HITS algorithm.
- property influence_maximization_celf: CelfEndpoints¶
Return endpoints for the influence maximization CELF algorithm.
- property k1_coloring: K1ColoringEndpoints¶
Return endpoints for the K1 coloring algorithm.
- property k_core_decomposition: KCoreEndpoints¶
Return endpoints for the K-core decomposition algorithm.
- property k_spanning_tree: KSpanningTreeEndpoints¶
Return endpoints for the K-spanning tree algorithm.
- property kcore: KCoreEndpoints¶
Return endpoints for the K-core decomposition algorithm.
- property kge: KgeEndpoints¶
Return endpoints for KGE (TransE/DistMult) relationship prediction.
- property kmeans: KMeansEndpoints¶
Return endpoints for the K-means algorithm.
- property knn: KnnEndpoints¶
Return endpoints for the K-nearest neighbors algorithm.
- property label_propagation: LabelPropagationEndpoints¶
Return endpoints for the label propagation algorithm.
- last_bookmarks() Bookmarks | None¶
Get the Neo4j bookmarks defining the state following the most recently called query
- Returns:
The Neo4j bookmarks defining the state following the most recently called query.
- Return type:
neo4j.Bookmarks | None
- property leiden: LeidenEndpoints¶
Return endpoints for the Leiden algorithm.
- property license: LicenseEndpoints¶
Return license endpoints.
- property list_progress: ListProgressCypherEndpoint¶
Return endpoint for listing progress.
- property local_clustering_coefficient: LocalClusteringCoefficientEndpoints¶
Return endpoints for the local clustering coefficient algorithm.
- property louvain: LouvainEndpoints¶
Return endpoints for the Louvain algorithm.
- property max_flow: MaxFlowEndpoints¶
Return endpoints for the Max Flow algorithm.
- property max_k_cut: MaxKCutEndpoints¶
Return endpoints for the Max K-cut algorithm.
- property memory: MemoryEndpoints¶
Return memory usage endpoints.
- property model: ModelCatalogEndpoints¶
Return model-related endpoints for model management.
- property modularity: ModularityEndpoints¶
Return endpoints for the modularity algorithm.
- property modularity_optimization: ModularityOptimizationEndpoints¶
Return endpoints for the modularity optimization algorithm.
- property node2vec: Node2VecEndpoints¶
Return endpoints for the Node2Vec algorithm.
- property node_similarity: NodeSimilarityEndpoints¶
Return endpoints for the node similarity algorithm.
- property page_rank: PageRankEndpoints¶
Return endpoints for the PageRank algorithm.
- property pipeline: PipelineEndpoints¶
Return endpoints for pipeline procedures.
- property prize_steiner_tree: PrizeSteinerTreeEndpoints¶
Return endpoints for the prize-collecting Steiner tree algorithm.
- property random_walk: RandomWalkEndpoints¶
Return endpoints for the Random Walk algorithm.
- run_cypher(query: str, params: dict[str, Any] | None = None, database: str | None = None, mode: QueryMode | Literal['READ', 'WRITE'] = QueryMode.WRITE, auto_commit: bool = False) DataFrame¶
Run a Cypher query
- Parameters:
query (str) – the Cypher query
database (str) – the database on which to run the query
mode (QueryMode | Literal['READ', 'WRITE']) – the query mode to use. Set based on the operation performed in the query.
auto_commit (bool) – run the query in an auto-commit transaction. This is required for queries using CALL { … } IN TRANSACTIONS.
- Returns:
The query result as a DataFrame
- Return type:
- property scale_properties: ScalePropertiesEndpoints¶
Return endpoints for scaling node properties.
- property scc: SccEndpoints¶
Return endpoints for the strongly connected components algorithm.
- set_bookmarks(bookmarks: Bookmarks | None) None¶
Set Neo4j bookmarks to require a certain state before the next query gets executed
- Parameters:
bookmarks (neo4j.Bookmarks | None) – The Neo4j bookmarks defining the required state
- Return type:
None
- set_database(database: str) None¶
Set the database which queries are run against.
- Parameters:
database (str) – The name of the database to run queries against.
- Return type:
None
- set_show_progress(show_progress: bool) None¶
Set whether to show progress for running procedures.
- Parameters:
show_progress (bool) – Whether to show progress for procedures.
- Return type:
None
- property shortest_path: ShortestPathEndpoints¶
Return endpoints for the shortest path algorithm.
- property similarity: SimilarityFunctions¶
Return similarity functions computed client-side.
- property sllpa: SllpaEndpoints¶
Return endpoints for the speaker-listener label propagation algorithm.
- property spanning_tree: SpanningTreeEndpoints¶
Return endpoints for the spanning tree algorithm.
- property steiner_tree: SteinerTreeEndpoints¶
Return endpoints for the Steiner tree algorithm.
- property topological_link_prediction: TopologicalLinkPredictionEndpoints¶
Return endpoints for topological link prediction functions.
- property triangle_count: TriangleCountEndpoints¶
Return endpoints for the triangle count algorithm.
- property triangles: TrianglesEndpoints¶
Return endpoint for the triangles algorithm.
- property util: UtilEndpoints¶
Return utility endpoints.
- property wcc: WccEndpoints¶
Return endpoints for the weakly connected components algorithm.