Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to print sortedVBC? #4

Open
yponcet opened this issue Mar 5, 2017 · 3 comments
Open

How to print sortedVBC? #4

yponcet opened this issue Mar 5, 2017 · 3 comments

Comments

@yponcet
Copy link

yponcet commented Mar 5, 2017

Hi, I am trying to print the sortedVBC. I do not get errors by building the .jar file, but anything is shown when I run it. Please, this is my source code to do so:

val graph = Graph(vertices, edges, defaultVertex)

val k = 3

val kBCGraph = KBetweenness.run(graph, k)
   
val verticesBetweenness = kBCGraph.vertices.collect()
  
val sortedVBC = verticesBetweenness.sortWith((x,y) => x._1 < y._1)

println(s"${sortedVBC(0)._1} should equal (1L)")

Best and thanks in advance

@dmarcous
Copy link
Owner

dmarcous commented Mar 5, 2017

Hi,
Can you please mention what isn't working correctly here?
Do you get the VBC values wrong? / sorted wrong? Are you getting anything at all?
Is the resulting graph empty? Maybe the original graph your are supplying is empty?
NOTE - your are sorting by node_ids not VBC values (graphX graph object is (id,value) so you need to use *._2 and not *._1).
Please attach the graph or a sample of the graph you are using to test whether this works correctly.
You can also try and run some of the tests here to get a hang of how to use the library on some example data

@yponcet
Copy link
Author

yponcet commented Mar 5, 2017

Hi,
Now I could add your library to my project without errors, but I do not get any result when I run it on my graph. Please, here I attach a sample of it and my source code:

val sc = new SparkContext(new SparkConf().setAppName("Spark Count"))

val vertexArray = Array(
(1L, ("Alice", 28)),
(2L, ("Bob", 27)),
(3L, ("Charlie", 65)),
(4L, ("David", 42)),
(5L, ("Ed", 55)),
(6L, ("Fran", 50))
)
val edgeArray = Array(
Edge(2L, 1L, 7),
Edge(2L, 4L, 2),
Edge(3L, 2L, 4),
Edge(3L, 6L, 3),
Edge(4L, 1L, 1),
Edge(5L, 2L, 2),
Edge(5L, 3L, 8),
Edge(5L, 6L, 3)
)

val vertexRDD: RDD[(Long, (String, Int))] = sc.parallelize(vertexArray)
val edgeRDD: RDD[Edge[Int]] = sc.parallelize(edgeArray)

val graph: Graph[(String, Int), Int] = Graph(vertexRDD, edgeRDD)
val kBCGraph = KBetweenness.run(graph, 2)

val verticesBetweenness = kBCGraph.vertices.collect()

val sortedVBC = verticesBetweenness.sortWith((x,y) => x._1 < y._1)

println(s"$sortedVBC(0)._1")

@dmarcous
Copy link
Owner

dmarcous commented Nov 5, 2017

Did you manage to get it to work?
Maybe not the recommended scala/spark version as on readme?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants