// Path: src/main/java/org/apache/jena/grande/giraph/sssps/SingleSourceShortestPaths.java
// public class SingleSourceShortestPaths extends EdgeListVertex<IntWritable, IntWritable, NullWritable, IntWritable> implements Tool {
// 
// 	private static final Logger log = LoggerFactory.getLogger(SingleSourceShortestPaths.class);
// 	
// 	public static final String SOURCE_VERTEX = "giraph.example.source";
// 	public static final int SOURCE_VERTEX_DEFAULT = 3;
// 
// 	
// 	@Override
// 	public int run(String[] args) throws Exception {
// 		log.debug("run({})", Utils.toString(args));
// 		Preconditions.checkArgument(args.length == 4, "run: Must have 4 arguments <input path> <output path> <source vertex> <# of workers>");
// 
// 		Configuration configuration = getConf();
//         boolean overrideOutput = configuration.getBoolean(Constants.OPTION_OVERWRITE_OUTPUT, Constants.OPTION_OVERWRITE_OUTPUT_DEFAULT);
//         FileSystem fs = FileSystem.get(new Path(args[1]).toUri(), configuration);
//         if ( overrideOutput ) {
//             fs.delete(new Path(args[1]), true);
//         }
// 
//         GiraphConfiguration giraphConfiguration = new GiraphConfiguration(getConf());
//         giraphConfiguration.setVertexClass(getClass());
//         giraphConfiguration.setVertexInputFormatClass(IntIntNullIntTextInputFormat.class);
//         giraphConfiguration.setVertexOutputFormatClass(IdWithValueTextOutputFormat.class);
// 		giraphConfiguration.set(SOURCE_VERTEX, args[2]);
// 		giraphConfiguration.setWorkerConfiguration(Integer.parseInt(args[3]), Integer.parseInt(args[3]), 100.0f);
// 
// 		GiraphJob job = new GiraphJob(giraphConfiguration, getClass().getName());
// 		FileInputFormat.addInputPath(job.getInternalJob(), new Path(args[0]));
// 		FileOutputFormat.setOutputPath(job.getInternalJob(), new Path(args[1]));
// 		return job.run(true) ? 0 : -1;
// 	}
// 
// 	@Override
// 	public void compute(Iterable<IntWritable> msgIterator) throws IOException {
// 		log.debug("compute(...)::{}#{} ...", getId(), getSuperstep());
// 	    if ( ( getSuperstep() == 0 ) || ( getSuperstep() == 1 ) ) {
// 	    	setValue(new IntWritable(Integer.MAX_VALUE));
// 	    }
// 	    int minDist = isSource() ? 0 : Integer.MAX_VALUE;
// 	    log.debug("compute(...)::{}#{}: min = {}, value = {}", new Object[]{getId(), getSuperstep(), minDist, getValue()});
// 	    for ( IntWritable msg : msgIterator ) {
// 	    	log.debug("compute(...)::{}#{}: <--[{}]-- from ?", new Object[]{getId(), getSuperstep(), msg});
// 	        minDist = Math.min(minDist, msg.get());
// 		    log.debug("compute(...)::{}#{}: min = {}", new Object[]{getId(), getSuperstep(), minDist});
// 	    }
// 	    if (minDist < getValue().get()) {
// 	        setValue(new IntWritable(minDist));
// 		    log.debug("compute(...)::{}#{}: value = {}", new Object[]{getId(), getSuperstep(), getValue()});
// 		    for (Edge<IntWritable,NullWritable> edge : getEdges()) {
// 	    	    log.debug("compute(...)::{}#{}: {} --[{}]--> {}", new Object[]{getId(), getSuperstep(), getId(), minDist+1, edge.getTargetVertexId()});
// 	        	sendMessage(edge.getTargetVertexId(), new IntWritable(minDist + 1));
// 	        }
// 	    }
// 	    voteToHalt();
// 	}
// 
// 	private boolean isSource() {
// 		boolean result = getId().get() == getConf().getInt(SOURCE_VERTEX, SOURCE_VERTEX_DEFAULT);
// 		log.debug("isSource() --> {}", result);
// 		return result;
// 	}
// 
// 	@Override
// 	public void setConf(Configuration conf) {
// 		super.setConf(new ImmutableClassesGiraphConfiguration<IntWritable, IntWritable, NullWritable, IntWritable>(conf));
// 	}
// 	
// 	public static void main(String[] args) throws Exception {
// 		log.debug("main({})", Utils.toString(args));
// 		System.exit(ToolRunner.run(new SingleSourceShortestPaths(), args));
// 	}
// 
// }


import java.util.HashMap;
import org.apache.giraph.io.IdWithValueTextOutputFormat;
import org.apache.giraph.io.IntIntNullIntTextInputFormat;
import org.apache.giraph.utils.InternalVertexRunner;
import org.apache.jena.grande.giraph.sssps.SingleSourceShortestPaths;
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package dev;



public class RunGiraphSSSPS {

	public static final String[] data = new String[] {
		"1 2 5", 
		"2 1 3 5", 
		"3 2 4", 
		"4 3 5 6", 
		"5 1 2 4", 
		"6 4", 
	};
	
