class Link
This class implements a generic link in a graph: it can be connected to two nodes, it can remeber if something has changed, and it has functions to write and read itself to and from streams (which do nothing, since this link has no data other than two pointers, and those are taken care of by the Graph class)
Attributes:
bool changed
- true if something has changed. Mostly useful to derivate classes (Weight, for example)
Methods:
Link()
- default constructor: the new linked has no nodes connected, and
changed
is true.
virtual ~Link()
- destructor: just a placeholder for derivate classes.
Node *to() const
- returns the node at the fore end of this link
Node *from() const
- return the node at the aft end of this link
Node* link_to(Node *n)
- change the node at the fore end, returns the previous one. To unlink,
link_to(0)
. Sets changed
to true
Node* link_from(Node *n)
- change the node at the aft end, returns the previous one. To unlink,
link_from(0)
. Sets changed
to true
virtual ostream &writeTo(ostream &o)
- writes nothing to the given stream. Redefined in derivate classes.
istream &readFrom(istream &i)
- reads nothing from the given stream. Redefined in derivate classes.
static istream& dummyRead(istream &i)
- reads nothing from the given stream. Redefined in derivate classes.