All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Protected Attributes | List of all members
NetworKit::LinkPredictor Class Referenceabstract

Abstract base class for link predictors. More...

#include <LinkPredictor.h>

Public Types

typedef std::pair< std::pair
< node, node >, double > 
prediction
 Type of predictions. More...
 

Public Member Functions

 LinkPredictor ()
 
 LinkPredictor (const Graph &G)
 
virtual ~LinkPredictor ()=default
 Default destructor. More...
 
virtual void setGraph (const Graph &newGraph)
 Sets the graph to work on. More...
 
virtual double run (node u, node v)
 Returns a score indicating the likelihood of a future link between the given nodes. More...
 
virtual std::vector< predictionrunOn (std::vector< std::pair< node, node >> nodePairs)
 Executes the run-method on aĺl given nodePairs and returns a vector of predictions. More...
 
virtual std::vector< predictionrunAll ()
 Runs the link predictor on all currently unconnected node-pairs. More...
 

Protected Attributes

const GraphG
 Graph to operate on. More...
 
bool validCache
 Indicates whether a possibly used cache is valid. More...
 

Detailed Description

Abstract base class for link predictors.

Member Typedef Documentation

typedef std::pair<std::pair<node, node>, double> NetworKit::LinkPredictor::prediction

Type of predictions.

Constructor & Destructor Documentation

NetworKit::LinkPredictor::LinkPredictor ( )
NetworKit::LinkPredictor::LinkPredictor ( const Graph G)
explicit
Parameters
GThe graph to work on
virtual NetworKit::LinkPredictor::~LinkPredictor ( )
virtualdefault

Default destructor.

Member Function Documentation

double NetworKit::LinkPredictor::run ( node  u,
node  v 
)
virtual

Returns a score indicating the likelihood of a future link between the given nodes.

Prior to calling this method a graph should be provided through the constructor or by calling setGraph. Note that only undirected graphs are accepted. There is also no lower or upper bound for scores and the actual range of values depends on the specific link predictor implementation. In case u == v a 0 is returned. If suitable this method might make use of parallelization to enhance performance.

Parameters
uFirst node in graph
vSecond node in graph
Returns
a prediction-score indicating the likelihood of a future link between the given nodes
std::vector< LinkPredictor::prediction > NetworKit::LinkPredictor::runAll ( )
virtual

Runs the link predictor on all currently unconnected node-pairs.

Possible self-loops are also excluded. The method makes use of parallelisation.

Returns
a vector of pairs containing all currently unconnected node-pairs as the first elements and the corresponding scores as the second elements. The vector is sorted ascendingly by node-pair
std::vector< LinkPredictor::prediction > NetworKit::LinkPredictor::runOn ( std::vector< std::pair< node, node >>  nodePairs)
virtual

Executes the run-method on aĺl given nodePairs and returns a vector of predictions.

The result is a vector of pairs where the first element is the node-pair and it's second element the corresponding score generated by the run-method. The method makes use of parallelisation.

Parameters
nodePairsNode-pairs to run the predictor on
Returns
a vector of pairs containing the given node-pair as the first element and it's corresponding score as the second element. The vector is sorted ascendingly by node-pair

Reimplemented in NetworKit::KatzIndex.

void NetworKit::LinkPredictor::setGraph ( const Graph newGraph)
virtual

Sets the graph to work on.

Parameters
newGraphThe graph to work on

Reimplemented in NetworKit::SameCommunityIndex.

Member Data Documentation

const Graph* NetworKit::LinkPredictor::G
protected

Graph to operate on.

bool NetworKit::LinkPredictor::validCache
protected

Indicates whether a possibly used cache is valid.


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