Package at.jku.ssw.fp.sect04_3
Class Graph<V>
- java.lang.Object
-
- at.jku.ssw.fp.sect04_3.Graph<V>
-
public class Graph<V> extends Object
Graph with nodes and edges
-
-
Constructor Summary
Constructors Constructor Description Graph()
Constructor initializing the lists of nodes and edges with empty lists.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Node<V>
addNode(V value)
Adds a node with a given value to the graph.void
biConnect(Node<V> from, Node<V> to, int weight)
Makes a bidirectional connection of two nodes with a given weight.Edge<V>
connect(Node<V> from, Node<V> to, int weight)
Connects two nodes with a given weight.List<Edge<V>>
getEdges()
Returns the list of edges of this graph.List<Node<V>>
getNodes()
Returns the list of nodes of this graph.
-
-
-
Method Detail
-
addNode
public Node<V> addNode(V value)
Adds a node with a given value to the graph.- Parameters:
value
- the value in the node- Returns:
- the node added
-
connect
public Edge<V> connect(Node<V> from, Node<V> to, int weight)
Connects two nodes with a given weight.- Parameters:
from
- the source nodeto
- the destination nodeweight
- the weight- Returns:
- the edge
-
biConnect
public void biConnect(Node<V> from, Node<V> to, int weight)
Makes a bidirectional connection of two nodes with a given weight.- Parameters:
from
- the first nodeto
- the second nodeweight
- the weight
-
getNodes
public List<Node<V>> getNodes()
Returns the list of nodes of this graph.- Returns:
- the list of nodes
-
-