# Source code for pacman.model.graphs.abstract_vertex

# Copyright (c) 2017-2019 The University of Manchester
#
# This program is free software: you can redistribute it and/or modify
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from pacman.exceptions import PacmanConfigurationException
from pacman.model.graphs.common import ConstrainedObject

[docs]class AbstractVertex(ConstrainedObject):
""" A vertex in a graph.
"""

# Because of diamond inheritance slots must be empty
__slots__ = [
# Indicates if the Vertex has been added to a graph
# Label for the vertex. Changable until added to graph
"_label"]

def __init__(self, label=None, constraints=None):
"""
:param str label: The optional name of the vertex
:param iterable(AbstractConstraint) constraints:
The optional initial constraints of the vertex
:raise PacmanInvalidParameterException:
If one of the constraints is not valid
"""

super().__init__(constraints)
self._label = label

@property
def label(self):
""" The current label to the vertex.

This label could change when the vertex is added to the graph.

:rtype: str
"""
return self._label

[docs]    def set_label(self, label):
""" Changes the label for a vertex *not yet added* to a graph.

:param str label: new value for the label
:raises PacmanConfigurationException:
If there is an attempt to change the label once the vertex has
"""