FlashGraph-ng
A new frontier in large-scale graph analysis and data mining
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Public Member Functions | Static Public Member Functions | List of all members
fg::FG_vector< T > Class Template Reference

FlashGraph vector that provides several parallelized methods when compared to an STL-vector.
NOTE: Not an STL-compatible data structure. This vector is also ideally used with numeric data types.
Methods marked with the keyword parallel are parallelized implementations. More...

#include <FG_vector.h>

Public Member Functions

void init (T v)
 Initialize the vector a single value as specified by parameter 1. More...
 
void plus_eq (FG_vector< T >::ptr other)
 Equivalent to += operator. Element by element addition of one FG_vector to another. More...
 
void assign (size_t num, T val)
 Assign a value num many times to the vector. More...
 
void shallow_copy (FG_vector< T >::ptr other)
 Make a shallow copy of the vector. More...
 
bool eq_all (FG_vector< T >::ptr other)
 Check for equality between two FG_vectors element by element. More...
 
void unique (std::set< T > &set) const
 Populate an STL set with the unique elements in the vector. All duplicates are ignored. More...
 
void count_unique (count_map< T > &map) const
 Count the number of unique items in the vector using a count map. More...
 
size_t get_size () const
 Get the number of elements contained in the vector. More...
 
T * get_data ()
 Get a pointer to the memory array used internally by the vector to store its owned elements. More...
 
const T * get_data () const
 Const method to get a pointer to the memory array used internally by the vector to store its owned elements. More...
 
dot_product (const FG_vector< T > &other) const
 Compute the dot product of two FG vectors.
parallel More...
 
norm2 () const
 Compute the L2 Norm#Euclidean_norm) (also know as Euclidean distance) of a vector.
parallel More...
 
norm1 () const
 Compute the L1 Norm#Taxicab_norm_or_Manhattan_norm) (also Taxicab norm) of an FG_vector.
parallel More...
 
sum () const
 Compute the sum of all elements in the vector.
If the type is integer, the sum can overflow. parallel More...
 
template<class ResType >
ResType sum () const
 Compute the sum of all elements in the vector.
This sum() allows users to specify the type of the result, so users can avoid integer overflow. parallel More...
 
max () const
 Find the maximal value in the vector and return its value. More...
 
std::pair< T, off_t > max_val_loc () const
 Find the maximal value in the vector and return its value and its location. More...
 
min () const
 Find the index with the minmimal value in the vector and return its value. More...
 
size_t argmin ()
 Find the index with the minimal value in the vector and return the index. More...
 
void print (vsize_t max_print_size=100)
 Serial element-wise print of the vector. Not intended for very large vectors
 
void to_file (std::string fn)
 Write the space separated vector to file. More...
 
void div_by_in_place (T v)
 In place division of vector by a single value. More...
 
template<class MergeFunc , class VecType >
void merge_in_place (typename FG_vector< VecType >::ptr vec, MergeFunc func)
 element-wise merge with another vector and store the result in this vector. More...
 
template<class T2 >
void add_in_place (typename FG_vector< T2 >::ptr vec)
 In place element-wise addition by another vector. More...
 
template<class T2 >
void subtract_in_place (typename FG_vector< T2 >::ptr &vec)
 In place subtraction of the vector by another vector. More...
 
void normalize (int type)
 Normalize vector using an Lx form. parallel
 
template<class ApplyFunc >
void apply (ApplyFunc func, FG_vector< T > &output)
 Apply a function to every element in an FG_vector. More...
 
void set (vertex_id_t id, const T &v)
 
const T & get (vertex_id_t id) const
 Const get the value of a particular index. More...
 
T & get (vertex_id_t id)
 Non-const get the value of a particular index. More...
 

Static Public Member Functions

static ptr create (graph_engine::ptr graph)
 Create a vector of the length the same as the number of vertices in the graph. An object of this class should be created using this or the create(size_t size) method. More...
 
static ptr create (size_t size)
 Create a vector of the specified length. An object of this class should be created using this or the create(graph_engine::ptr graph) method. More...
 

Detailed Description

template<class T>
class fg::FG_vector< T >

FlashGraph vector that provides several parallelized methods when compared to an STL-vector.
NOTE: Not an STL-compatible data structure. This vector is also ideally used with numeric data types.
Methods marked with the keyword parallel are parallelized implementations.

Member Function Documentation

template<class T>
template<class T2 >
void fg::FG_vector< T >::add_in_place ( typename FG_vector< T2 >::ptr  vec)
inline

In place element-wise addition by another vector.

Parameters
vecThe vector by which you want to add to this vector. parallel
template<class T>
template<class ApplyFunc >
void fg::FG_vector< T >::apply ( ApplyFunc  func,
FG_vector< T > &  output 
)
inline

Apply a function to every element in an FG_vector.

Parameters
funcA user-defined function.
outputThe FG_vector that you want to apply the function to.

parallel

template<class T>
size_t fg::FG_vector< T >::argmin ( )
inline

Find the index with the minimal value in the vector and return the index.

Returns
The minimal index value in the vector.
template<class T>
void fg::FG_vector< T >::assign ( size_t  num,
val 
)
inline

Assign a value num many times to the vector.

Parameters
numThe number of elements to assign.
valThe value a user wnats to assign to vector positions.
template<class T>
void fg::FG_vector< T >::count_unique ( count_map< T > &  map) const
inline

Count the number of unique items in the vector using a count map.

Parameters
mapAn empty count_map object that is used to count the number of unique elements in the vector.
template<class T>
static ptr fg::FG_vector< T >::create ( graph_engine::ptr  graph)
inlinestatic

