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).
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.
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.
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 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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With