Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implement a directed Graph as an undirected graph using GraphX

I have following directed graph as given by the nodes and edges below.

Nodes

1,2,3,4,5

Edges

(1,2),(1,3),(1,4),(2,5),(3,4),(3,5),(4,5)

How do I convert this directed graph to undirected graph Do I have to convert using built-in method. If there is build in method, what method is it?. Or, do I have to add edges manually in the dataset such as (1,2) to (2,1).

like image 492
Yasir Avatar asked Nov 21 '16 20:11

Yasir


People also ask

How do you convert an undirected graph into directed graph?

Every undirected graph can be easily converted to an equivalent directed graph via a simple transformation: Replace every undirected edge with two directed edges in opposite directions.

Is GraphX available in Pyspark?

GraphX is a new component in Spark for graphs and graph-parallel computation. At a high level, GraphX extends the Spark RDD by introducing a new Graph abstraction: a directed multigraph with properties attached to each vertex and edge.

What is directed undirected graph?

Undirected graphs have edges that do not have a direction. The edges indicate a two-way relationship, in that each edge can be traversed in both directions. This figure shows a simple undirected graph with three nodes and three edges. Directed graphs have edges with direction.

What is graph processing in spark?

What is Spark GraphX? GraphX is the Spark API for graphs and graph-parallel computation. It includes a growing collection of graph algorithms and builders to simplify graph analytics tasks. GraphX extends the Spark RDD with a Resilient Distributed Property Graph.


1 Answers

You don't need to convert your graph to an undirected graph. You'll simply have to treat it as an undirected graph (by simply ignoring the edge directions).

For example, if you use collectNeighbors, you can make it act as an undirected graph by passing an EdgeDirection.Either as parameter.

like image 69
cheseaux Avatar answered Sep 21 '22 05:09

cheseaux