Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

30 lines (20 sloc) 0.766 kb
package com.twitter.scalding.examples
import com.twitter.scalding._
import com.twitter.scalding.mathematics.Matrix
* MatrixTutorial1.scala
* Loads a directed graph adjacency matrix where a[i,j] = 1 if there is an edge from a[i] to b[j]
* and compute the co-follows between any two nodes
* ../scripts/scald.rb --local MatrixTutorial1.scala --input data/graph.tsv --output data/cofollows.tsv
class CofollowsJob(args : Args) extends Job(args) {
import Matrix._
val adjacencyMatrix = Tsv( args("input"), ('user1, 'user2, 'rel) )
.toMatrix[Long,Long,Double]('user1, 'user2, 'rel)
// compute the innerproduct of the adjacency matrix with itself
(adjacencyMatrix * adjacencyMatrix.transpose).write( Tsv( args("output") ) )
Jump to Line
Something went wrong with that request. Please try again.