pandore::Graph2d Class Reference

#include <graph.h>

List of all members.


Detailed Description

A 2D graph.

A graph is a set of nodes connected to some other nodes. The two types of graph are supported: directed and undirected; the type must be specified with the constructor. A node is characterized by a value which determines if the node is active in the representation of the graph or not. A node can reference any of the Pandore object. It indexes an item in a separate array of items by a long value. It is equivalent to a pointer to an objet in an array except that not type is needed.
see The Graphs.


Public Types

typedef Double ValueType

Public Member Functions

Typobj Type () const
std::string Name () const
bool isDirected () const
Long Width () const
Long Height () const
Long Size () const
Dimension2d ImageSize () const
PobjectProps Props () const
 Graph2d (bool directed=false)
 Graph2d (Long s, bool directed=false)
 Graph2d (Long s, Long h, Long w, bool directed=false)
 Graph2d (Long s, const Dimension2d &d, bool directed=false)
 Graph2d (const PobjectProps &p)
 ~Graph2d ()
void New (Long s, Long h, Long w)
void New (const PobjectProps &p)
void Delete ()
Graph2doperator= (const Graph2d &src)
Errc Init (const Reg2d &rgs, const Reg2d &seeds)
Errc Init (const Reg2d &rgs)
Pobject * Clone () const
GNode< Point2d > * operator[] (Long pos)
const GNode< Point2d > * operator[] (Long pos) const
Errc Add (Long node, Long item, const Point2d &pt)
Errc Add (Long node, Long item)
Errc Add (Long node, Long item, Long y, Long x)
Errc Del (Long s)
Errc Link (Long s1, Long s2, Double weight=1.0F, bool add=false)
Errc Link (Long s1, Long s2, Long i, Double weight=1.0F, bool add=false)
Errc Unlink (Long s1, Long s2)
Errc Unlink (Long s1, Long s2, Long i)
Errc Merge (Long s1, Long s2)
Errc Split (Long s1, Long s2)
Errc LoadAttributes (FILE *file)
Errc SaveAttributes (FILE *file) const
Errc LoadData (FILE *file)
Errc SaveData (FILE *file) const
Pobject * Mask (const Pobject *mask)
Pobject * UnMask (const Pobject *mask, const Pobject *reference)
 Graph2d (const Graph2d &grs)


Member Typedef Documentation

typedef Double pandore::Graph2d::ValueType
 

The type of the data (for instance Double).


Constructor & Destructor Documentation

pandore::Graph2d::Graph2d bool  directed = false  )  [inline]
 

Creates a new graph with no data.

Parameters:
directed true for creating a directed graph.

pandore::Graph2d::Graph2d Long  s,
bool  directed = false
[inline]
 

Creates a new graph with the specified number of nodes and the specified dimension of the related image. Allocates therefrom the related data.

Warning:
the node value is not initialized with 0.
Parameters:
s the number of nodes.
directed true for creating a directed graph.

pandore::Graph2d::Graph2d Long  s,
Long  h,
Long  w,
bool  directed = false
[inline]
 

Creates a new graph with the specified number of nodes and the specified dimension of the related image. Allocates therefrom the related data.

Warning:
the node value is not initialized with 0.
Parameters:
s the number of nodes.
h the height of the related image.
w the width of the related image.
directed true for creating a directed graph.

pandore::Graph2d::Graph2d Long  s,
const Dimension2d d,
bool  directed = false
[inline]
 

Creates a new graph with the specified number of nodes and the specified dimension of the related image. Allocates therefrom the related data.

Warning:
the node value is not initialized with 0.
Parameters:
s the number of nodes.
d the dimension of the image.
directed true for creating a directed graph.

pandore::Graph2d::Graph2d const PobjectProps &  p  )  [inline]
 

Creates a new graph with the specified properties. Allocates therefrom the related data.

Warning:
the node value is not initialized with 0.
Parameters:
p the properties.

pandore::Graph2d::~Graph2d  )  [inline]
 

Deletes the graph.

pandore::Graph2d::Graph2d const Graph2d grs  )  [inline]
 

