If you do not want to install the whole GraphLab C++ installation, you can simply download the Java interface from here: graphlab_java_20101210.tar.gz. We currently provide 64-bit Linux and Mac binary versions of the native library. For other platforms, you need to build your own (see README.txt for instructions).
Consult README.txt for instructions on how to build the Java API and how to run the example applications.
(Java interface is also located as part of the main source distribution under directory extapis).
GraphLabJNIWrapper jniWrapper = new GraphLabJNIWrapper(updateFunction);
jniWrapper.setScopeType("edge");
jniWrapper.setScheduler("multiqueue_fifo");
jniWrapper.setGraph(graph);
jniWrapper.scheduleAll();
jniWrapper.start();
We have built on top of the GraphLab Java API a Python/Jython interface. While the performance is not excellent (compared to native code), it provides a very easy way to start writing GraphLab programs. Python programs are typically much more concise than Java or C++ applications, and allow for quick experimenting. Note: Python API is in an early stage, but is almost fully functional (multiple update functions are not supported).
To use the Jython interface, you only need to install the Java Graphlab API (instructions above). Full GraphLab Java API is available for the Python scripts.
GraphLab python program consists of four separate script-files:graph.addEdge(0,1, 3.2) graph.addEdge(i, j, [0.1, 12, "test"]) graph.addVertex(MyVertexClass())Vertex and Edge data is stored in field "value" in the corresponding object. Example: graph.getVertex(vertexid).value.
# Python implementation of pagerank update function
import math
damping = 0.85
def update(scope, scheduler):
pvertex = scope.getVertex().value
sumval = pvertex.rank * pvertex.selfedge + sum([e.value * scope.getNeighbor(e.from).value.rank for e in scope.getInboundEdges()])
newval = (1-damping)/scope.getNumOfVertices() + damping*sumval
if (abs(newval-pvertex.rank)>0.00001):
scheduler.addTaskToOutbound(scope)
pvertex.rank = newval
update(scope, scheduler)
java -Xmx500m -Djava.library.path=../native/ graphlab.wrapper.PythonGraphlab pagerank_load.py pagerank_config.py pagerank_update.py pagerank_post.py testdata/stoch30x.csv