22 #include "attributes.h"    29 using NodePtr = std::shared_ptr<BaseNode>;
    39     friend class TestNode;
    40     friend class TestEdge;
    50     virtual NodePtr 
clone() 
const = 0;
    65     virtual int degree() 
const = 0;
    80     virtual void addInEdge(
const Edge& inEdge) = 0;
    81     virtual void addOutEdge(
const Edge& outEdge) = 0;
    82     virtual void removeInEdge(
const int edgeId) = 0;
    83     virtual void removeOutEdge(
const int edgeId) = 0;
    84     virtual void clearInEdges() = 0;
    85     virtual void clearOutEdges() = 0;
   100     friend class TestNode;
   101     friend class TestEdge;
   118     inline int id() 
const;
   122     inline float x() 
const;
   126     inline float y() 
const;
   131     inline void setX(
float x);
   135     inline void setY(
float y);
   175     ~
UNode() 
override = 
default;
   177     inline NodePtr 
clone() 
const override;
   180     inline int degree() 
const override;
   181     inline int inDegree() 
const override;
   185     inline void addInEdge(
const Edge& inEdge) 
override;
   186     inline void addOutEdge(
const Edge& outEdge) 
override;
   187     inline void removeInEdge(
const int edgeId) 
override;
   188     inline void removeOutEdge(
const int edgeId) 
override;
   189     inline void clearInEdges() 
override;
   190     inline void clearOutEdges() 
override;
   202     ~
DNode() 
override = 
default;
   204     inline NodePtr 
clone() 
const override;
   207     inline int degree() 
const override;
   208     inline int inDegree() 
const override;
   214     inline void addInEdge(
const Edge& inEdge) 
override;
   215     inline void addOutEdge(
const Edge& outEdge) 
override;
   216     inline void removeInEdge(
const int edgeId) 
override;
   217     inline void removeOutEdge(
const int edgeId) 
override;
   218     inline void clearInEdges() 
override;
   219     inline void clearOutEdges() 
override;
   230 { 
return m_attrs.
value(
id); }
   233 { 
return m_attrs.
value(name, defaultValue); }
   264 { 
return m_outEdges; }
   267 { 
return m_outEdges; }
   270 { 
return static_cast<int>(m_outEdges.size()); }
   278 inline void UNode::addInEdge(
const Edge& inEdge)
   279 { addOutEdge(inEdge); }
   281 inline void UNode::addOutEdge(
const Edge& outEdge)
   282 { m_outEdges.insert({outEdge.id(), outEdge}); }
   284 inline void UNode::removeInEdge(
const int edgeId)
   285 { removeOutEdge(edgeId); }
   287 inline void UNode::removeOutEdge(
const int edgeId)
   288 { m_outEdges.erase(edgeId); }
   290 inline void UNode::clearInEdges()
   293 inline void UNode::clearOutEdges()
   294 { m_outEdges.clear(); }
   304 { 
return m_inEdges; }
   307 { 
return m_outEdges; }
   313 { 
return static_cast<int>(m_inEdges.size()); }
   316 { 
return static_cast<int>(m_outEdges.size()); }
   318 inline void DNode::addInEdge(
const Edge& inEdge)
   319 { m_inEdges.insert({inEdge.
id(), inEdge}); }
   321 inline void DNode::addOutEdge(
const Edge& outEdge)
   322 { m_outEdges.insert({outEdge.id(), outEdge}); }
   324 inline void DNode::removeInEdge(
const int edgeId)
   325 { m_inEdges.erase(edgeId); }
   327 inline void DNode::removeOutEdge(
const int edgeId)
   328 { m_outEdges.erase(edgeId); }
   330 inline void DNode::clearInEdges()
   331 { m_inEdges.clear(); }
   333 inline void DNode::clearOutEdges()
   334 { m_outEdges.clear(); }
 virtual NodePtr clone() const =0
