GraphLab: Distributed Graph-Parallel API
2.1
|
Provides the ability to pass information between vertices of two different graphs. More...
#include <graphlab/graph/graph_vertex_join.hpp>
Public Types | |
typedef LeftGraph | left_graph_type |
Type of the left graph. | |
typedef RightGraph | right_graph_type |
Type of the right graph. | |
typedef right_graph_type::vertex_type | left_vertex_type |
Vertex Type of the left graph. | |
typedef left_graph_type::vertex_type | right_vertex_type |
Vertex Type of the right graph. | |
typedef right_graph_type::local_vertex_type | left_local_vertex_type |
Local Vertex Type of the left graph. | |
typedef left_graph_type::local_vertex_type | right_local_vertex_type |
Local Vertex Type of the right graph. | |
typedef right_graph_type::vertex_data_type | left_data_type |
Vertex Data Type of the left graph. | |
typedef left_graph_type::vertex_data_type | right_data_type |
Vertex Data Type of the right graph. |
Public Member Functions | |
graph_vertex_join (distributed_control &dc, left_graph_type &left, right_graph_type &right) | |
template<typename LeftEmitKey , typename RightEmitKey > | |
void | prepare_injective_join (LeftEmitKey left_emit_key, RightEmitKey right_emit_key) |
Initializes the join by associating each vertex with a key. | |
template<typename JoinOp > | |
void | left_injective_join (JoinOp join_op) |
Performs an injective join from the right graph to the left graph. | |
template<typename JoinOp > | |
void | right_injective_join (JoinOp join_op) |
Performs an injective join from the left graph to the right graph. |
Public Attributes | |
dc_dist_object < graph_vertex_join< LeftGraph, RightGraph > > | rmi |
Provides the ability to pass information between vertices of two different graphs.
LeftGraph | Type of the left graph |
RightGraph | Type of the right graph |
The graph_vertex_join class allows information to be passed between vertices of two different graphs.
Given two graphs g1
and g2
, possibly of different types:
A graph_vertex_join object can be created:
The first argument is the distributed control object. The second argument shall be referred to as the graph on the "left" side of the join, and the third argument shall be referred to as the graph on the "right" side of the join.
The join operates by having each vertex in both graph emit an integer key. Vertices with the same key are then combined into the same group. The semantics of the key depends on the join operation to be performed. Right now, the only join operation supported is the Left Injective Join and the Right Injective Join (see below).
For the left injective join, vertices in the same graph must emit distinct unique keys. i.e. Each vertex in g1
must emit a key which is different from all other vertices in g1
. Vertices on the right graph are then matched with vertices on the left graph with the same key. The join operation is then allowed to modify vertices on the left graph given the data on the vertices of the right graph.
To emit the keys:
left_emit_key and right_emit_key are functions (or lambda) with the following prototype:
They essentially take as a constant argument, the vertex of their respective graphs, and return an integer key. If the key has value (-1) it does not participate in the join. After keys are emitted and prepared with prepare_join, to perform a left injective join:
Where join_op is a function with the following prototype:
Note the asymmetry in the arguments: the left vertex is passed as a vertex_type, while for the right vertex, only the vertex data is accessible. The function may make modifications on the left vertex.
The left_injective_join() function must be called by all machines. As a result, it may be used from within an engine's graphlab::iengine::add_vertex_aggregator aggregator's finalize function.
I have two graphs with identical structure. The left graph has data
However, when the left graph was constructed, there was no email address information conveniently available, and thus was left blank.
And the right graph has vertex data:
which was loaded from some other source, and contains all the email address information.
I create emit functions for both graphs :
Create a join object and prepare the join:
To copy the email address field from the right graph to the left graph:
The right injective join is similar to the left injective join, but with types reversed.
Definition at line 171 of file graph_vertex_join.hpp.
|
inline |
Performs an injective join from the right graph to the left graph.
JoinOp | The type of the joinop function. It should not be necessary to specify this. C++ type inference should be able to infer this automatically. |
join_op | The joining function. May be a function pointer or a lambda matching the prototype void join_op(LeftGraph::vertex_type& left_vertex, const RightGraph::vertex_data_type right_vertex_data); |
prepare_injective_join() must be called before hand. All machines must call this function. join_op will be called on each left vertex with the data on a right vertex which emitted the same key in prepare_injective_join(). The join_op function is allowed to modify the vertex data on the left graph.
Definition at line 304 of file graph_vertex_join.hpp.
|
inline |
Initializes the join by associating each vertex with a key.
LeftEmitKey | Type of the left_emit_key parameter. It should not be necessary to specify this. C++ type inference should be able to infer this automatically. |
RightEmitKey | Type of the right_emit_key parameter. It should not be necessary to specify this. C++ type inference should be able to infer this automatically. |
left_emit_key | A function which takes a vertex_type from the left graph and emits an integral key value. Can be a lambda, of the prototype: size_t left_emit_key(const LeftGraph::vertex_type& vertex); |
right_emit_key | A function which takes a vertex_type from the right graph and emits an integral key value. Can be a lambda, of the prototype: size_t right_emit_key(const RightGraph::vertex_type& vertex); |
The semantics of the key depend on the actual join operation performed. This function must be called by all machines.
left_emit_key and right_emit_key are functions (or lambda) with the following prototype:
They essentially take as a constant argument, the vertex of their respective graphs, and return an integer key. If a vertex emits the key (size_t)(-1) it does not participate in the join.
prepare_injective_join() only needs to be called once. After which an arbitrary number of left_injective_join() and right_injective_join() calls may be made.
If after a join, a new join is to be performed on the same graph using new data, or new emit functions, prepare_injective_join() can be called again to recompute the join.
Definition at line 255 of file graph_vertex_join.hpp.
|
inline |
Performs an injective join from the left graph to the right graph.
JoinOp | The type of the joinop function. It should not be necessary to specify this. C++ type inference should be able to infer this automatically. |
join_op | The joining function. May be a function pointer or a lambda matching the prototype void join_op(RightGraph::vertex_type& right_vertex, const LeftGraph::vertex_data_type left_vertex_data); |
prepare_injective_join() must be called before hand. All machines must call this function. join_op will be called on each rght vertex with the data on a left vertex which emitted the same key in prepare_injective_join(). The join_op function is allowed to modify the vertex data on the right graph.
Definition at line 330 of file graph_vertex_join.hpp.