This question is about Spark GraphX. Given an arbitry graph, I want to compute a new graph that adds edges between any two nodes v, w that are both pointed to by some node x. The new edges should contain the pointing node as an attribute.
That is, given edges (x, v, nil) and (x, w, nil) compute edges (v, w, x) and (w, v, x).
It should work for any graph and not require me to know anything about the graph before hand, such as vertex ids.
Example
[Task] Add two directioned edges between nodes (e.g. A, C) when pointed to by same node (e.g. B).
Input graph:
┌────┐
┌─────│ B │──────┐
│ └────┘ │
v v
┌────┐ ┌────┐
│ A │ │ C │
└────┘ └────┘
^ ^
│ ┌────┐ │
└─────│ D │──────┘
└────┘
Output graph (bi-directional edges = two directed edges):
┌────┐
┌─────│ B │──────┐
│ └────┘ │
v v
┌────┐<───by B───>┌────┐
│ A │ │ C │
└────┘<───by D───>└────┘
^ ^
│ ┌────┐ │
└─────│ D │──────┘
└────┘
How to elegantly write a GraphX query that returns the output graph?