Creates a new graph by copy. Allocates the related data and sets the values with the grs values. If needed casts the values by using the C casting.

Parameters:
grs the specified graph.


Member Function Documentation

Errc pandore::Graph2d::Add Long  node,
Long  item,
Long  y,
Long  x
[inline]
 

Adds the specified node that references the specified item. The coordinates of the node is set to the specificied cordinates.

Parameters:
node the index of the node.
item the index of the related item.
y the row coordinate.
x the column coordinate.
Returns:
SUCCESS or FAILURE.

Errc pandore::Graph2d::Add Long  node,
Long  item
[inline]
 

Adds the specified node that references the specified item. The coordinate of the node is set to (0, 0).

Parameters:
node the index of the node.
item the index of the related item.
Returns:
SUCCESS or FAILURE.

Errc pandore::Graph2d::Add Long  node,
Long  item,
const Point2d pt
 

Adds the specified node that references the specified item.

Parameters:
node the index of the node.
item the index of the related item.
pt the coordinate of the node.
Returns:
SUCCESS or FAILURE.

Pobject* pandore::Graph2d::Clone  )  const
 

Creates and returns a distinct copy of this object.

Returns:
a new graph.

Errc pandore::Graph2d::Del Long  s  ) 
 

Deletes the specified node from the graph. Unlinks it from connected nodes.

Parameters:
s the node to be deleted.
Returns:
SUCCESS or FAILURE.

void pandore::Graph2d::Delete  ) 
 

Deletes the graph data.

Long pandore::Graph2d::Height  )  const [inline]
 

Returns the number of rows of the related image.

Returns:
the height.

Dimension2d pandore::Graph2d::ImageSize  )  const [inline]
 

Returns the dimension of the related image.

Returns:
the dimension.

Errc pandore::Graph2d::Init const Reg2d rgs  ) 
 

Initializes the graph with the given region map. Each region is represented as a node, and connected regions are represented as a link between the related nodes.

Parameters:
rgs the region map.
Returns:
SUCCESS or FAILURE.

Errc pandore::Graph2d::Init const Reg2d rgs,
const Reg2d seeds
 

Initializes the graph with the given region map. Each region is represented as a node, and connected regions are represented as a link between the related nodes. The seed map is used to set the coordinates of each node.

Parameters:
rgs the region map.
seeds the region map that holds the seeds.
Returns:
SUCCESS or FAILURE.

bool pandore::Graph2d::isDirected  )  const [inline]
 

Returns:
true if the graph is directed.

Errc pandore::Graph2d::Link Long  s1,
Long  s2,
Long  i,
Double  weight = 1.0F,
bool  add = false
 

Links the two specified nodes s1 and s2 by adding two identified edges one from s1 to s2 and one from s2 to s1 and sets the specified value for the link weight, either by adding it to the current weight if add = true or by setting it.

Parameters:
s1 the first node.
s2 the second node.
i the identifier of the edge
weight the weight for the link.
add if true adds the weight to the current weight, otherwise sets the new value.
Returns:
SUCCESS or FAILURE.

Errc pandore::Graph2d::Link Long  s1,
Long  s2,
Double  weight = 1.0F,
bool  add = false
 

Links the two specified nodes s1 and s2 by adding two edges one from s1 to s2 and one from s2 to s1 and sets the specified value for each edge weight, either by adding it to the current weight if add = true or by setting it.

Parameters:
s1 the first node.
s2 the second node.
weight the weight for the link.
add if true adds the weight to the current weight, otherwise sets the new value.
Returns:
SUCCESS or FAILURE.

Errc pandore::Graph2d::LoadAttributes FILE *  file  ) 
 

Loads attribute values from the specified file. Allocates therefrom the related data.

Parameters:
file the file where to read attributes values.
Returns:
SUCCESS or FAILURE in case of IO errors..

Errc pandore::Graph2d::LoadData FILE *  file  ) 
 

Loads data from the specified file.

Parameters:
file the file where to read data.
Returns:
SUCCESS or FAILURE in case of IO errors..

Pobject* pandore::Graph2d::Mask const Pobject *  mask  ) 
 

