The GraphAlg Language
GraphAlg is a language for graph algorithms designed to be embedded into databases.
func withDamping(degree:int, damping:real) -> real {
return cast<real>(degree) / damping;
}
func PageRank(graph: Matrix<s, s, bool>) -> Vector<s, real> {
damping = real(0.85);
iterations = int(10);
n = graph.nrows;
teleport = real(0.15) / cast<real>(n);
d_out = reduceRows(cast<int>(graph));
d = apply(withDamping, d_out, damping);
pr = Vector<real>(n);
pr[:] = real(1.0) / cast<real>(n);
for i in int(0):iterations {
w = pr (./) d;
pr[:] = teleport;
pr += cast<real>(graph).T * w;
}
return pr;
}
Are you new to GraphAlg? Write your first GraphAlg program and learn more about the language using the interactive tutorial.
You can experiment with GraphAlg in our Playground, or use a system with GraphAlg support.
For a detailed overview of the GraphAlg language, see the language specification.