0% found this document useful (0 votes)
12 views3 pages

Graphx

process of graphx

Uploaded by

sahithiturubati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

Graphx

process of graphx

Uploaded by

sahithiturubati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

scala> import [Link].

_
import [Link]._

scala> import [Link]


import [Link]

scala> import [Link]._


import [Link]._

................................................................................
Creating Vertics Table ---->
-----------------------------
scala> val vertices=Array((1L, ("A")),(2L, ("B")),(3L, ("C")))
vertices: Array[(Long, String)] = Array((1,A), (2,B), (3,C))

scala> val vRDD= [Link](vertices)


vRDD: [Link][(Long, String)] = ParallelCollectionRDD[0] at
parallelize at <console>:31

scala> [Link](1)
[Stage 0:> (0 + 0) [Stage
0:> (0 + 1)
res0: Array[(Long, String)] = Array((1,A))

................................................................................
Creating Edges TAble ------>
-------------------------------
scala> val edges=Array(Edge(1L,2L,1800),Edge(2L,3L,800),Edge(3L,1L,1400))
edges: Array[[Link][Int]] = Array(Edge(1,2,1800),
Edge(2,3,800), Edge(3,1,1400))

scala> val eRDD=[Link](edges)


eRDD: [Link][[Link][Int]] =
ParallelCollectionRDD[1] at parallelize at <console>:31

scala> [Link](2)
res1: Array[[Link][Int]] = Array(Edge(1,2,1800),
Edge(2,3,800))
..................................................................................

scala> val nowhere = "nowwhere"


nowhere: String = nowwhere

scala> val graph = Graph(vRDD,eRDD, nowhere)


graph: [Link][String,Int] =
[Link]@27af34df

scala> [Link](println)
(1,A)
(2,B)
(3,C)

scala> [Link](println)
Edge(1,2,1800)
Edge(2,3,800)
Edge(3,1,1400)
..................................................................................

val numvertice = [Link]


val numvertice: Long = 3

scala> val numroutes = [Link]


numroutes: Long = 3

scala>[Link] { case Edge(src, dst, prop) => prop >


1000 }.[Link](println)
Edge(1,2,1800)
Edge(3,1,1400)

scala> [Link](3).foreach(println)
((1,A),(2,B),1800)
((2,B),(3,C),800)
((3,C),(1,A),1400)

scala> val f= [Link]


f: [Link][Int] = VertexRDDImpl[25] at RDD at
[Link]

scala> [Link]()
res6: Array[([Link], Int)] = Array((1,1), (2,1), (3,1))
..................................................................................

scala> val fv= [Link]


fv: [Link][Int] = VertexRDDImpl[33] at RDD at
[Link]

scala> [Link]()
res8: Array[([Link], Int)] = Array((1,1), (2,1), (3,1))

scala> val totalDegrees = [Link]


totalDegrees: [Link][Int] = VertexRDDImpl[29] at RDD at
[Link]

scala> [Link]()
res9: Array[([Link], Int)] = Array((1,2), (2,2), (3,2))
..................................................................................

scala> import [Link]._


import [Link]._

scala> import [Link]


import [Link]

scala> import [Link]._


import [Link]._

scala> val vertices=Array((3L, ("rxin","student")),(7L, ("jgonzal","postdoc")),(5L,


("franklin","prof")), (2L, ("istoica", "prof")))
vertices: Array[(Long, (String, String))] = Array((3,(rxin,student)), (7,
(jgonzal,postdoc)), (5,(franklin,prof)), (2,(istoica,prof)))

scala> val vRDD= [Link](vertices)


vRDD: [Link][(Long, (String, String))] = ParallelCollectionRDD[0]
at parallelize at <console>:31

scala> val edges=Array(Edge(3L, 7L, "collab"), Edge(5L, 3L, "advisor"), Edge(2L,


5L, "colleague"), Edge(5L, 7L, "pi"))
edges: Array[[Link][String]] = Array(Edge(3,7,collab),
Edge(5,3,advisor), Edge(2,5,colleague), Edge(5,7,pi))

scala> val eRDD=[Link](edges)


eRDD: [Link][[Link][String]] =
ParallelCollectionRDD[1] at parallelize at <console>:31

scala> val defaultUser = ("john doe", "missing")


defaultUser: (String, String) = (john doe,missing)

scala> val graph = Graph(vRDD,eRDD,defaultUser)


graph: [Link][(String, String),String] =
[Link]@1f55bb2
...................................................................................
.................................................

scala> [Link] {case (id, (name, pos)) => pos == "postdoc" }.count
res0: Long = 1

scala> [Link](e => [Link] > [Link]).count


res2: Long = 1

scala> [Link] { case Edge(src, dst, prop) => src > dst }.count
res4: Long = 1
...................................................................................
...............................................
PAGE RANK ::>
scala> val rank = [Link](0.0001).vertices
rank: [Link][Double] = VertexRDDImpl[106] at RDD at
[Link]

scala> println([Link]().mkString("\n"))
(2,0.5037267911816329)
(3,0.8997819807481918)
(5,0.9318945636860209)
(7,1.6645966643841548)

scala> [Link](println)
(2,(istoica,prof))
(3,(rxin,student))
(5,(franklin,prof))
(7,(jgonzal,postdoc))

scala> [Link](println)
Edge(3,7,collab)
Edge(5,3,advisor)
Edge(2,5,colleague)
Edge(5,7,pi)
...................................................................................
.................................

You might also like