in cassovary-core/src/main/scala/com/twitter/cassovary/algorithms/linkanalysis/LinkAnalysis.scala [54:79]
protected def efficientNeighbors(node: Node): CSeq[Int] = if (isInStored) node.inboundNodes() else node.outboundNodes()
protected def efficientNeighborCount(node: Node): Int = efficientNeighbors(node).length
/**
* Run a single iteration through our algorithm.
* @param currState The starting iteration that our algorithm will be applied to.
* @return A new iteration.
*/
def iterate(currState: T): T
/**
* Provides default initial start values for our algorithms.
* @return An default starting iteration.
*/
protected def defaultInitialState: T
/**
* Calculate the error between two arrays using either the T1 error or the T2 error. This is a
* convenience method.
* @param t1 Flag `true` to calculate the T1 error (the sum of absolute differences between two arrays). Flag
* `false` to calculate the T2 error (the sum of the squared differences between two arrays).
*/
protected def deltaOfArrays(a: Array[Double], b: Array[Double], t1: Boolean = true): Double = {
val difference = (a zip b).map { case(v1, v2) => if (t1) Math.abs(v1 - v2) else Math.pow(v1 - v2, 2) }.sum
if (t1) difference else Math.sqrt(difference)
}