dai::GraphAL::Neighbor Struct Reference

Describes the neighbor relationship of two nodes in a GraphAL. More...

#include <dai/graph.h>

List of all members.

Public Member Functions

 Neighbor ()
 Default constructor.
 Neighbor (size_t iter, size_t node, size_t dual)
 Constructor that sets the Neighbor members according to the parameters.
 operator size_t () const
 Cast to size_t returns node member.

Public Attributes

size_t iter
 Corresponds to the index of this Neighbor entry in the vector of neighbors.
size_t node
 Contains the number of the neighboring node.
size_t dual
 Contains the "dual" iter.

Detailed Description

Describes the neighbor relationship of two nodes in a GraphAL.

Sometimes we want to do an action, such as sending a message, for all edges in a graph. However, most graphs will be sparse, so we need some way of storing a set of the neighbors of a node, which is both fast and memory-efficient. We also need to be able to go between viewing node a as a neighbor of node b, and node b as a neighbor of node a. The Neighbor struct solves both of these problems. Each node has a list of neighbors, stored as a std::vector<Neighbor>, and extra information is included in the Neighbor struct which allows us to access a node as a neighbor of its neighbor (the dual member).

By convention, variable identifiers naming indices into a vector of neighbors are prefixed with an underscore ("_"). The neighbor list which they point into is then understood from context. For example:

  Real MR::T( size_t i, size_t _j );

Here, i is the "absolute" index of node i, but _j is understood as a "relative" index, giving node j 's entry in nb(i). The corresponding Neighbor structure can be accessed as nb(i,_j) or nb(i)[_j]. The absolute index of _j, which would be called j, can be recovered from the node member: nb(i,_j).node. The iter member gives the relative index _j, and the dual member gives the "dual" relative index, i.e., the index of i in j 's neighbor list.

  Neighbor n = nb(i,_j);
  n.node == j &&
  n.iter == _j &&
  nb(n.node,n.dual).node == i

There is no easy way to transform a pair of absolute node indices i and j into a Neighbor structure relative to one of the nodes. Such a feature has never yet been found to be necessary. Iteration over edges can always be accomplished using the Neighbor lists, and by writing functions that accept relative indices:

  for( size_t i = 0; i < nrNodes(); ++i )
      foreach( const Neighbor &j, nb(i) )
          T( i, j.iter );

Constructor & Destructor Documentation

dai::GraphAL::Neighbor::Neighbor (  )  [inline]

Default constructor.

dai::GraphAL::Neighbor::Neighbor ( size_t  iter,
size_t  node,
size_t  dual 
) [inline]

Constructor that sets the Neighbor members according to the parameters.


Member Function Documentation

dai::GraphAL::Neighbor::operator size_t (  )  const [inline]

Cast to size_t returns node member.


Member Data Documentation

Corresponds to the index of this Neighbor entry in the vector of neighbors.

Contains the number of the neighboring node.

Contains the "dual" iter.


The documentation for this struct was generated from the following file:
Generated on Sun May 9 16:51:36 2010 for libDAI by  doxygen 1.6.3