Class Node<V>

  • Type Parameters:
    V - the type of the value of the nodes

    public class Node<V>
    extends Object
    Class representing a node in a graph. A node has a value.
    Author:
    Herbert Praehofer
    • Field Detail

      • value

        private final V value
        The value of the node
      • succs

        private final List<Edge<V>> succs
        The list of outgoing edges
      • preds

        private final List<Edge<V>> preds
        The list of incoming edges
    • Constructor Detail

      • Node

        Node​(V value)
        Constructor initializing the value of the node.
        Parameters:
        value - the value of the node
    • Method Detail

      • connect

        static <V> Edge<V> connect​(Node<V> from,
                                   Node<V> to,
                                   int weight)
        Connects two nodes.
        Type Parameters:
        V - the type of node values
        Parameters:
        from - the source node
        to - the target node
        weight - the weight
        Returns:
        the edge
      • getValue

        public V getValue()
        Returns the value of the node.
        Returns:
        the value of the node
      • getEdge

        public Optional<Edge<V>> getEdge​(Node<V> succNode)
        Returns the edge building a connection to the given node in an optional; with empty if no connection exists.
        Parameters:
        succNode - the connected node
        Returns:
        an edge in an optional building the connection
      • getWeight

        public int getWeight​(Node<V> succNode)
        Returns the weight of the edge building a connection to the given node in an optional; with empty if no connection exists.
        Parameters:
        succNode - the connected node
        Returns:
        the weight of an edge in an optional
      • getSuccEdges

        public List<Edge<V>> getSuccEdges()
        Returns a list of outgoing edges.
        Returns:
        the outgoing edges
      • getPredEdges

        public List<Edge<V>> getPredEdges()
        Returns a list of incoming edges.
        Returns:
        the incoming edges
      • getSuccNodes

        public List<Node<V>> getSuccNodes()
        Returns a list of connected nodes by outgoing edges.
        Returns:
        the nodes connected by an outgoing edges
      • getPredNodes

        public List<Node<V>> getPredNodes()
        Returns a list of connected nodes by incoming edges.
        Returns:
        the nodes connected by an incoming edges
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object