Link Prediction¶
Algorithms for predicting missing or future edges.
Coming Soon
These algorithms are planned for upcoming releases.
Common Neighbors¶
Predict links based on shared connections.
from grafeo.algorithms import common_neighbors
predictions = common_neighbors(db,
node_a=1,
node_b=2
)
print(f"Common neighbor score: {predictions.score}")
Jaccard Coefficient¶
Normalized common neighbors.
Adamic-Adar Index¶
Weighted common neighbors (rare neighbors count more).
Preferential Attachment¶
Product of node degrees.
from grafeo.algorithms import preferential_attachment
score = preferential_attachment(db, node_a, node_b)
Resource Allocation¶
Similar to Adamic-Adar but with different weighting.
Batch Predictions¶
Generate predictions for many node pairs.
from grafeo.algorithms import predict_links
predictions = predict_links(db,
method='adamic_adar',
limit=100
)
for source, target, score in predictions:
print(f"{source} -> {target}: {score:.4f}")
Use Cases¶
- Friend suggestions in social networks
- Product recommendations
- Knowledge graph completion
- Collaboration prediction