Let's get started

Run your first algorithm in less than 10 minutes!

Prepare Eclipse IDE

We suggest you install Eclipse IDE 3.7 (Indigo) for Java developers, since this is currently the officially supported version by the Scala IDE plugin.

For an optimal expericence please make sure that Eclipse uses the Java 7 library and JVM: Preferences → Java → Installed JREs → JRE/JDK 7 should be installed and selected.

To leverage Eclipse for Scala development, install the Scala IDE plugins (for Scala 2.10): Help → Install New Software ... → Add → http://download.scala-ide.org/sdk/e37/scala210/dev/site/ Select and install all plugins from that location.

Download the Signal/Collect .jar file

Download the Signal/Collect .jar file which is available here

Your first Signal/Collect Algorithm

Now that you have all the necessary components and tools in place you are ready to implement your first algorithm based on Signal/Collect. For this purpose we selected the well known PageRank algorithm which calculates the relative importance of a node in a network in an iterative fashion.

We start off by creating a new Scala Project in an eclipse workspace. (File → New → Other... → Scala Wizards → Scala Project)

Once you named your project and clicked on the Finish button you will see the your project folder in the package explorer on the right hand side of your IDE. The project folder already containes an empty source folder together with the Scala library and the Java Runtime Environment. In addition to these libraries we now need to add the the previously downloaded Signal/Collect jar file to the projects build path. We achieve this by right clicking on the project folder and selecting Build Path → Configure Build Path ... → Libraries → Add external JARs....

We now have provided all the needed libraries and are ready to write some actual code. Since the implementation of our PageRank algorithm will be rather short, we will define all our classes in a single scala file. To add a new Scala file to your project select the src Folder and click on New → Scala Object.

Let's name this Object PageRank because it will also act as the entry point of our application as we will see in just a moment.
Our algorithm will consist of three disctinct parts which specify the structure and behavior of the vertices and edges in the graph as well as one part that handles the loading of the graph and triggers the execution.

Define the Vertex

The definition of the vertex structure is very short since we can build on top of the default implementation that is provided by the Signal/Collect library. All that is left to do is to write the algorithm specific collect function and the termination criterion (defined in the scoreSignal function).

      class PageRankVertex(id: Any, dampingFactor: Double = 0.85) extends DataGraphVertex(id, 1 - dampingFactor) {
        type Signal = Double
        def collect: Double = 1 - dampingFactor + dampingFactor * signals.sum
        override def scoreSignal: Double = {
          lastSignalState match {
            case None           => 1
            case Some(oldState) => (state - oldState).abs

Define the Edge

Similarly, we can also use the default edge implementation as a basis for our own edge and just modify its signal method.

      class PageRankEdge(t: Any) extends DefaultEdge(t) {
        type Source = PageRankVertex
        def signal = source.state * weight / source.sumOfOutWeights

Define the Graph Structure

As a final step, we also have to define the entry point for our program together with the code that sets up the graph structure and runs the algorithm.

      object PageRank extends App {
        val graph = GraphBuilder.build
        graph.addVertex(new PageRankVertex(1))
        graph.addVertex(new PageRankVertex(2))
        graph.addVertex(new PageRankVertex(3))
        graph.addEdge(1, new PageRankEdge(2))
        graph.addEdge(2, new PageRankEdge(1))
        graph.addEdge(2, new PageRankEdge(3))
        graph.addEdge(3, new PageRankEdge(2))
        val stats = graph.execute

A commented version of this algorithm is also available in our GitHub repository.

Run the algorithm

Now take a deep breath and run your first PageRank algorithm on Signal/Collect.

The results of this simple graph do not matter too much at this point, but they should look something similar to this:

- Execution Parameters -
Execution mode OptimizedAsynchronous
Signal threshold 0.01
Collect threshold 0.0
Time limit None
Steps limit None

- Execution Statistics -
# signal steps 1
# collect steps 0
Computation time 49 milliseconds
JVM CPU time 50 milliseconds
Graph loading time 104 milliseconds
Termination reason Converged
# messages 81
# collect operations 39
# signal operations 40
# vertices (add/remove) 3 (3/0)
# edges (add/remove) 4 (4/0)

PageRankVertex(id=1, state=0.7474643455022485)
PageRankVertex(id=2, state=1.4057984600052906)
PageRankVertex(id=3, state=0.7474643455022485)

Contratulations! You have successfully implemented and run your first Signal/Collect computation.

To learn more about the underlying concepts and mechanisms of Signal/Collect we suggest you read the documentation section or get inspired by some of our example algorithms: