Skip to content
Snippets Groups Projects
Commit fa2f87ca authored by Joseph E. Gonzalez's avatar Joseph E. Gonzalez
Browse files

added replication and balance reporting

parent 5f756fb6
No related branches found
No related tags found
No related merge requests found
...@@ -47,6 +47,17 @@ object Analytics extends Logging { ...@@ -47,6 +47,17 @@ object Analytics extends Logging {
val pagerankGraph = graph.leftJoinVertices[Int, (Int, Double)](graph.outDegrees, val pagerankGraph = graph.leftJoinVertices[Int, (Int, Double)](graph.outDegrees,
(vertex, deg) => (deg.getOrElse(0), 1.0) (vertex, deg) => (deg.getOrElse(0), 1.0)
) )
println("Vertex Replication: " + pagerankGraph.replication)
val edgeCounts = pagerankGraph.balance
println("Edge Balance: " + (edgeCounts.max.toDouble / edgeCounts.min ) )
println("Min edge block: " + edgeCounts.min)
println("Max edge block: " + edgeCounts.max)
Pregel.iterate[(Int, Double), ED, Double](pagerankGraph)( Pregel.iterate[(Int, Double), ED, Double](pagerankGraph)(
(vertex, a: Double) => (vertex.data._1, (resetProb + (1.0 - resetProb) * a)), // apply (vertex, a: Double) => (vertex.data._1, (resetProb + (1.0 - resetProb) * a)), // apply
(me_id, edge) => Some(edge.src.data._2 / edge.src.data._1), // gather (me_id, edge) => Some(edge.src.data._2 / edge.src.data._1), // gather
......
...@@ -18,6 +18,12 @@ import org.apache.spark.rdd.RDD ...@@ -18,6 +18,12 @@ import org.apache.spark.rdd.RDD
*/ */
abstract class Graph[VD: ClassManifest, ED: ClassManifest] { abstract class Graph[VD: ClassManifest, ED: ClassManifest] {
def replication: Double
def balance: Array[Int]
/** /**
* Get the vertices and their data. * Get the vertices and their data.
* *
......
...@@ -56,6 +56,16 @@ class GraphImpl[VD: ClassManifest, ED: ClassManifest] protected ( ...@@ -56,6 +56,16 @@ class GraphImpl[VD: ClassManifest, ED: ClassManifest] protected (
this this
} }
override def replication(): Double = {
val rep = vTable.map{ case (_, (_, a)) => a.size }.sum
rep / vTable.count
}
override def balance(): Array[Int] = {
eTable.map{ case (_, epart) => epart.data.size }.collect
}
override def reverse: Graph[VD, ED] = { override def reverse: Graph[VD, ED] = {
newGraph(vertices, edges.map{ case Edge(s, t, e) => Edge(t, s, e) }) newGraph(vertices, edges.map{ case Edge(s, t, e) => Edge(t, s, e) })
} }
......
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