Package com.graphs.struct
Class Graph.Vertex<E extends T>
java.lang.Object
com.graphs.struct.Graph.Vertex<E>
- Type Parameters:
 E- the type of element stored in this vertex.
This inner class implements vertices of this graph.
- Since:
 - 1.0-beta
 - See Also:
 
- 
Field Summary
Fields - 
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateVertex(int index) This constructor creates vertex based on a givenintparameter. - 
Method Summary
Modifier and TypeMethodDescriptionprivate booleancanConnectWith(Graph<T>.Vertex<E> vertex) This method checks if this vertex can be connected to the vertex given as a parameter.private booleancanDisconnectWith(Graph<T>.Vertex<E> vertex) This method check if this vertex can be disconnected with the vertex given as a parameter.private booleanconnectWith(Graph<T>.Vertex<E> vertex) This method connects this vertex with other givenVertex.private booleandisconnectWith(Graph<T>.Vertex<E> vertex) This method disconnects this vertex with other givenVertex.private intThis method returns the degree of this vertex.private booleanisConnectedWith(Graph<T>.Vertex<E> vertex) This method checks whether this vertex is connected with other givenVertexor is not.@NotNull StringtoString() 
- 
Field Details
- 
index
private final int indexThis field represents the index of a vertex. Once initialized, it cannot be changed.Minimal value: 0 Maximal value:
Integer.MAX_VALUE- Since:
 - 1.0-beta
 
 - 
neighbours
This field represents (open) neighbourhood of this vertex.- Since:
 - 1.0-beta
 - See Also:
 
 - 
element
This field represents data stored in this vertex.- Since:
 - 2.0
 - See Also:
 
 
 - 
 - 
Constructor Details
- 
Vertex
This constructor creates vertex based on a givenintparameter.- Parameters:
 index- numerical index of a vertex.- Throws:
 NegativeVertexIndexException- if given parameter typeint < 0.- Since:
 - 1.0-beta
 - See Also:
 
 
 - 
 - 
Method Details
- 
getDegree
private int getDegree()This method returns the degree of this vertex.- Returns:
 - number of vertices in an open neighbourhood of this vertex.
 - Since:
 - 1.0-beta
 - See Also:
 
 - 
isConnectedWith
This method checks whether this vertex is connected with other givenVertexor is not.- Parameters:
 vertex- a different vertex that is possibly adjacent to this vertex.- Returns:
 trueif vertices are adjacent,falseotherwise.- Since:
 - 1.0-beta
 
 - 
connectWith
This method connects this vertex with other givenVertex. They connect only if they are not the same vertex and if they are not connected yet.- Parameters:
 vertex- a vertex to be adjacent to this vertex.- Returns:
 trueif this vertex has been connected with givenVertex,falseotherwise.- Since:
 - 1.0-beta
 - See Also:
 
 - 
canConnectWith
This method checks if this vertex can be connected to the vertex given as a parameter.- Parameters:
 vertex- a vertex to check if it can be connected with this vertex.- Returns:
 trueif vertices can be connected,falseotherwise.- Since:
 - 1.1
 
 - 
canDisconnectWith
This method check if this vertex can be disconnected with the vertex given as a parameter.- Parameters:
 vertex- - a vertex to check if it can be disconnected with this vertex.- Returns:
 trueif vertices can be disconnected,falseotherwise.- Since:
 - 1.1
 
 - 
disconnectWith
This method disconnects this vertex with other givenVertex. They disconnect only if they are not the same vertex and if they are already connected.- Parameters:
 vertex- a vertex to be disconnected with this vertex.- Returns:
 trueif this vertex has been disconnected with givenVertex,falseotherwise.- Since:
 - 1.0-beta
 - See Also:
 
 - 
toString
 
 -