Package dev.roanh.gmark.util
Class SimpleGraph.SimpleVertex<T extends IDable,M>
java.lang.Object
dev.roanh.gmark.util.SimpleGraph.SimpleVertex<T,M>
- Type Parameters:
T
- The data type of data stored at vertices.M
- The metadata data type.
- All Implemented Interfaces:
IDable
- Enclosing class:
- SimpleGraph<T extends IDable,
M>
public static final class SimpleGraph.SimpleVertex<T extends IDable,M>
extends Object
implements IDable
Represents a single vertex in the graph.
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprivate
SimpleVertex
(T data) Constructs a new vertex with the given data. -
Method Summary
Modifier and TypeMethodDescriptionboolean
getData()
Gets the data stored at this vertex.int
Gets the degree of this vertex in the graph.getEdge
(SimpleGraph.SimpleVertex<T, M> target) Gets the edge from this vertex to the given target vertex.getEdges()
Gets a set of all edges that this vertex participates in as an end point.int
getID()
Gets the unique ID for this object.Gets the metadata stored at this vertex.Gets a list of all the neighbour vertices for this vertex, excluding itself.boolean
hasEdge
(SimpleGraph.SimpleVertex<T, M> target) Checks if this vertex has an edge to the given target vertex.int
hashCode()
void
setMetadata
(M meta) Sets the metadata stored at this vertex.
-
Field Details
-
data
The data stored at this vertex that uniquely identifies it in the graph. -
edges
The edges this vertex is an end point for. -
metadata
The metadata stored at this vertex.
-
-
Constructor Details
-
SimpleVertex
Constructs a new vertex with the given data.- Parameters:
data
- The data uniquely identifying this vertex.
-
-
Method Details
-
getMetadata
Gets the metadata stored at this vertex.- Returns:
- The metadata stored at this vertex.
-
setMetadata
Sets the metadata stored at this vertex.- Parameters:
meta
- The new metadata to store at this vertex.
-
getEdges
Gets a set of all edges that this vertex participates in as an end point.- Returns:
- All the edges that this vertex is and end point of.
-
getData
Gets the data stored at this vertex. This piece of data uniquely identifies this vertex in the graph.- Returns:
- The data associated with this vertex.
-
getDegree
public int getDegree()Gets the degree of this vertex in the graph. This is equal to the number of edges that this vertex is and end point of.- Returns:
- The degree of this vertex in the graph.
-
hasEdge
Checks if this vertex has an edge to the given target vertex.- Parameters:
target
- The vertex to check for an edge to.- Returns:
- True if this vertex has and edge to the given target vertex.
-
getEdge
Gets the edge from this vertex to the given target vertex.- Parameters:
target
- The target vertex.- Returns:
- The edge from this vertex to the given target vertex
or
null
if no such edge exists.
-
getNeighbours
Gets a list of all the neighbour vertices for this vertex, excluding itself.- Returns:
- All neighbours of this vertex.
-
getID
public int getID()Gets the unique ID for this object. This ID uniquely identifies all objects of this type.Note that while this ID is unique for a given graph node, the uniqueness of a node in the graph is still determined by the data objected used to create the node. Hence two nodes with different IDs but the same data are in fact equal. Though this situation could only arise when comparing the IDs of nodes from different graph.
-
equals
-
hashCode
public int hashCode()
-