Package at.jku.ssw.fp.sect04_3
Class Node<V>
- java.lang.Object
-
- at.jku.ssw.fp.sect04_3.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
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static <V> Edge<V>
connect(Node<V> from, Node<V> to, int weight)
Connects two nodes.boolean
equals(Object obj)
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.List<Edge<V>>
getPredEdges()
Returns a list of incoming edges.List<Node<V>>
getPredNodes()
Returns a list of connected nodes by incoming edges.List<Edge<V>>
getSuccEdges()
Returns a list of outgoing edges.List<Node<V>>
getSuccNodes()
Returns a list of connected nodes by outgoing edges.V
getValue()
Returns the value of the node.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.int
hashCode()
String
toString()
-
-
-
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 nodeto
- the target nodeweight
- 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
-
-