Skip to content

Commit

Permalink
[gelly] [refactoring] Removed Example end string from all gelly examples
Browse files Browse the repository at this point in the history
Added Algorithm end string to the library methods

This closes apache#625
  • Loading branch information
andralungu authored and marthavk committed Jun 9, 2015
1 parent 03b914e commit d8873ae
Show file tree
Hide file tree
Showing 28 changed files with 119 additions and 138 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
import org.apache.flink.graph.Edge;
import org.apache.flink.graph.Graph;
import org.apache.flink.graph.Vertex;
import org.apache.flink.graph.example.utils.SimpleCommunityDetectionData;
import org.apache.flink.graph.library.SimpleCommunityDetection;
import org.apache.flink.graph.example.utils.CommunityDetectionData;
import org.apache.flink.graph.library.CommunityDetectionAlgorithm;
import org.apache.flink.graph.utils.Tuple3ToEdgeMap;

/**
* This example shows how to use the {@link org.apache.flink.graph.library.SimpleCommunityDetection}
* This example shows how to use the {@link org.apache.flink.graph.library.CommunityDetectionAlgorithm}
* library method:
* <ul>
* <li> with the edge data set given as a parameter
Expand All @@ -43,12 +43,12 @@
* For example: <code>1\t2\t1.0\n1\t3\t2.0\n</code> defines two edges,
* 1-2 with weight 1.0 and 1-3 with weight 2.0.
*
* Usage <code>SimpleCommunityDetection &lt;edge path&gt; &lt;result path&gt;
* Usage <code>CommunityDetection &lt;edge path&gt; &lt;result path&gt;
* &lt;number of iterations&gt; &lt;delta&gt;</code><br>
* If no parameters are provided, the program is run with default data from
* {@link org.apache.flink.graph.example.utils.SimpleCommunityDetectionData}
* {@link org.apache.flink.graph.example.utils.CommunityDetectionData}
*/
public class SimpleCommunityDetectionExample implements ProgramDescription {
public class CommunityDetection implements ProgramDescription {

@SuppressWarnings("serial")
public static void main(String [] args) throws Exception {
Expand All @@ -73,7 +73,7 @@ public Long map(Long label) throws Exception {
// the result is in the form of <vertexId, communityId>, where the communityId is the label
// which the vertex converged to
DataSet<Vertex<Long, Long>> communityVertices =
graph.run(new SimpleCommunityDetection(maxIterations, delta)).getVertices();
graph.run(new CommunityDetectionAlgorithm(maxIterations, delta)).getVertices();

// emit result
if (fileOutput) {
Expand All @@ -82,12 +82,12 @@ public Long map(Long label) throws Exception {
communityVertices.print();
}

env.execute("Executing Simple Community Detection Example");
env.execute("Executing Community Detection Example");
}

@Override
public String getDescription() {
return "Simple Community Detection Example";
return "Community Detection";
}

// *************************************************************************
Expand All @@ -97,13 +97,13 @@ public String getDescription() {
private static boolean fileOutput = false;
private static String edgeInputPath = null;
private static String outputPath = null;
private static Integer maxIterations = SimpleCommunityDetectionData.MAX_ITERATIONS;
private static Double delta = SimpleCommunityDetectionData.DELTA;
private static Integer maxIterations = CommunityDetectionData.MAX_ITERATIONS;
private static Double delta = CommunityDetectionData.DELTA;

private static boolean parseParameters(String [] args) {
if(args.length > 0) {
if(args.length != 4) {
System.err.println("Usage SimpleCommunityDetection <edge path> <output path> " +
System.err.println("Usage CommunityDetection <edge path> <output path> " +
"<num iterations> <delta>");
return false;
}
Expand All @@ -117,7 +117,7 @@ private static boolean parseParameters(String [] args) {
} else {
System.out.println("Executing SimpleCommunityDetection example with default parameters and built-in default data.");
System.out.println("Provide parameters to read input data from files.");
System.out.println("Usage SimpleCommunityDetection <edge path> <output path> " +
System.out.println("Usage CommunityDetection <edge path> <output path> " +
"<num iterations> <delta>");
}

Expand All @@ -134,7 +134,7 @@ private static DataSet<Edge<Long, Double>> getEdgesDataSet(ExecutionEnvironment
.types(Long.class, Long.class, Double.class)
.map(new Tuple3ToEdgeMap<Long, Double>());
} else {
return SimpleCommunityDetectionData.getDefaultEdgeDataSet(env);
return CommunityDetectionData.getDefaultEdgeDataSet(env);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
import org.apache.flink.graph.Edge;
import org.apache.flink.graph.Graph;
import org.apache.flink.graph.Vertex;
import org.apache.flink.graph.example.utils.ConnectedComponentsExampleData;
import org.apache.flink.graph.library.ConnectedComponents;
import org.apache.flink.graph.example.utils.ConnectedComponentsDefaultData;
import org.apache.flink.graph.library.ConnectedComponentsAlgorithm;
import org.apache.flink.types.NullValue;

/**
* This example shows how to use the {@link org.apache.flink.graph.library.ConnectedComponents}
* This example shows how to use the {@link org.apache.flink.graph.library.ConnectedComponentsAlgorithm}
* library method:
* <ul>
* <li> with the edge data set given as a parameter
Expand All @@ -47,9 +47,9 @@
* Usage <code>ConnectedComponents &lt;edge path&gt; &lt;result path&gt;
* &lt;number of iterations&gt; </code><br>
* If no parameters are provided, the program is run with default data from
* {@link org.apache.flink.graph.example.utils.ConnectedComponentsExampleData}
* {@link org.apache.flink.graph.example.utils.ConnectedComponentsDefaultData}
*/
public class ConnectedComponentsExample implements ProgramDescription {
public class ConnectedComponents implements ProgramDescription {

@SuppressWarnings("serial")
public static void main(String [] args) throws Exception {
Expand All @@ -70,7 +70,7 @@ public Long map(Long value) throws Exception {
}, env);

DataSet<Vertex<Long, Long>> verticesWithMinIds = graph
.run(new ConnectedComponents(maxIterations)).getVertices();
.run(new ConnectedComponentsAlgorithm(maxIterations)).getVertices();

// emit result
if (fileOutput) {
Expand All @@ -94,7 +94,7 @@ public String getDescription() {
private static boolean fileOutput = false;
private static String edgeInputPath = null;
private static String outputPath = null;
private static Integer maxIterations = ConnectedComponentsExampleData.MAX_ITERATIONS;
private static Integer maxIterations = ConnectedComponentsDefaultData.MAX_ITERATIONS;

private static boolean parseParameters(String [] args) {
if(args.length > 0) {
Expand Down Expand Up @@ -135,7 +135,7 @@ public Edge<Long, NullValue> map(Tuple2<Long, Long> value) throws Exception {
}
});
} else {
return ConnectedComponentsExampleData.getDefaultEdgeDataSet(env);
return ConnectedComponentsDefaultData.getDefaultEdgeDataSet(env);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
* </ul>
* </p>
*
* Usage <code>EuclideanGraphExample &lt;vertex path&gt; &lt;edge path&gt; &lt;result path&gt;</code><br>
* Usage <code>EuclideanGraphWeighing &lt;vertex path&gt; &lt;edge path&gt; &lt;result path&gt;</code><br>
* If no parameters are provided, the program is run with default data from
* {@link org.apache.flink.graph.example.utils.EuclideanGraphData}
*/
@SuppressWarnings("serial")
public class EuclideanGraphExample implements ProgramDescription {
public class EuclideanGraphWeighing implements ProgramDescription {

public static void main(String[] args) throws Exception {

Expand Down Expand Up @@ -105,7 +105,7 @@ public Double map(Tuple2<Double, Double> distance) throws Exception {
result.print();
}

env.execute("Euclidean Graph Example");
env.execute("Euclidean Graph Weighing Example");
}

@Override
Expand Down Expand Up @@ -163,10 +163,10 @@ private static boolean parseParameters(String[] args) {
edgesInputPath = args[1];
outputPath = args[2];
} else {
System.out.println("Executing Euclidean Graph example with default parameters and built-in default data.");
System.out.println("Executing Euclidean Graph Weighing example with default parameters and built-in default data.");
System.out.println("Provide parameters to read input data from files.");
System.out.println("See the documentation for the correct format of input files.");
System.err.println("Usage: EuclideanGraphExample <input vertices path> <input edges path>" +
System.err.println("Usage: EuclideanGraphWeighing <input vertices path> <input edges path>" +
" <output path>");
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
/**
* This is an implementation of the Connected Components algorithm, using a gather-sum-apply iteration
*/
public class GSAConnectedComponentsExample implements ProgramDescription {
public class GSAConnectedComponents implements ProgramDescription {

// --------------------------------------------------------------------------------------------
// Program
Expand Down Expand Up @@ -109,7 +109,7 @@ public void apply(Long summedValue, Long origValue) {
setResult(summedValue);
}
}
};
}

// --------------------------------------------------------------------------------------------
// Util methods
Expand All @@ -128,7 +128,7 @@ private static boolean parseParameters(String[] args) {
fileOutput = true;

if (args.length != 3) {
System.err.println("Usage: GSAConnectedComponentsExample <edge path> " +
System.err.println("Usage: GSAConnectedComponents <edge path> " +
"<result path> <max iterations>");
return false;
}
Expand All @@ -140,7 +140,7 @@ private static boolean parseParameters(String[] args) {
System.out.println("Executing GSA Connected Components example with built-in default data.");
System.out.println(" Provide parameters to read input data from files.");
System.out.println(" See the documentation for the correct format of input files.");
System.out.println(" Usage: GSAConnectedComponentsExample <edge path> <result path> <max iterations>");
System.out.println(" Usage: GSAConnectedComponents <edge path> <result path> <max iterations>");
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
/**
* This is an implementation of the Single Source Shortest Paths algorithm, using a gather-sum-apply iteration
*/
public class GSASingleSourceShortestPathsExample implements ProgramDescription {
public class GSASingleSourceShortestPaths implements ProgramDescription {

// --------------------------------------------------------------------------------------------
// Program
Expand Down Expand Up @@ -68,7 +68,7 @@ public static void main(String[] args) throws Exception {
singleSourceShortestPaths.print();
}

env.execute("GSA Single Source Shortest Paths Example");
env.execute("GSA Single Source Shortest Paths");
}

@SuppressWarnings("serial")
Expand Down Expand Up @@ -118,7 +118,7 @@ public void apply(Double newDistance, Double oldDistance) {
setResult(newDistance);
}
}
};
}

// --------------------------------------------------------------------------------------------
// Util methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
* For example: <code>1 2\n1 3\n</code> defines two edges 1-2 and 1-3.
* </p>
*
* Usage <code> JaccardSimilarityMeasureExample &lt;edge path&gt; &lt;result path&gt;</code><br>
* Usage <code> JaccardSimilarityMeasure &lt;edge path&gt; &lt;result path&gt;</code><br>
* If no parameters are provided, the program is run with default data from
* {@link org.apache.flink.graph.example.utils.JaccardSimilarityMeasureData}
*/
@SuppressWarnings("serial")
public class JaccardSimilarityMeasureExample implements ProgramDescription {
public class JaccardSimilarityMeasure implements ProgramDescription {

public static void main(String [] args) throws Exception {

Expand Down Expand Up @@ -177,7 +177,7 @@ private static Long getNeighborID(Tuple2<Long, Edge<Long, Double>> edge) {
private static boolean parseParameters(String [] args) {
if(args.length > 0) {
if(args.length != 2) {
System.err.println("Usage JaccardSimilarityMeasureExample <edge path> <output path>");
System.err.println("Usage JaccardSimilarityMeasure <edge path> <output path>");
return false;
}

Expand All @@ -187,7 +187,7 @@ private static boolean parseParameters(String [] args) {
} else {
System.out.println("Executing JaccardSimilarityMeasure example with default parameters and built-in default data.");
System.out.println("Provide parameters to read input data from files.");
System.out.println("Usage JaccardSimilarityMeasureExample <edge path> <output path>");
System.out.println("Usage JaccardSimilarityMeasure <edge path> <output path>");
}

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.apache.flink.graph.Edge;
import org.apache.flink.graph.Graph;
import org.apache.flink.graph.Vertex;
import org.apache.flink.graph.library.LabelPropagation;
import org.apache.flink.graph.library.LabelPropagationAlgorithm;
import org.apache.flink.graph.utils.Tuple2ToVertexMap;
import org.apache.flink.types.NullValue;
import org.apache.flink.util.Collector;
Expand All @@ -48,7 +48,7 @@
*
* If no arguments are provided, the example runs with a random graph of 100 vertices.
*/
public class LabelPropagationExample implements ProgramDescription {
public class LabelPropagation implements ProgramDescription {

public static void main(String[] args) throws Exception {

Expand All @@ -67,7 +67,7 @@ public static void main(String[] args) throws Exception {

// Set up the program
DataSet<Vertex<Long, Long>> verticesWithCommunity = graph.run(
new LabelPropagation<Long>(maxIterations)).getVertices();
new LabelPropagationAlgorithm<Long>(maxIterations)).getVertices();

// Emit results
if(fileOutput) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import org.apache.flink.graph.Graph;
import org.apache.flink.graph.Vertex;
import org.apache.flink.graph.example.utils.MusicProfilesData;
import org.apache.flink.graph.library.LabelPropagation;
import org.apache.flink.graph.library.LabelPropagationAlgorithm;
import org.apache.flink.types.NullValue;
import org.apache.flink.util.Collector;

Expand Down Expand Up @@ -140,7 +140,7 @@ public Long map(String value) {
public Long map(Tuple2<Long, Long> value) {
return value.f1;
}
}).run(new LabelPropagation<String>(maxIterations))
}).run(new LabelPropagationAlgorithm<String>(maxIterations))
.getVertices();

if (fileOutput) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.apache.flink.graph.Edge;
import org.apache.flink.graph.Graph;
import org.apache.flink.graph.Vertex;
import org.apache.flink.graph.library.PageRank;
import org.apache.flink.graph.library.PageRankAlgorithm;
import org.apache.flink.graph.utils.Tuple3ToEdgeMap;
import org.apache.flink.util.Collector;

Expand All @@ -41,7 +41,7 @@
* and random edge weights.
*
*/
public class PageRankExample implements ProgramDescription {
public class PageRank implements ProgramDescription {

@SuppressWarnings("serial")
public static void main(String[] args) throws Exception {
Expand Down Expand Up @@ -73,7 +73,7 @@ public Double map(Tuple2<Double, Long> value) {
});

DataSet<Vertex<Long, Double>> pageRanks = networkWithWeights.run(
new PageRank<Long>(DAMPENING_FACTOR, maxIterations))
new PageRankAlgorithm<Long>(DAMPENING_FACTOR, maxIterations))
.getVertices();

if (fileOutput) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.apache.flink.graph.Graph;
import org.apache.flink.graph.Vertex;
import org.apache.flink.graph.example.utils.SingleSourceShortestPathsData;
import org.apache.flink.graph.library.SingleSourceShortestPaths;
import org.apache.flink.graph.library.SingleSourceShortestPathsAlgorithm;
import org.apache.flink.graph.utils.Tuple3ToEdgeMap;

/**
Expand All @@ -40,7 +40,7 @@
* If no arguments are provided, the example runs with default data from {@link SingleSourceShortestPathsData}.
*
*/
public class SingleSourceShortestPathsExample implements ProgramDescription {
public class SingleSourceShortestPaths implements ProgramDescription {

@SuppressWarnings("serial")
public static void main(String[] args) throws Exception {
Expand All @@ -62,7 +62,7 @@ public Double map(Long value) {
}, env);

DataSet<Vertex<Long, Double>> singleSourceShortestPaths = graph
.run(new SingleSourceShortestPaths<Long>(srcVertexId, maxIterations))
.run(new SingleSourceShortestPathsAlgorithm<Long>(srcVertexId, maxIterations))
.getVertices();

// emit result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* Provides the default data set used for the Simple Community Detection example program.
* If no parameters are given to the program, the default edge data set is used.
*/
public class SimpleCommunityDetectionData {
public class CommunityDetectionData {

// the algorithm is not guaranteed to always converge
public static final Integer MAX_ITERATIONS = 30;
Expand Down Expand Up @@ -61,5 +61,5 @@ public static DataSet<Edge<Long, Double>> getDefaultEdgeDataSet(ExecutionEnviron
return env.fromCollection(edges);
}

private SimpleCommunityDetectionData() {}
private CommunityDetectionData() {}
}

0 comments on commit d8873ae

Please sign in to comment.