Turi Create  4.0
turi::sgraph_compute::sgraph_engine< T > Class Template Reference

#include <core/storage/sgraph_data/sgraph_engine.hpp>

Detailed Description

template<typename T>
class turi::sgraph_compute::sgraph_engine< T >

PowerGraph computation.

Two central graph computation operations are provided by this class:

  • Vertex Gather
  • Parallel For Edges

Vertex Gather

Given a graph, this class computes for each vertex, a generalized "sum" over neighborhood of each vertex. You need to define a function which is then given

  • the data on the central vertex,
  • the data on the edge,
  • the data on the other vertex
  • The direction of the edge.

The function then performs some computation and aggregates the result into a combiner.

Abstractly:

for v \in vertices:
output[v] = initial_value
for v \in vertices:
for u \in neighbor of v:
gather(data[v], data[v,u], data[u], edge_direction_of_v_u, output[v])
return output

At completion, a vector of shared_ptr to sarrays will be returned. Each sarray corresponds to one vertex partition, and each sarray row corresponds to the result of summing across the neighborhood of the vertex.

This is easiest to explain with an example. Pagerank for instance:

const size_t degree_idx = g.get_vertex_field_id("out_degree");
const size_t pr_idx = g.get_vertex_field_id("pagerank");
// declare a sgraph_engine computation object of a particular return type.
sgraph_compute::sgraph_engine<flexible_type> ga;
ret = ga.gather(g,
[=](const graph_data_type& center,
const graph_data_type& edge,
const graph_data_type& other,
edge_direction edgedir,
flexible_type& combiner) {
combiner = combiner + (1-random_jump_prob) * (other[pr_idx] / other[degree_idx]);
},
flexible_type(random_jump_prob), // initial value
edge_direction::IN_EDGE); // edges to sum over

Parallel For Edges

The parallel_for_edges() performs the following operations on the graph:

Abstractly: Given a function edge_map: (source_data, edge_data, target_data) -> T,

for e \in edges:
output[e] = edge_map(e.source.data(), e.data(), e.target.data())

At completion it returns a vector of shared_ptr to sarrays. Each sarray corresponds to one edge partition, and each edge row corresponds to the result of the map operation over the edge.

Note
Refactoring is required in the furture for this class. Essentially, this class should provide the mechanism to iterate over edges with vertex data properly loaded. Then the user facing "gather" and "parallel for edges" will be simple functions that uses this class.

Definition at line 112 of file sgraph_engine.hpp.


The documentation for this class was generated from the following file: