- Home /

I want to find out the symmetry difference of neighbors for all pair of vertices in a graph based on graphX in a parallel manner.

For example, two vertices a and b, N(a) = {c,d,e}, N(b) = {c,d,f}, the symmetry difference is symm_diff(N(a),N(b)) = {e,f}. how to do this in a parallel manner for all pair of vertices?

Actually, even the following codes cannot work:

/*return the degree of a vertex id in graph g*/ def nbrs_func(id: VertexId,g : Graph[rankVertex, Int]) : Int = { g.collectNeighborIds(EdgeDirection.Either).filter(v => (v._1 == id)).first()._2.length }

val result = ids.cartesian(ids).filter( pair => (pair._1 < pair._2)).cache() /*print the degree sum of all pair vertices in graph*/ result.map( pair => (pair._1,pair._2, nbrs_func(pair._1,rank_g) + nbrs_func(pair._2,rank_g))) .foreach( v => println(v._1 + " " + v._2 + " " + v._3))

however, if add .collect() to result, it worked. But, actually, the codes is not in parallel

result.collect().map( pair => (nbrs_func(pair._1,rank_g) + nbrs_func(pair._2,rank_g))) .foreach( v => println(v))

Comment

Databricks Inc.

160 Spear Street, 13th Floor

San Francisco, CA 94105

info@databricks.com

1-866-330-0121

- Anonymous
- Sign in
- Create
- Ask a question
- Create an article
- Explore
- Topics
- Questions
- Articles
- Badges