From 9317286b72ec8bb065b0422c344c267cc49189e3 Mon Sep 17 00:00:00 2001 From: Reynold Xin Date: Mon, 13 Jan 2014 18:45:35 -0800 Subject: More cleanup. --- graphx/src/main/scala/org/apache/spark/graphx/Edge.scala | 2 +- .../src/main/scala/org/apache/spark/graphx/EdgeDirection.scala | 3 +++ .../org/apache/spark/graphx/lib/ConnectedComponents.scala | 4 +--- .../main/scala/org/apache/spark/graphx/lib/TriangleCount.scala | 10 +++++----- 4 files changed, 10 insertions(+), 9 deletions(-) (limited to 'graphx') diff --git a/graphx/src/main/scala/org/apache/spark/graphx/Edge.scala b/graphx/src/main/scala/org/apache/spark/graphx/Edge.scala index 85463052bc..21be58e740 100644 --- a/graphx/src/main/scala/org/apache/spark/graphx/Edge.scala +++ b/graphx/src/main/scala/org/apache/spark/graphx/Edge.scala @@ -37,7 +37,7 @@ case class Edge[@specialized(Char, Int, Boolean, Byte, Long, Float, Double) ED] if (vid == srcId) EdgeDirection.Out else { assert(vid == dstId); EdgeDirection.In } } -object Edge { +private[graphx] object Edge { def lexicographicOrdering[ED] = new Ordering[Edge[ED]] { override def compare(a: Edge[ED], b: Edge[ED]): Int = (if (a.srcId != b.srcId) a.srcId - b.srcId else a.dstId - b.dstId).toInt diff --git a/graphx/src/main/scala/org/apache/spark/graphx/EdgeDirection.scala b/graphx/src/main/scala/org/apache/spark/graphx/EdgeDirection.scala index 5b58a61bbd..f265764006 100644 --- a/graphx/src/main/scala/org/apache/spark/graphx/EdgeDirection.scala +++ b/graphx/src/main/scala/org/apache/spark/graphx/EdgeDirection.scala @@ -26,6 +26,9 @@ class EdgeDirection private (private val name: String) extends Serializable { } +/** + * A set of [[EdgeDirection]]s. + */ object EdgeDirection { /** Edges arriving at a vertex. */ final val In = new EdgeDirection("In") diff --git a/graphx/src/main/scala/org/apache/spark/graphx/lib/ConnectedComponents.scala b/graphx/src/main/scala/org/apache/spark/graphx/lib/ConnectedComponents.scala index 121df5ad67..4d1f5e74df 100644 --- a/graphx/src/main/scala/org/apache/spark/graphx/lib/ConnectedComponents.scala +++ b/graphx/src/main/scala/org/apache/spark/graphx/lib/ConnectedComponents.scala @@ -14,13 +14,11 @@ object ConnectedComponents { * @tparam ED the edge attribute type (preserved in the computation) * * @param graph the graph for which to compute the connected components - * @param undirected compute reachability ignoring edge direction. * * @return a graph with vertex attributes containing the smallest vertex in each * connected component */ - def run[VD: ClassTag, ED: ClassTag](graph: Graph[VD, ED]): - Graph[VertexID, ED] = { + def run[VD: ClassTag, ED: ClassTag](graph: Graph[VD, ED]): Graph[VertexID, ED] = { val ccGraph = graph.mapVertices { case (vid, _) => vid } def sendMessage(edge: EdgeTriplet[VertexID, ED]) = { if (edge.srcAttr < edge.dstAttr) { diff --git a/graphx/src/main/scala/org/apache/spark/graphx/lib/TriangleCount.scala b/graphx/src/main/scala/org/apache/spark/graphx/lib/TriangleCount.scala index 4b04557bc2..23c9c40594 100644 --- a/graphx/src/main/scala/org/apache/spark/graphx/lib/TriangleCount.scala +++ b/graphx/src/main/scala/org/apache/spark/graphx/lib/TriangleCount.scala @@ -9,11 +9,11 @@ import org.apache.spark.graphx._ * * The algorithm is relatively straightforward and can be computed in three steps: * - * 1) Compute the set of neighbors for each vertex - * 2) For each edge compute the intersection of the sets and send the - * count to both vertices. - * 3) Compute the sum at each vertex and divide by two since each - * triangle is counted twice. + * * * Note that the input graph should have its edges in canonical direction * (i.e. the `sourceId` less than `destId`). Also the graph must have been partitioned -- cgit v1.2.3