Create a vector of the length the same as the number of vertices in the graph. An object of this class should be created using this or the create(size_t size) method.

Smart pointer for object access

Parameters
graphA shared pointer to a graph engine object. This is generally the graph for which you are creating the vector.
template<class T>
static ptr fg::FG_vector< T >::create ( size_t  size)
inlinestatic

Create a vector of the specified length. An object of this class should be created using this or the create(graph_engine::ptr graph) method.

Parameters
sizeThe length of the vector you desire.
template<class T>
void fg::FG_vector< T >::div_by_in_place ( v)
inline

In place division of vector by a single value.

Parameters
vThe value by which you want the array divided. parallel
template<class T>
T fg::FG_vector< T >::dot_product ( const FG_vector< T > &  other) const
inline

Compute the dot product of two FG vectors.
parallel

Returns
A value of data type T value that is the dot product.
template<class T>
bool fg::FG_vector< T >::eq_all ( FG_vector< T >::ptr  other)
inline

Check for equality between two FG_vectors element by element.

Parameters
otherAn FG_vector smart pointer.
template<class T>
const T& fg::FG_vector< T >::get ( vertex_id_t  id) const
inline

Const get the value of a particular index.

Parameters
idThe index of the vector from where you want a value.
Returns
The value requested by param 1
template<class T>
T& fg::FG_vector< T >::get ( vertex_id_t  id)
inline

Non-const get the value of a particular index.

Parameters
idThe index of the vector from where you want a value.
Returns
The value requested by param 1
template<class T>
T* fg::FG_vector< T >::get_data ( )
inline

Get a pointer to the memory array used internally by the vector to store its owned elements.

Returns
A pointer the underlying data memory array.
template<class T>
const T* fg::FG_vector< T >::get_data ( ) const
inline

Const method to get a pointer to the memory array used internally by the vector to store its owned elements.

Returns
A const pointer the underlying data memory array.
template<class T>
size_t fg::FG_vector< T >::get_size ( ) const
inline

Get the number of elements contained in the vector.

Returns
The number of elements in the vector
template<class T>
void fg::FG_vector< T >::init ( v)
inline

Initialize the vector a single value as specified by parameter 1.

Parameters
vThe initialization parameter for the vector data. parallel
template<class T>
T fg::FG_vector< T >::max ( ) const
inline

Find the maximal value in the vector and return its value.

Returns
The maximal value in the vector.
template<class T>
std::pair<T, off_t> fg::FG_vector< T >::max_val_loc ( ) const
inline

Find the maximal value in the vector and return its value and its location.

Returns
A pair that contains the maximal value and its location in the vector.
template<class T>
template<class MergeFunc , class VecType >
void fg::FG_vector< T >::merge_in_place ( typename FG_vector< VecType >::ptr  vec,
MergeFunc  func 
)
inline

element-wise merge with another vector and store the result in this vector.

Parameters
vecThe vector that you want to merge with.
funcThe operator that you want to perform on each pair of elements.
template<class T>
T fg::FG_vector< T >::min ( ) const
inline

Find the index with the minmimal value in the vector and return its value.

Returns
The minimal value in the vector.
template<class T>
T fg::FG_vector< T >::norm1 ( ) const
inline

Compute the L1 Norm#Taxicab_norm_or_Manhattan_norm) (also Taxicab norm) of an FG_vector.
parallel

Returns
An object of type T with the L1 norm.
template<class T>
T fg::FG_vector< T >::norm2 ( ) const
inline

Compute the L2 Norm#Euclidean_norm) (also know as Euclidean distance) of a vector.
parallel

Returns
An object of type T with the value of the L2 norm.
template<class T>
void fg::FG_vector< T >::plus_eq ( FG_vector< T >::ptr  other)
inline

Equivalent to += operator. Element by element addition of one FG_vector to another.

Parameters
otherAn FG_vector smart pointer object.
template<class T>
void fg::FG_vector< T >::set ( vertex_id_t  id,
const T &  v 
)
inline

Set a value of an index in the vector.

NOTE: This function assumes a shared memory environment.

Parameters
idThe index where value is being set.
vThe value that the index will be set to.
template<class T>
void fg::FG_vector< T >::shallow_copy ( FG_vector< T >::ptr  other)
inline

Make a shallow copy of the vector.

Parameters
otherAn FG_vector smart pointer. paralel
template<class T>
template<class T2 >
void fg::FG_vector< T >::subtract_in_place ( typename FG_vector< T2 >::ptr &  vec)
inline

In place subtraction of the vector by another vector.

Parameters
vecThe vector by which you want the array to be subtracted. parallel
template<class T>
T fg::FG_vector< T >::sum ( ) const
inline

Compute the sum of all elements in the vector.
If the type is integer, the sum can overflow. parallel

Returns
The sum of all items in the vector.
template<class T>
template<class ResType >
ResType fg::FG_vector< T >::sum ( ) const
inline

Compute the sum of all elements in the vector.
This sum() allows users to specify the type of the result, so users can avoid integer overflow. parallel

Returns
The sum of all items in the vector.
template<class T>
void fg::FG_vector< T >::to_file ( std::string  fn)
inline

Write the space separated vector to file.

Parameters
fnThe file name you wish written to file.
template<class T>
void fg::FG_vector< T >::unique ( std::set< T > &  set) const
inline

Populate an STL set with the unique elements in the vector. All duplicates are ignored.

Parameters
setThe empty STL set that will be populated with unique vector members.

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