Creates a new std::shared_ptr<BaseNode> with the same data of the current Node. 
A class for variant data types (tagged union). 
Definition: value.h:56
virtual int outDegree() const =0
Gets the node's out-degree, i.e., the number of edges leaving the node. 
A node belongs to either a directed or undirected graph. 
Definition: node_p.h:96
It wraps a std::shared_ptr<BaseNode>. 
Definition: node.h:35
A collection of utility functions for creating and saving nodes. 
Definition: nodes_p.h:32
const Attributes & attrs() const
Gets all the node's Attributes. 
Definition: node_p.h:226
const Value & attr(int id) const
Gets the value of the attribute at id. 
Definition: node_p.h:229
void setCoords(float x, float y)
Sets the node's coordinates. 
Definition: node_p.h:253
BaseNode implementation for directed nodes. 
Definition: node_p.h:197
A common interface for the node's classes. 
Definition: node_p.h:35
BaseNode implementation for undirected nodes. 
Definition: node_p.h:170
NodePtr clone() const override
Creates a new std::shared_ptr<BaseNode> with the same data of the current Node. 
Definition: node_p.h:300
float y() const
Gets the node's y coordinate. 
Definition: node_p.h:247
const Edges & outEdges() const override
Gets the edges leaving the node. 
Definition: node_p.h:306
void setValue(int id, const Value &value)
Sets the value at id. 
Definition: attributes.h:221
const Value & value(int id) const
Gets the value of the attribute at id. 
Definition: attributes.h:213
int outDegree() const override
Gets the node's out-degree, i.e., the number of edges leaving the node. 
Definition: node_p.h:275
Node randNeighbour(PRG *prg) const
Gets a random neighbour. 
virtual int degree() const =0
Gets the node's degree. 
A Node container. 
Definition: nodes.h:32
int inDegree() const override
Gets the node's in-degree, i.e., the number of edges entering the node. 
Definition: node_p.h:272
int inDegree() const override
Gets the node's in-degree, i.e., the number of edges entering the node. 
Definition: node_p.h:312
virtual const Edges & outEdges() const =0
Gets the edges leaving the node. 
int outDegree() const override
Gets the node's out-degree, i.e., the number of edges leaving the node. 
Definition: node_p.h:315
An Edge connects a Node to itself or to another Node. 
Definition: edge.h:37
const Edges & inEdges() const override
Gets the edges entering the node. 
Definition: node_p.h:303
This is a private key accessible only to friend classes. 
Definition: node_p.h:153
int id() const
Gets the node's id. 
Definition: node_p.h:238
void setY(float y)
Sets the node's y coordinate. 
Definition: node_p.h:250
virtual ~NodeInterface()=default
Destructor. 
int id() const
Gets the edge's id. 
int degree() const override
Gets the node's degree. 
Definition: node_p.h:269
void setX(float x)
Sets the node's x coordinate. 
Definition: node_p.h:244
const Edges & inEdges() const override
Gets the edges entering the node. 
Definition: node_p.h:263
float x() const
Gets the node's x coordinate. 
Definition: node_p.h:241
const Edges & outEdges() const override
Gets the edges leaving the node. 
Definition: node_p.h:266
Pseudo-random number generator. 
Definition: prg.h:29
virtual int inDegree() const =0
Gets the node's in-degree, i.e., the number of edges entering the node. 
void setAttr(int id, const Value &value)
Sets the value at id. 
Definition: node_p.h:235
NodePtr clone() const override
Creates a new std::shared_ptr<BaseNode> with the same data of the current Node. 
Definition: node_p.h:260
int degree() const override
Gets the node's degree. 
Definition: node_p.h:309
Definition: abstractgraph.h:29
A container of labeled values. 
Definition: attributes.h:39
Abstract base class for graph plugins. 
Definition: abstractgraph.h:54
virtual const Edges & inEdges() const =0
Gets the edges entering the node. 
An Edge container. 
Definition: edges.h:32