Rank a chosen set of linked records
Prepare the self-relation in the graph quickstart. Scores below illustrate the response format; they depend on your graph and selected nodes.
The language tabs use earlier client interfaces. Check SDK versions and connection setup before running them.
PageRank estimates importance from incoming links. The nodes list defines which records take part.
Before you run it: Scores from different node sets are not directly comparable.
For the unchanged three-node quickstart cycle, all three nodes have the same link pattern, so none should be interpreted as a uniquely influential node. nodes=u1,u2,u3 chooses the records being compared; the score is relative to that set.
- Select u1, u2 and u3Use the sample cycle as the analysis set.
- Pass weight through linksRepeat the PageRank updates across that set.
- Compare relative scoresThe symmetric three-node cycle should give equal scores.
Follow the example
- Choose the relationship.
- Pass the full nodes list to rank.
- Run the calculation.
- Read the highest scores first.
Set up the relationship
The relation must be declared in the schema's [[relations]] block. See schemas/reference#relations.
Run the request
nodes is a comma-separated list of the primary keys that form the universe. Edges to keys outside the list are dropped; the iteration is scoped to what you pass.
curl -G "https://$OC_HOST/v1/tenants/$OC_TENANT/graph/graph_demo.people/pagerank" \
--data-urlencode "rel=follows" \
--data-urlencode "nodes=u1,u2,u3" \
-H "Authorization: Bearer $OC_TOKEN"Check the result
Scores sum to 1 across the supplied set. Links outside it are ignored.
[
{
"pk": "u1",
"score": 0.333333
},
{
"pk": "u2",
"score": 0.333333
},
{
"pk": "u3",
"score": 0.333333
}
]An array of { pk, score } entries, already sorted by score descending, so the first entry is the top influencer in the universe you passed. Scores sum to 1 across that node set.
Understand the behavior
- Power-iteration PageRank with damping factor 0.85.
- The induced subgraph is built once from the
nodeslist; iteration converges on that subgraph only. - Caller-scoped universe is intentional - the engine refuses to rank the entire tenant graph because that's almost never what you want and is unbounded in cost.
Important limits and checks
- Omitting
nodes=. The engine 400s because it requires the universe up front. Pick the candidate set first; rank second. - Comparing scores across different node sets. Scores are relative to the universe you pass. A pk's score in one subgraph isn't comparable to its score in another.