	public static void main(String[] args) throws Exception {
	    Iterable<String> results = InternalVertexRunner.run(
// Path: src/main/java/org/apache/jena/grande/giraph/sssps/SingleSourceShortestPaths.java
// public class SingleSourceShortestPaths extends EdgeListVertex<IntWritable, IntWritable, NullWritable, IntWritable> implements Tool {
// 
// 	private static final Logger log = LoggerFactory.getLogger(SingleSourceShortestPaths.class);
// 	
// 	public static final String SOURCE_VERTEX = "giraph.example.source";
// 	public static final int SOURCE_VERTEX_DEFAULT = 3;
// 
// 	
// 	@Override
// 	public int run(String[] args) throws Exception {
// 		log.debug("run({})", Utils.toString(args));
// 		Preconditions.checkArgument(args.length == 4, "run: Must have 4 arguments <input path> <output path> <source vertex> <# of workers>");
// 
// 		Configuration configuration = getConf();
//         boolean overrideOutput = configuration.getBoolean(Constants.OPTION_OVERWRITE_OUTPUT, Constants.OPTION_OVERWRITE_OUTPUT_DEFAULT);
//         FileSystem fs = FileSystem.get(new Path(args[1]).toUri(), configuration);
//         if ( overrideOutput ) {
//             fs.delete(new Path(args[1]), true);
//         }
// 
//         GiraphConfiguration giraphConfiguration = new GiraphConfiguration(getConf());
//         giraphConfiguration.setVertexClass(getClass());
//         giraphConfiguration.setVertexInputFormatClass(IntIntNullIntTextInputFormat.class);
//         giraphConfiguration.setVertexOutputFormatClass(IdWithValueTextOutputFormat.class);
// 		giraphConfiguration.set(SOURCE_VERTEX, args[2]);
// 		giraphConfiguration.setWorkerConfiguration(Integer.parseInt(args[3]), Integer.parseInt(args[3]), 100.0f);
// 
// 		GiraphJob job = new GiraphJob(giraphConfiguration, getClass().getName());
// 		FileInputFormat.addInputPath(job.getInternalJob(), new Path(args[0]));
// 		FileOutputFormat.setOutputPath(job.getInternalJob(), new Path(args[1]));
// 		return job.run(true) ? 0 : -1;
// 	}
// 
// 	@Override
// 	public void compute(Iterable<IntWritable> msgIterator) throws IOException {
// 		log.debug("compute(...)::{}#{} ...", getId(), getSuperstep());
// 	    if ( ( getSuperstep() == 0 ) || ( getSuperstep() == 1 ) ) {
// 	    	setValue(new IntWritable(Integer.MAX_VALUE));
// 	    }
// 	    int minDist = isSource() ? 0 : Integer.MAX_VALUE;
// 	    log.debug("compute(...)::{}#{}: min = {}, value = {}", new Object[]{getId(), getSuperstep(), minDist, getValue()});
// 	    for ( IntWritable msg : msgIterator ) {
// 	    	log.debug("compute(...)::{}#{}: <--[{}]-- from ?", new Object[]{getId(), getSuperstep(), msg});
// 	        minDist = Math.min(minDist, msg.get());
// 		    log.debug("compute(...)::{}#{}: min = {}", new Object[]{getId(), getSuperstep(), minDist});
// 	    }
// 	    if (minDist < getValue().get()) {
// 	        setValue(new IntWritable(minDist));
// 		    log.debug("compute(...)::{}#{}: value = {}", new Object[]{getId(), getSuperstep(), getValue()});
// 		    for (Edge<IntWritable,NullWritable> edge : getEdges()) {
// 	    	    log.debug("compute(...)::{}#{}: {} --[{}]--> {}", new Object[]{getId(), getSuperstep(), getId(), minDist+1, edge.getTargetVertexId()});
// 	        	sendMessage(edge.getTargetVertexId(), new IntWritable(minDist + 1));
// 	        }
// 	    }
// 	    voteToHalt();
// 	}
// 
// 	private boolean isSource() {
// 		boolean result = getId().get() == getConf().getInt(SOURCE_VERTEX, SOURCE_VERTEX_DEFAULT);
// 		log.debug("isSource() --> {}", result);
// 		return result;
// 	}
// 
// 	@Override
// 	public void setConf(Configuration conf) {
// 		super.setConf(new ImmutableClassesGiraphConfiguration<IntWritable, IntWritable, NullWritable, IntWritable>(conf));
// 	}
// 	
// 	public static void main(String[] args) throws Exception {
// 		log.debug("main({})", Utils.toString(args));
// 		System.exit(ToolRunner.run(new SingleSourceShortestPaths(), args));
// 	}
// 
// }


// Path: src/test/java/dev/RunGiraphSSSPS.java
import java.util.HashMap;
import org.apache.giraph.io.IdWithValueTextOutputFormat;
import org.apache.giraph.io.IntIntNullIntTextInputFormat;
import org.apache.giraph.utils.InternalVertexRunner;
import org.apache.jena.grande.giraph.sssps.SingleSourceShortestPaths;

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package dev;



public class RunGiraphSSSPS {

	public static final String[] data = new String[] {
		"1 2 5", 
		"2 1 3 5", 
		"3 2 4", 
		"4 3 5 6", 
		"5 1 2 4", 
		"6 4", 
	};
	
	public static void main(String[] args) throws Exception {
	    Iterable<String> results = InternalVertexRunner.run(
	    	SingleSourceShortestPaths.class,