Creates a new Graph of the same type but where the data are masked by the given mask. It means that value are set to 0 when the related label in the mask is 0.

Parameters:
mask the region map that is used as a mask.
Returns:
the new Graph.

Errc pandore::Graph2d::Merge Long  s1,
Long  s2
 

Merges the two specified nodes.This means keeps only the first node and merges all neighbours of the second node. The result weight is the sum of the weight, but the seed is still the seed of the first node.

Parameters:
s1 the first node.
s2 the second node.
Returns:
SUCCESS or FAILURE.

std::string pandore::Graph2d::Name  )  const [inline]
 

Returns the name of the graph type.

Returns:
the string with the name.

void pandore::Graph2d::New const PobjectProps &  p  )  [inline]
 

Allocates the image data from the specified vector of properties.

Warning:
the node value is not initialized with 0.
Parameters:
p the vector of properties.

void pandore::Graph2d::New Long  s,
Long  h,
Long  w
 

Allocates the data from the specified number of nodes, and the specified dimension of the related image.

Warning:
the node value is not initialized with 0.
Parameters:
s the number of nodes.
h the height of the related image.
w the width of the related image.

Graph2d& pandore::Graph2d::operator= const Graph2d src  ) 
 

Sets the values of the graph from the specified graph values. If needed, deletes the previous data and reallocs new data.

Parameters:
src the reference graph.

const GNode<Point2d>* pandore::Graph2d::operator[] Long  pos  )  const [inline]
 

Returns the node at the specified coordinates.

Parameters:
pos the coordinates.
Returns:
the node at the specified coordinates.

GNode<Point2d>* pandore::Graph2d::operator[] Long  pos  )  [inline]
 

Returns the node at the specified coordinates.

Parameters:
pos the coordinates.
Returns:
the node at the specified coordinates.

PobjectProps pandore::Graph2d::Props  )  const [inline]
 

Returns the related vector of properties.

Returns:
the vector of properties.

Errc pandore::Graph2d::SaveAttributes FILE *  file  )  const
 

Saves the current attribute values.

Parameters:
file the file.
Returns:
SUCCESS or FAILURE in case of IO errors..

Errc pandore::Graph2d::SaveData FILE *  file  )  const
 

Saves data in the specified file.

Parameters:
file the file where to save data.
Returns:
SUCCESS or FAILURE in case of IO errors..

Long pandore::Graph2d::Size  )  const [inline]
 

Returns the number of nodes.

Returns:
the size.

Errc pandore::Graph2d::Split Long  s1,
Long  s2
 

Splits the first node to create the second node. The list of neighbours, the weight and the seeds are duplicated.

Parameters:
s1 the first node.
s2 the second node.
Returns:
SUCCESS or FAILURE.

Typobj pandore::Graph2d::Type  )  const [inline]
 

Returns the graph identifier.

Returns:
the identifier.

Errc pandore::Graph2d::Unlink Long  s1,
Long  s2,
Long  i
 

Removes the link i between the two specified nodes s1 and s2. Other link between the two nodes s1 and s2 are not removed, therefore s1 can remain a neighbor of s2.

Parameters:
s1 the first node.
s2 the second node.
i the identifier of the edge.
Returns:
SUCCESS or FAILURE.

Errc pandore::Graph2d::Unlink Long  s1,
Long  s2
 

Unlinks the two specified nodes. s1 will no longer be a neighbour of s2 (and vice versa).

Parameters:
s1 the first node.
s2 the second node.
Returns:
SUCCESS or FAILURE.

Pobject* pandore::Graph2d::UnMask const Pobject *  mask,
const Pobject *  reference
 

Creates a new graph where the data are ummasked by the given mask and the given reference image. It means that values are set to the value of the reference object when the related label in the mask is 0.

Parameters:
mask the region map that is used as a mask.
reference the object that is used as a reference.
Returns:
a new Graph.

Long pandore::Graph2d::Width  )  const [inline]
 

Returns the number of columns of the related image.

Returns:
the width.


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

The Pantheon project
Image Team GREYC Laboratory
UMR CNRS 6072 - ENSICAEN - University of Caen, France
This page was last modified on 19 June 2015