class Vertex
Each object of this class represents a single vertex (or node) in a graph.
Previous versions of this class in the library included member variables such as visited
and previous
to help facilitate the implementation of various graph algorithms.
These were removed by the library's maintainer because we want our students to learn to manage such data themselves using collections.
See also:
BasicGraph
,
Edge
Available since: 2014/02/01 version of C++ library
Constructor | |
Creates a vertex with the given name. | |
Methods | |
Returns the color of this vertex. | |
Sets the vertex's color back to its initial value. | |
Sets this vertex's color to the given color. | |
Returns a string representation of this vertex. | |
Fields | |
Deprecated. A set of pointers to all outbound arcs (edges) from this vertex. We suggest you refer to this field as edges rather than arcs , though either will work. | |
Deprecated. The cost to reach this vertex; initially 0. This will be removed from the library; students should not use it. | |
A set of pointers to all outbound edges from this vertex. (An alias for arcs .) | |
The name of this vertex in the graph. | |
Deprecated. A pointer to a previous vertex; initially nullptr . This will be removed from the library; students should not use it. | |
Deprecated. Whether or not this vertex has currently been visited; initially false . This will be removed from the library; students should not use it. | |
Deprecated. The cost to reach this vertex (an alias for cost ). This will be removed from the library; students should not use it. |
Vertex(string name);
Vertex
objects but should instead add vertexes by name to a BasicGraph
which will then internally create the Vertex
structure for you.
Usage:
Vertex* vp = new Vertex(name);
int getColor();
setColor
.
If setColor
has not been called previously, the return value is unspecified.
Usage:
int color = vp->getColor();
void resetData();
Usage:
vp->resetData();
void setColor(int color);
getColor
will return this color.
Usage:
vp->setColor(color);
string toString() const;
"Vertex{name=r13c42, neighbors={r12c41, r12c43}}"
.
Usage:
string str = vp->toString();