Skip to content

Commit

Permalink
[FLINK-3013] [gelly] Incorrect package declaration in GellyScalaAPICo…
Browse files Browse the repository at this point in the history
…mpletenessTest.scala

This closes #1356.
  • Loading branch information
smarthi authored and tillrohrmann committed Nov 19, 2015
1 parent db456a7 commit 3a300e6
Show file tree
Hide file tree
Showing 45 changed files with 518 additions and 582 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ object Graph {
/**
* Creates a Graph with from a CSV file of vertices and a CSV file of edges
*
* @param The Execution Environment.
* @param env Execution Environment.
* @param pathEdges The file path containing the edges.
* @param readVertices Defines whether the vertices have associated values.
* If set to false, the vertex input is ignored and vertices are created from the edges file.
Expand Down Expand Up @@ -868,7 +868,7 @@ TypeInformation : ClassTag](jgraph: jg.Graph[K, VV, EV]) {
* Adds the list of vertices, passed as input, to the graph.
* If the vertices already exist in the graph, they will not be added once more.
*
* @param verticesToAdd the list of vertices to add
* @param vertices the list of vertices to add
* @return the new graph containing the existing and newly added vertices
*/
def addVertices(vertices: List[Vertex[K, VV]]): Graph[K, VV, EV] = {
Expand All @@ -881,7 +881,7 @@ TypeInformation : ClassTag](jgraph: jg.Graph[K, VV, EV]) {
* When adding an edge for a non-existing set of vertices,
* the edge is considered invalid and ignored.
*
* @param newEdges the data set of edges to be added
* @param edges the data set of edges to be added
* @return a new graph containing the existing edges plus the newly added edges.
*/
def addEdges(edges: List[Edge[K, EV]]): Graph[K, VV, EV] = {
Expand Down Expand Up @@ -916,7 +916,7 @@ TypeInformation : ClassTag](jgraph: jg.Graph[K, VV, EV]) {
/**
* Removes the given vertex and its edges from the graph.
*
* @param vertex the vertex to remove
* @param vertices list of vertices to remove
* @return the new graph containing the existing vertices and edges without
* the removed vertex and its edges
*/
Expand All @@ -938,7 +938,7 @@ TypeInformation : ClassTag](jgraph: jg.Graph[K, VV, EV]) {
/**
* Removes all the edges that match the edges in the given data set from the graph.
*
* @param edgesToBeRemoved the list of edges to be removed
* @param edges the list of edges to be removed
* @return a new graph where the edges have been removed and in which the vertices remained intact
*/
def removeEdges(edges: List[Edge[K, EV]]): Graph[K, VV, EV] = {
Expand Down Expand Up @@ -993,7 +993,7 @@ TypeInformation : ClassTag](jgraph: jg.Graph[K, VV, EV]) {
* The {@link ReduceNeighborsFunction} combines a pair of neighbor vertex values
* into one new value of the same type.
*
* @param reduceNeighborsFunction the reduce function to apply to the neighbors of each vertex.
* @param reduceEdgesFunction the reduce function to apply to the edges of each vertex.
* @param direction the edge direction (in-, out-, all-)
* @return a Dataset of Tuple2, with one tuple per vertex.
* The first field of the Tuple2 is the vertex ID and the second field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

package org.apache.flink.graph.scala.example;
package org.apache.flink.graph.scala.example

import org.apache.flink.api.scala._
import org.apache.flink.graph.scala._
Expand All @@ -32,7 +32,7 @@ import java.lang.Long
* You can find all available library methods in [[org.apache.flink.graph.library]].
*
* In particular, this example uses the
* [[org.apache.flink.graph.library.ConnectedComponentsAlgorithm.GSAConnectedComponents]]
* [[org.apache.flink.graph.library.GSAConnectedComponents]]
* library method to compute the connected components of the input graph.
*
* The input file is a plain text file and must be formatted as follows:
Expand Down Expand Up @@ -70,7 +70,7 @@ object ConnectedComponents {
}

private final class InitVertices extends MapFunction[Long, Long] {
override def map(id: Long) = {id}
override def map(id: Long) = id
}

// ***********************************************************************
Expand All @@ -87,19 +87,18 @@ object ConnectedComponents {
if(args.length != 3) {
System.err.println("Usage ConnectedComponents <edge path> <output path> " +
"<num iterations>")
false
}
fileOutput = true
edgesInputPath = args(0)
outputPath = args(1)
maxIterations = (2).toInt
maxIterations = 2
} else {
System.out.println("Executing ConnectedComponents 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.out.println("Usage ConnectedComponents <edge path> <output path> " +
"<num iterations>");
"<num iterations>")
}
true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,15 @@
* limitations under the License.
*/

package org.apache.flink.graph.scala.example;
package org.apache.flink.graph.scala.example

import org.apache.flink.api.common.functions.MapFunction
import org.apache.flink.api.scala._
import org.apache.flink.graph.scala._
import org.apache.flink.types.NullValue
import org.apache.flink.graph.Edge
import org.apache.flink.api.common.functions.MapFunction
import scala.collection.JavaConversions._
import org.apache.flink.graph.scala.utils.Tuple3ToEdgeMap
import org.apache.flink.graph.example.utils.SingleSourceShortestPathsData
import org.apache.flink.graph.gsa.GatherFunction
import org.apache.flink.graph.gsa.Neighbor
import org.apache.flink.graph.gsa.SumFunction
import org.apache.flink.graph.gsa.ApplyFunction
import org.apache.flink.graph.gsa.{ApplyFunction, GatherFunction, Neighbor, SumFunction}
import org.apache.flink.graph.scala._
import org.apache.flink.graph.scala.utils.Tuple3ToEdgeMap

/**
* This example shows how to use Gelly's gather-sum-apply iterations.
Expand Down Expand Up @@ -121,20 +116,19 @@ object GSASingleSourceShortestPaths {
if(args.length != 4) {
System.err.println("Usage: SingleSourceShortestPaths <source vertex id>" +
" <input edges path> <output path> <num iterations>")
false
}
fileOutput = true
srcVertexId = args(0).toLong
edgesInputPath = args(1)
outputPath = args(2)
maxIterations = (3).toInt
maxIterations = 3
} else {
System.out.println("Executing Single Source Shortest Paths 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.out.println("Usage: SingleSourceShortestPaths <source vertex id>" +
" <input edges path> <output path> <num iterations>");
" <input edges path> <output path> <num iterations>")
}
true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ object GraphMetrics {
val graph: Graph[Long, NullValue, NullValue] = Graph.fromDataSet(getEdgeDataSet(env), env)

/** get the number of vertices **/
val numVertices = graph.numberOfVertices;
val numVertices = graph.numberOfVertices

/** get the number of edges **/
val numEdges = graph.numberOfEdges;
val numEdges = graph.numberOfEdges

/** compute the average node degree **/
val verticesWithDegrees = graph.getDegrees;
val verticesWithDegrees = graph.getDegrees
val avgDegree = verticesWithDegrees.sum(1).map(in => (in._2 / numVertices).toDouble)

/** find the vertex with the maximum in-degree **/
Expand Down Expand Up @@ -114,7 +114,7 @@ object GraphMetrics {
(key: Long, out: Collector[Edge[Long, NullValue]]) => {
val numOutEdges: Int = (Math.random() * (numVertices / 2)).toInt
for ( i <- 0 to numOutEdges ) {
var target: Long = ((Math.random() * numVertices) + 1).toLong
val target: Long = ((Math.random() * numVertices) + 1).toLong
new Edge[Long, NullValue](key, target, NullValue.getInstance())
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
* limitations under the License.
*/

package org.apache.flink.graph.scala.example;
package org.apache.flink.graph.scala.example

import org.apache.flink.api.scala._
import org.apache.flink.graph.scala._
import org.apache.flink.types.NullValue
import org.apache.flink.graph.Edge
import org.apache.flink.api.common.functions.MapFunction
import org.apache.flink.graph.spargel.VertexUpdateFunction
Expand Down Expand Up @@ -95,7 +94,7 @@ object SingleSourceShortestPaths {
override def updateVertex(vertex: Vertex[Long, Double], inMessages: MessageIterator[Double]) {
var minDistance = Double.MaxValue
while (inMessages.hasNext) {
var msg = inMessages.next
val msg = inMessages.next
if (msg < minDistance) {
minDistance = msg
}
Expand All @@ -115,7 +114,7 @@ object SingleSourceShortestPaths {

override def sendMessages(vertex: Vertex[Long, Double]) {
for (edge: Edge[Long, Double] <- getEdges) {
sendMessageTo(edge.getTarget(), vertex.getValue + edge.getValue)
sendMessageTo(edge.getTarget, vertex.getValue + edge.getValue)
}
}
}
Expand All @@ -135,20 +134,19 @@ object SingleSourceShortestPaths {
if(args.length != 4) {
System.err.println("Usage: SingleSourceShortestPaths <source vertex id>" +
" <input edges path> <output path> <num iterations>")
false
}
fileOutput = true
srcVertexId = args(0).toLong
edgesInputPath = args(1)
outputPath = args(2)
maxIterations = (3).toInt
maxIterations = 3
} else {
System.out.println("Executing Single Source Shortest Paths 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.out.println("Usage: SingleSourceShortestPaths <source vertex id>" +
" <input edges path> <output path> <num iterations>");
" <input edges path> <output path> <num iterations>")
}
true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.flink.streaming.api.scala
package org.apache.flink.graph.scala.test

import java.lang.reflect.Method
import org.apache.flink.graph.scala._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import org.apache.flink.graph.{Edge, Vertex}
object TestGraphUtils {

def getLongLongVertexData(env: ExecutionEnvironment): DataSet[Vertex[Long, Long]] = {
return env.fromCollection(getLongLongVertices)
env.fromCollection(getLongLongVertices)
}

def getLongLongEdgeData(env: ExecutionEnvironment): DataSet[Edge[Long, Long]] = {
return env.fromCollection(getLongLongEdges)
env.fromCollection(getLongLongEdges)
}

def getLongLongVertices: List[Vertex[Long, Long]] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import org.apache.flink.api.scala._
import org.apache.flink.graph.scala._
import org.apache.flink.graph.scala.test.TestGraphUtils
import org.apache.flink.test.util.{MultipleProgramsTestBase, TestBaseUtils}
import org.junit.rules.TemporaryFolder
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import org.junit.{After, Before, Rule, Test}

import _root_.scala.collection.JavaConverters._

@RunWith(classOf[Parameterized])
Expand All @@ -36,33 +36,33 @@ MultipleProgramsTestBase(mode) {

@Test
@throws(classOf[Exception])
def testInDegrees {
def testInDegrees() {
val env: ExecutionEnvironment = ExecutionEnvironment.getExecutionEnvironment
val graph: Graph[Long, Long, Long] = Graph.fromDataSet(TestGraphUtils
.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env)
val res = graph.inDegrees.collect().toList
val res = graph.inDegrees().collect().toList
expectedResult = "(1,1)\n" + "(2,1)\n" + "(3,2)\n" + "(4,1)\n" + "(5,2)\n"
TestBaseUtils.compareResultAsText(res.asJava, expectedResult)
}

@Test
@throws(classOf[Exception])
def testOutDegrees {
def testOutDegrees() {
val env: ExecutionEnvironment = ExecutionEnvironment.getExecutionEnvironment
val graph: Graph[Long, Long, Long] = Graph.fromDataSet(TestGraphUtils
.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env)
val res = graph.outDegrees.collect().toList
val res = graph.outDegrees().collect().toList
expectedResult = "(1,2)\n" + "(2,1)\n" + "(3,2)\n" + "(4,1)\n" + "(5,1)\n"
TestBaseUtils.compareResultAsText(res.asJava, expectedResult)
}

@Test
@throws(classOf[Exception])
def testGetDegrees {
def testGetDegrees() {
val env: ExecutionEnvironment = ExecutionEnvironment.getExecutionEnvironment
val graph: Graph[Long, Long, Long] = Graph.fromDataSet(TestGraphUtils
.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env)
val res = graph.getDegrees.collect().toList
val res = graph.getDegrees().collect().toList
expectedResult = "(1,3)\n" + "(2,2)\n" + "(3,4)\n" + "(4,2)\n" + "(5,3)\n"
TestBaseUtils.compareResultAsText(res.asJava, expectedResult)
}
Expand Down

0 comments on commit 3a300e6

Please sign in to comment.