faultCode0faultStringWarning:include_once(analyticstracking.php): failed to open stream: No such file or directory in /data/htdocs-users/hogie/public_html/software/index.php on line 7faultCode0faultStringWarning:include_once(): Failed opening 'analyticstracking.php' for inclusion (include_path='.:/usr/share/php5:/usr/share/php') in /data/htdocs-users/hogie/public_html/software/index.php on line 7 BigGrph - High Performance Graph Librairy for Java
Biggrph
Scientific distributed graph computing made easy
Home › Quickstart

In this example we will see how to load a graph a several cluster nodes and run the BFS algorithm on it.

  1. copy and gunzip the example dataset file acc2007_1.tsv.gz in the $HOME/biggrph/datasets/ directory of your compute nodes.
  2. run the following main code which executes a BFS from a given source.
This code may serve as a starting point for your own application.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import java.io.IOException;

import toools.StopWatch;
import toools.math.DistributionForLongs;
import toools.thread.NThreadsPolicy;
import biggrph.BigAdjacencyTable;
import biggrph.BigGrphCluster;
import biggrph.algo.DistanceDistribution;
import biggrph.algo.search.bfs.BFSDistanceAssigner;
import biggrph.computing_models.bsp.BSPStdoutLogger;
import biggrph.dataset.EdgeListDataSet;

public class BigGrphTest
{

	public static void main(String[] args) throws IOException
	{
		// start the cluster
		BigGrphCluster cluster = BigGrphCluster.localhost();

		// load the dataset
		String datasetName = "acc2007_1.tsv";
		EdgeListDataSet dataset = new EdgeListDataSet(datasetName, cluster);
		BigAdjacencyTable g = dataset.load(false, true);

		// compute some stats on the graph
		System.out.println("graph: " + g);
		System.out.println("avg out degree: " + g.getAverageDegree());
		System.out.println("max out degree: " + g.getMaxDegree());

		// timers the BFS algorithm
		StopWatch sw = new StopWatch();
		long srcVertex = 344445347;
		BFSDistanceAssigner bfs = BFSDistanceAssigner.compute(g, srcVertex, new BSPStdoutLogger(), new NThreadsPolicy(1));
		// BFSDistanceAssigner bfs = g.bfs(srcVertex);
		System.out.println("Duration of the BFS search: " + sw);
		DistributionForLongs d = new DistanceDistribution(bfs.getDistancesDistributedMap()).execute();
		System.out.println("Distance distrution for graph " + g + " (distance #node)");
		System.out.println(d.toString(false, false));

		System.out.println(cluster.getDescription(true));
	}
}

If you want to run the code on your local computer, start the cluster like this:

BigGrphCluster cluster = BigGrphCluster.localhost();

If you want to run the code on a set of computer that are not managed by Torque, start the cluster like this:

BigGrphCluster cluster = BigGrphCluster.workstations("musclotte", "k5000", "nicoati", "george");

We used http://hilite.me to highlight the source code.