Evoplex  0.2.1
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
evoplex::BaseNode Class Reference

A node belongs to either a directed or undirected graph. More...

#include <node_p.h>

Inheritance diagram for evoplex::BaseNode:
evoplex::NodeInterface evoplex::DNode evoplex::UNode

Classes

struct  constructor_key
 This is a private key accessible only to friend classes. More...
 

Public Member Functions

const Attributesattrs () const
 Gets all the node's Attributes.
 
const Valueattr (int id) const
 Gets the value of the attribute at id. More...
 
Value attr (const QString &name, Value defaultValue=Value()) const
 Gets the value corresponding to name. More...
 
void setAttr (int id, const Value &value)
 Sets the value at id. More...
 
int id () const
 Gets the node's id.
 
float x () const
 Gets the node's x coordinate.
 
float y () const
 Gets the node's y coordinate.
 
void setX (float x)
 Sets the node's x coordinate.
 
void setY (float y)
 Sets the node's y coordinate.
 
void setCoords (float x, float y)
 Sets the node's coordinates.
 
Node randNeighbour (PRG *prg) const
 Gets a random neighbour. More...
 
- Public Member Functions inherited from evoplex::NodeInterface
virtual ~NodeInterface ()=default
 Destructor.
 
virtual NodePtr clone () const =0
 Creates a new std::shared_ptr<BaseNode> with the same data of the current Node.
 
virtual const EdgesinEdges () const =0
 Gets the edges entering the node.
 
virtual const EdgesoutEdges () const =0
 Gets the edges leaving the node.
 
virtual int degree () const =0
 Gets the node's degree.
 
virtual int inDegree () const =0
 Gets the node's in-degree, i.e., the number of edges entering the node.
 
virtual int outDegree () const =0
 Gets the node's out-degree, i.e., the number of edges leaving the node.
 

Protected Member Functions

 BaseNode (const constructor_key &, int id, const Attributes &attrs, float x, float y)
 
 BaseNode (const constructor_key &k, int id, const Attributes &attr)
 

Protected Attributes

Edges m_outEdges
 

Friends

class AbstractGraph
 
class NodesPrivate
 
class TestNode
 
class TestEdge
 

Detailed Description

A node belongs to either a directed or undirected graph.

Directed graphs are composed of DNode objects, while an undirected graph is composed of UNode objects.

Attention
A node can only be created by an AbstractGraph derived object or from a Nodes container.

Member Function Documentation

◆ attr() [1/2]

const Value & evoplex::BaseNode::attr ( int  id) const
inline

Gets the value of the attribute at id.

Parameters
idThe attribute's id.
Exceptions
std::out_of_rangeif the id is not present.

◆ attr() [2/2]

Value evoplex::BaseNode::attr ( const QString &  name,
Value  defaultValue = Value() 
) const
inline

Gets the value corresponding to name.

Parameters
nameThe attribute's name.
defaultValueA Value to be returned if name is not present.

◆ randNeighbour()

Node evoplex::BaseNode::randNeighbour ( PRG prg) const

Gets a random neighbour.

Returns an invalid/empty Node if the node has no neighbours.

◆ setAttr()

void evoplex::BaseNode::setAttr ( int  id,
const Value value 
)
inline

Sets the value at id.

Parameters
idThe attribute's id.
valueThe new attribute's value.
Exceptions
std::out_of_rangeif the id is not present.

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