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.
Enclosing class:
Graph<T>

private class Graph.Vertex<E extends T> extends Object
This inner class implements vertices of this graph.
Since:
1.0-beta
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private E
    This field represents data stored in this vertex.
    private final int
    This field represents the index of a vertex.
    private final List<Graph<T>.Vertex<E>>
    This field represents (open) neighbourhood of this vertex.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Vertex(int index)
    This constructor creates vertex based on a given int parameter.
  • Method Summary

    Modifier and Type
    Method
    Description
    private boolean
    This method checks if this vertex can be connected to the vertex given as a parameter.
    private boolean
    This method check if this vertex can be disconnected with the vertex given as a parameter.
    private boolean
    This method connects this vertex with other given Vertex.
    private boolean
    This method disconnects this vertex with other given Vertex.
    private int
    This method returns the degree of this vertex.
    private boolean
    This method checks whether this vertex is connected with other given Vertex or is not.
    @NotNull String
     

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • index

      private final int index
      This 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

      private final List<Graph<T>.Vertex<E extends T>> neighbours
      This field represents (open) neighbourhood of this vertex.
      Since:
      1.0-beta
      See Also:
    • element

      private E extends T element
      This field represents data stored in this vertex.
      Since:
      2.0
      See Also:
  • Constructor Details

  • 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

      private boolean isConnectedWith(Graph<T>.Vertex<E> vertex)
      This method checks whether this vertex is connected with other given Vertex or is not.
      Parameters:
      vertex - a different vertex that is possibly adjacent to this vertex.
      Returns:
      true if vertices are adjacent, false otherwise.
      Since:
      1.0-beta
    • connectWith

      private boolean connectWith(Graph<T>.Vertex<E> vertex)
      This method connects this vertex with other given Vertex. 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:
      true if this vertex has been connected with given Vertex, false otherwise.
      Since:
      1.0-beta
      See Also:
    • canConnectWith

      private boolean canConnectWith(Graph<T>.Vertex<E> vertex)
      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:
      true if vertices can be connected, false otherwise.
      Since:
      1.1
    • canDisconnectWith

      private boolean canDisconnectWith(Graph<T>.Vertex<E> vertex)
      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:
      true if vertices can be disconnected, false otherwise.
      Since:
      1.1
    • disconnectWith

      private boolean disconnectWith(Graph<T>.Vertex<E> vertex)
      This method disconnects this vertex with other given Vertex. 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:
      true if this vertex has been disconnected with given Vertex, false otherwise.
      Since:
      1.0-beta
      See Also:
    • toString

      @Contract(pure=true) @NotNull public @NotNull String toString()
      Overrides:
      toString in class Object
      Returns:
      String value of index.
      Since:
      1.0-beta
      See Also: