-
Notifications
You must be signed in to change notification settings - Fork 18
Graph Analytics page #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,3 +1,72 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
== Setup Instructions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
== Graph Analytics | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
See https://neo4j.com/docs/aura/graph-analytics/[documentation] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Graph Analytics is a powerful feature of Neo4j Aura that allows users to run graph algorithms on their graph data. This includes tasks such as community detection, pathfinding, and centrality analysis. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
More information about Aura Graph Analytics can be found in the Neo4j link:https://neo4j.com/docs/aura/graph-analytics[documentation]. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
You only need to have link:https://neo4j.com/docs/aura/api/authentication/[Aura API credentials] ready before you can start using sessions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+3
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
=== Using the Graph Analytics Cypher API | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The Graph Analytics Cypher API provides a straightforward way to execute graph algorithms directly within your Neo4j database using Cypher queries. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
You can use the `gds.aura.api.credentials` function to provide your credentials in your Cypher queries. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Assuming you have data in your Neo4j Aura database, the first step is to project a graph into Aura Graph Analytics. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+11
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.Projecting a graph to a GDS Session: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[source, cypher, copy=true] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CYPHER runtime=parallel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
WITH gds.aura.api.credentials($clientId, $clientSecret) AS credentials | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
MATCH (n) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
OPTIONAL MATCH (n)-->(m) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
RETURN gds.graph.project('myGraph', n, m, {}, {memory: '4GB'}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Next you can run different algorithms on the projected graph, such as PageRank to find central nodes in the graph. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.Run an algorithm on the projected graph: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[source, cypher, copy=true] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
WITH gds.aura.api.credentials($clientId, $clientSecret) AS credentials | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We agreed to make auth examples easier by using placeholders rather than query parameters (same for the client examples). |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CALL gds.pageRank.stream('myGraph', { mutateProperty: 'pageRank' }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
YIELD nodeId, score | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
RETURN gds.util.asNode(nodeId), score | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
After running the algorithm, you can inspect the PageRank score assigned to each node using `gds.graph.nodeProperty.stream` function to retrieve the node properties that were mutated by the algorithm. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could also skip this one and just show the algo in |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For more information about the Cypher API such as writing back results to the database, refer to the link:https://neo4j.com/docs/graph-data-science/current/aura-graph-analytics/cypher[Graph Data Science documentation]. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
=== Using the Python Client | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
To use the Graph Analytics features in Neo4j Aura with Python, you need to install the `graphdatascience` package. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Compared to the Cypher API, the Python client offers the option to run algorithms against non-neo4j data sources, such as Pandas DataFrames. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[source, bash, copy=true] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
pip install graphdatascience | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The entry point for managing Aura Graph Analytics sessions is the `GdsSessions` class. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[source, python, copy=true] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import os | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
from graphdatascience.session import AuraAPICredentials, GdsSessions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# you can also use AuraAPICredentials.from_env() to load credentials from environment variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
api_credentials = AuraAPICredentials( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
client_id=os.environ["CLIENT_ID"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
client_secret=os.environ["CLIENT_SECRET"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# If your account is a member of several project, you must also specify the project ID to use | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
project_id=os.environ.get("PROJECT_ID", None), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
sessions = GdsSessions(api_credentials=api_credentials) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+56
to
+68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still need to add the examples for how to create a session and run an algorithm. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For more details, explore our client link:https://neo4j.com/docs/graph-data-science-client/current/graph-analytics-serverless/[docs] and the tutorials on link:https://neo4j.com/docs/graph-data-science-client/current/tutorials/graph-analytics-serverless/[attached], and link:https://neo4j.com/docs/graph-data-science-client/current/tutorials/graph-analytics-serverless-standalone/[standalone] sessions). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+71
to
+72
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Graph Analytics" is already the tab name, so this is more specific.