Turi Create
4.0
|
Classes | |
class | edge_scope |
class | fast_edge_scope |
class | sgraph_engine |
class | sgraph_synchronize |
class | sgraph_synchronize_interface |
class | vertex_block |
struct | vertex_partition_exchange |
Functions | |
void | hilbert_blocked_parallel_for (size_t n, std::function< void(std::vector< std::pair< size_t, size_t > >) > preamble, std::function< void(std::pair< size_t, size_t >)> fn, size_t parallel_limit=SGRAPH_HILBERT_CURVE_PARALLEL_FOR_NUM_THREADS) |
void | hilbert_parallel_for (size_t n, std::function< void(std::vector< std::pair< size_t, size_t > >) > preamble, std::function< void(std::pair< size_t, size_t >)> fn) |
template<typename Fn , typename T > | |
std::vector< std::shared_ptr< sarray< flexible_type > > > | edge_apply (sgraph &g, std::vector< std::shared_ptr< sarray< T >>> &other, flex_type_enum result_type, Fn fn) |
template<typename Fn > | |
std::vector< std::shared_ptr< sarray< flexible_type > > > | edge_apply (sgraph &g, flex_type_enum result_type, Fn fn) |
template<typename Fn , typename T > | |
std::vector< std::shared_ptr< sarray< flexible_type > > > | edge_apply (sgraph &g, std::string column_name, std::vector< std::shared_ptr< sarray< T >>> &other, flex_type_enum result_type, Fn fn) |
template<typename Fn > | |
std::vector< std::shared_ptr< sarray< flexible_type > > > | edge_apply (sgraph &g, std::string column_name, flex_type_enum result_type, Fn fn) |
template<typename ResultType , typename Reducer , typename Combiner > | |
std::enable_if<!std::is_convertible< Reducer, std::string >::value, ResultType >::type | edge_reduce (sgraph &g, Reducer fn, Combiner combine, ResultType init=ResultType()) |
template<typename ResultType , typename Reducer , typename Combiner > | |
ResultType | edge_reduce (sgraph &g, std::string column_name, Reducer fn, Combiner combine, ResultType init=ResultType()) |
void | fast_triple_apply (sgraph &g, fast_triple_apply_fn_type apply_fn, const std::vector< std::string > &edge_fields, const std::vector< std::string > &mutated_edge_fields) |
template<typename T > | |
std::vector< std::vector< T > > | create_vertex_data (const sgraph &g) |
void | triple_apply (sgraph &g, triple_apply_fn_type apply_fn, const std::vector< std::string > &mutated_vertex_fields, const std::vector< std::string > &mutated_edge_fields={}, bool requires_vertex_id=true) |
void | triple_apply (sgraph &g, batch_triple_apply_fn_type batch_apply_fn, const std::vector< std::string > &mutated_vertex_fields, const std::vector< std::string > &mutated_edge_fields={}) |
void | batch_triple_apply_mock (sgraph &g, triple_apply_fn_type apply_fn, const std::vector< std::string > &mutated_vertex_fields, const std::vector< std::string > &mutated_edge_fields={}) |
template<typename Fn , typename T > | |
std::vector< std::shared_ptr< sarray< flexible_type > > > | vertex_apply (sgraph &g, std::vector< std::shared_ptr< sarray< T >>> &other, flex_type_enum result_type, Fn fn) |
template<typename Fn > | |
std::vector< std::shared_ptr< sarray< flexible_type > > > | vertex_apply (sgraph &g, flex_type_enum result_type, Fn fn) |
template<typename Fn , typename T > | |
std::vector< std::shared_ptr< sarray< flexible_type > > > | vertex_apply (sgraph &g, std::string column_name, std::vector< std::shared_ptr< sarray< T >>> &other, flex_type_enum result_type, Fn fn) |
template<typename Fn > | |
std::vector< std::shared_ptr< sarray< flexible_type > > > | vertex_apply (sgraph &g, std::string column_name, flex_type_enum result_type, Fn fn) |
template<typename ResultType , typename Reducer , typename Combiner > | |
std::enable_if<!std::is_convertible< Reducer, std::string >::value, ResultType >::type | vertex_reduce (sgraph &g, Reducer fn, Combiner combine, ResultType init=ResultType()) |
template<typename ResultType , typename Reducer , typename Combiner > | |
ResultType | vertex_reduce (sgraph &g, std::string column_name, Reducer fn, Combiner combine, ResultType init=ResultType()) |
Graph Computation Functions
void turi::sgraph_compute::batch_triple_apply_mock | ( | sgraph & | g, |
triple_apply_fn_type | apply_fn, | ||
const std::vector< std::string > & | mutated_vertex_fields, | ||
const std::vector< std::string > & | mutated_edge_fields = {} |
||
) |
Mock the single triple apply using batch_triple_apply implementation. Used for testing only.
std::vector<std::vector<T> > turi::sgraph_compute::create_vertex_data | ( | const sgraph & | g | ) |
Utility function
Definition at line 96 of file sgraph_fast_triple_apply.hpp.
std::vector<std::shared_ptr<sarray<flexible_type> > > turi::sgraph_compute::edge_apply | ( | sgraph & | g, |
std::vector< std::shared_ptr< sarray< T >>> & | other, | ||
flex_type_enum | result_type, | ||
Fn | fn | ||
) |
Performs a map operation combining one external array (other) with the graph edge data. other must be the same length as the edge data. Abstractly performs the following computation:
out must be of the result_type specified.
The function must take as the first argument, a vector<flexible_type> and the second argument, T, and must return an object castable to a flexible_type of the result_type specified.
For instance, if I am going to compute a change in message value between the existing column, and a new computed column:
Note that if the apply is only going to access one column, the alternative overload will be more efficient.
Definition at line 69 of file sgraph_edge_apply.hpp.
std::vector<std::shared_ptr<sarray<flexible_type> > > turi::sgraph_compute::edge_apply | ( | sgraph & | g, |
flex_type_enum | result_type, | ||
Fn | fn | ||
) |
Performs a map operation on graph edge_data. Abstractly performs the following computation:
out must be of the result_type specified.
The function must take as the only argument, a vector<flexible_type>. and must return an object castable to a flexible_type of the result_type specified.
For instance, if I am going to compute a "normalized" sampling vector.
Note that if the apply is only going to access one column, the alternative overload will be more efficient.
Definition at line 121 of file sgraph_edge_apply.hpp.
std::vector<std::shared_ptr<sarray<flexible_type> > > turi::sgraph_compute::edge_apply | ( | sgraph & | g, |
std::string | column_name, | ||
std::vector< std::shared_ptr< sarray< T >>> & | other, | ||
flex_type_enum | result_type, | ||
Fn | fn | ||
) |
Performs a map operation combining one external array (other) with one column of the graph edge data. other must be the same length as the edge data. Abstractly performs the following computation:
out must be of the result_type specified.
The function must take as the first argument, a flexible_type and the second argument, T, and must return an object castable to a flexible_type of the result_type specified.
For instance, if I am going to compute a change in message value between the existing column, and a new computed column:
Definition at line 171 of file sgraph_edge_apply.hpp.
std::vector<std::shared_ptr<sarray<flexible_type> > > turi::sgraph_compute::edge_apply | ( | sgraph & | g, |
std::string | column_name, | ||
flex_type_enum | result_type, | ||
Fn | fn | ||
) |
Performs a map operation on one column of the graph edge_data. Abstractly performs the following computation:
out must be of the result_type specified.
The function must take as the only argument, a flexible_type. and must return an object castable to a flexible_type of the result_type specified.
For instance, if I am going to compute the log of the message column.
Definition at line 220 of file sgraph_edge_apply.hpp.
std::enable_if<!std::is_convertible<Reducer, std::string>::value, ResultType>::type turi::sgraph_compute::edge_reduce | ( | sgraph & | g, |
Reducer | fn, | ||
Combiner | combine, | ||
ResultType | init = ResultType() |
||
) |
Performs a reduction over the graph data. If you are only reducing over one column, see the alternative overload.
The edge data is partitioned into small chunks. Within each chunk, the reducer function is called on every element using init as the initial value. This accomplishes a collection of partial reductions. Finally, the combine function is used to merge all the partial reductions which is then returned.
Abstractly performs the following computation:
Example. Here were compute the sum of the triangle_count field of every edge.
Note that if the apply is only going to access one column, the alternative overload will be more efficient.
Definition at line 282 of file sgraph_edge_apply.hpp.
ResultType turi::sgraph_compute::edge_reduce | ( | sgraph & | g, |
std::string | column_name, | ||
Reducer | fn, | ||
Combiner | combine, | ||
ResultType | init = ResultType() |
||
) |
Performs a reduction over a single column of the graph data.
The edge data is partitioned into small chunks. Within each chunk, the reducer function is called on every element using init as the initial value. This accomplishes a collection of partial reductions. Finally, the combine function is used to merge all the partial reductions which is then returned.
Abstractly performs the following computation:
Example. Here were compute the sum of the triangle field of every edge.
Definition at line 344 of file sgraph_edge_apply.hpp.
void turi::sgraph_compute::fast_triple_apply | ( | sgraph & | g, |
fast_triple_apply_fn_type | apply_fn, | ||
const std::vector< std::string > & | edge_fields, | ||
const std::vector< std::string > & | mutated_edge_fields | ||
) |
A faster and simplified version of triple_apply.
The "faster" assumption is based on that vertex data can be loaded entirey into memory and accessed by the apply function through addressing.
The interface made it possible for vertex data to stay in memory across multiple triple applies before commiting to the disk.
Main interface difference:
g | The target graph to perform the transformation. |
apply_fn | The user defined function that will be applied on each edge scope. |
vertex_fields | A subset of vertex data columns that the apply_fn will access. |
mutated_vertex_fields | A subset of columns in vertex_fields that the apply_fn will modify. |
|
inline |
This performs a parallel sweep over an n*n grid following the Hilbert curve ordering. The parallel sweep is broken into two parts. A "preamble" callback which is called sequentially, which contains a list of all the coordinates to be executed in the next pass, and a function which is executed on every coordinate in the pass.
The function abstractly implements the following:
n must be at least 2 and a power of 2.
Definition at line 54 of file hilbert_parallel_for.hpp.
|
inline |
Non blocking version.
Definition at line 73 of file hilbert_parallel_for.hpp.
void turi::sgraph_compute::triple_apply | ( | sgraph & | g, |
triple_apply_fn_type | apply_fn, | ||
const std::vector< std::string > & | mutated_vertex_fields, | ||
const std::vector< std::string > & | mutated_edge_fields = {} , |
||
bool | requires_vertex_id = true |
||
) |
Apply a transform function on each edge and its associated source and target vertices in parallel. Each edge is visited once and in parallel. The modification to vertex data will be protected by lock.
The effect of the function is equivalent to the following pesudo-code:
g | The target graph to perform the transformation. |
apply_fn | The user defined function that will be applied on each edge scope. |
mutated_vertex_fields | A subset of vertex data columns that the apply_fn will modify. |
mutated_edge_fields | A subset of edge data columns that the apply_fn will modify. |
requires_vertex_id | Set to false for optimization when vertex id is not required for triple_apply computation. |
The behavior is undefined when mutated_vertex_fields, and mutated_edge_fields are inconsistent with the apply_fn function.
void turi::sgraph_compute::triple_apply | ( | sgraph & | g, |
batch_triple_apply_fn_type | batch_apply_fn, | ||
const std::vector< std::string > & | mutated_vertex_fields, | ||
const std::vector< std::string > & | mutated_edge_fields = {} |
||
) |
Overload. Take the apply function that processes a batch of edges at once. Used for testing the building block of lambda triple apply.
std::vector<std::shared_ptr<sarray<flexible_type> > > turi::sgraph_compute::vertex_apply | ( | sgraph & | g, |
std::vector< std::shared_ptr< sarray< T >>> & | other, | ||
flex_type_enum | result_type, | ||
Fn | fn | ||
) |
Performs a map operation combining one external array (other) with the graph vertex data. other must be the same length as the vertex data. Abstractly performs the following computation:
out must be of the result_type specified.
The function must take as the first argument, a vector<flexible_type> and the second argument, T, and must return an object castable to a flexible_type of the result_type specified.
For instance, if I am going to compute a change in pagerank value between the existing pagerank column, and a new computed column:
Note that if the apply is only going to access one column, the alternative overload will be more efficient.
Definition at line 69 of file sgraph_vertex_apply.hpp.
std::vector<std::shared_ptr<sarray<flexible_type> > > turi::sgraph_compute::vertex_apply | ( | sgraph & | g, |
flex_type_enum | result_type, | ||
Fn | fn | ||
) |
Performs a map operation on graph vertex_data. Abstractly performs the following computation:
out must be of the result_type specified.
The function must take as the only argument, a vector<flexible_type>. and must return an object castable to a flexible_type of the result_type specified.
For instance, if I am going to compute a "normalized" pagerank.
Note that if the apply is only going to access one column, the alternative overload will be more efficient.
Definition at line 121 of file sgraph_vertex_apply.hpp.
std::vector<std::shared_ptr<sarray<flexible_type> > > turi::sgraph_compute::vertex_apply | ( | sgraph & | g, |
std::string | column_name, | ||
std::vector< std::shared_ptr< sarray< T >>> & | other, | ||
flex_type_enum | result_type, | ||
Fn | fn | ||
) |
Performs a map operation combining one external array (other) with one column of the graph vertex data. other must be the same length as the vertex data. Abstractly performs the following computation:
out must be of the result_type specified.
The function must take as the first argument, a flexible_type and the second argument, T, and must return an object castable to a flexible_type of the result_type specified.
For instance, if I am going to compute a change in pagerank value between the existing pagerank column, and a new computed column:
Definition at line 170 of file sgraph_vertex_apply.hpp.
std::vector<std::shared_ptr<sarray<flexible_type> > > turi::sgraph_compute::vertex_apply | ( | sgraph & | g, |
std::string | column_name, | ||
flex_type_enum | result_type, | ||
Fn | fn | ||
) |
Performs a map operation on one column of the graph vertex_data. Abstractly performs the following computation:
out must be of the result_type specified.
The function must take as the only argument, a flexible_type. and must return an object castable to a flexible_type of the result_type specified.
For instance, if I am going to compute a "normalized" pagerank.
Definition at line 220 of file sgraph_vertex_apply.hpp.
std::enable_if<!std::is_convertible<Reducer, std::string>::value, ResultType>::type turi::sgraph_compute::vertex_reduce | ( | sgraph & | g, |
Reducer | fn, | ||
Combiner | combine, | ||
ResultType | init = ResultType() |
||
) |
Performs a reduction over the graph data. If you are only reducing over one column, see the alternative overload.
The vertex data is partitioned into small chunks. Within each chunk, the reducer function is called on every element using init as the initial value. This accomplishes a collection of partial reductions. Finally, the combine function is used to merge all the partial reductions which is then returned.
Abstractly performs the following computation:
Example. Here were compute the sum of the pagerank field of every vertex.
Note that if the apply is only going to access one column, the alternative overload will be more efficient.
Definition at line 281 of file sgraph_vertex_apply.hpp.
ResultType turi::sgraph_compute::vertex_reduce | ( | sgraph & | g, |
std::string | column_name, | ||
Reducer | fn, | ||
Combiner | combine, | ||
ResultType | init = ResultType() |
||
) |
Performs a reduction over a single column of the graph data.
The vertex data is partitioned into small chunks. Within each chunk, the reducer function is called on every element using init as the initial value. This accomplishes a collection of partial reductions. Finally, the combine function is used to merge all the partial reductions which is then returned.
Abstractly performs the following computation:
Example. Here were compute the sum of the pagerank field of every vertex.
Definition at line 342 of file sgraph_vertex_apply.hpp.