reoptimization_algorithms.utils.graph.vertex.Vertex¶
-
class
Vertex(key: str, weight: float = None, neighbours: Dict[str, Edge] = None)¶ Bases:
objectVertex class having key, weight and adjacency dictionary of neighbours
Default weight as
Vertex.DEFAULT_VERTEX_WEIGHT- Parameters
key (str) – Key
weight (int) – Weight of the vertex
neighbours (Dict[str, Edge]) – Neighbours of the vertex
Attributes
Default Vertex weight
Vertex key
Neighbouring vertices
Vertex weight
-
property
DEFAULT_VERTEX_WEIGHT¶ Default Vertex weight
- Returns
1
-
add_neighbour(neighbour: str, weight: float = None) → reoptimization_algorithms.utils.graph.vertex.Vertex¶ Adds a neighbour, default edge weight as
Edge.DEFAULT_EDGE_WEIGHT- Parameters
neighbour (str) – Neighbour vertex key
weight (float, optional (default = None)) – Edge weight
- Returns
Self
-
degree() → int¶ Gets degree of the vertex
- Returns
Degree of the vertex
-
delete_neighbour(neighbour: str) → reoptimization_algorithms.utils.graph.edge.Edge¶ Deletes a neighbour
- Parameters
neighbour (str) – Neighbour vertex key
- Returns
Deleted Edge
-
get_neighbour(neighbour: str) → reoptimization_algorithms.utils.graph.edge.Edge¶ Gets a neighbour
- Parameters
neighbour (str) – Neighbour vertex key
- Returns
Edge representing the neighbour
-
is_neighbour_exists(neighbour: str) → bool¶ Checks if neighbour exists
- Parameters
neighbour (str) – Neighbour vertex key
- Returns
Boolean
-
property
key¶ Vertex key
- Returns
Vertex key
-
property
neighbours¶ Neighbouring vertices
- Returns
Dictionary of neighbouring vertices as keys and values as edges
-
update_neighbour(neighbour: str, weight: float = None) → reoptimization_algorithms.utils.graph.vertex.Vertex¶ Updates a neighbour, default edge weight as
Edge.DEFAULT_EDGE_WEIGHT- Parameters
neighbour (str) – Neighbour vertex key
weight (float, optional (default = None)) – Edge weight to update
- Returns
Self
-
update_weight(weight: float) → reoptimization_algorithms.utils.graph.vertex.Vertex¶ Updates vertex weight
- Parameters
weight (float, optional (default = None)) – Vertex weight
- Returns
Self
-
property
weight¶ Vertex weight
- Returns
Vertex weight