SpringRank.jl implements the SpringRank algorithm for ranking nodes in directed networks, with a focus on:
- Sparse linear algebra (iterative and direct solvers)
- Multiple input formats (sparse matrices, Graphs.jl graphs, Tables.jl-compatible edge lists)
- Simple evaluation metrics for link prediction and ranking quality
SpringRank.jl is currently under development.
For now you can develop it locally:
using Pkg
Pkg.develop(url = "https://github.com/yifen9/SpringRank.jl")After it is registered in the General registry, it will be installable with:
] add SpringRankusing SpringRank, SparseArrays
A = sparse([1, 1, 2], [2, 3, 3], [1.0, 2.0, 1.0], 3, 3)
r = springrank(A)r is a vector of SpringRank scores, normalized to have zero mean.
You can control the solver and regularization:
r = springrank(A; λ = 1e-8, method = :auto) # automatic direct / Krylov
r = springrank(A; λ = 1e-6, method = :direct) # direct solver
r = springrank(A; λ = 1e-6, method = :krylov) # iterative solverAny Graphs.AbstractGraph is supported via its adjacency matrix:
using SpringRank, Graphs
g = SimpleDiGraph(5)
add_edge!(g, 1, 2); add_edge!(g, 1, 3)
add_edge!(g, 2, 4); add_edge!(g, 3, 4)
add_edge!(g, 4, 5)
r = springrank(g)If the graph has weights, SpringRank uses them when possible.
SpringRank can assemble the adjacency matrix from any Tables.jl-compatible source, such as a DataFrame of edges:
using SpringRank, DataFrames
edges = DataFrame(
src = [1, 1, 2],
dst = [2, 3, 3],
w = [1.0, 2.0, 1.0],
)
r = springrank_pairs(edges; n = 3)The column names can be customized via keywords (src, dst, w).
SpringRank.jl provides some basic utilities for link prediction evaluation.
Given scores r and an edge list, you can evaluate prediction accuracy and AUC:
using SpringRank, DataFrames
edges = DataFrame(
src = [1, 1, 2, 3],
dst = [2, 3, 3, 1],
w = [1.0, 1.0, 1.0, -1.0],
)
# Accuracy and AUC
ev = evaluate_prediction(r, edges)
ev.acc # accuracy
ev.auc # AUC
# Probability-style scores
pr = predict_proba(r, edges; β = 1.0)
pr.proba # predicted probabilities
pr.y_true # binary labels
pr.y_score # raw scoresYou can also compute rank correlation with a reference ranking:
using SpringRank
ρ = rank_correlation(r, r_ref) # Spearman correlationThis repository uses just to drive common tasks.
- Run tests:
just test- Quality checks (Aqua, JET) and formatting:
just fmt
just qa-aqua
just qa-jet- Benchmarks:
just bench- Build local documentation (Documenter.jl):
just docs- CI entry point (used by GitHub Actions):
just ciSpringRank.jl is released under the MIT License. See LICENSE for details.