Skip to content
Snippets Groups Projects
Commit 9317286b authored by Reynold Xin's avatar Reynold Xin
Browse files

More cleanup.

parent 8e5c7324
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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")
......
......@@ -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) {
......
......@@ -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.
* <ul>
* <li>Compute the set of neighbors for each vertex
* <li>For each edge compute the intersection of the sets and send the count to both vertices.
* <li> Compute the sum at each vertex and divide by two since each triangle is counted twice.
* </ul>
*
* 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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment