com.kuka.graph.impl
Class BasePath<N,E extends Edge<N>>

java.lang.Object
  extended by com.kuka.graph.impl.AbstractGraph<N,E>
      extended by com.kuka.graph.impl.AbstractBaseGraph<N,E>
          extended by com.kuka.graph.impl.Subgraph<N,E>
              extended by com.kuka.graph.impl.BasePath<N,E>
Type Parameters:
N - the node type.
E - the edge type.
All Implemented Interfaces:
Graph<N,E>, Path<N,E>, Serializable, Cloneable, Iterable<N>

public class BasePath<N,E extends Edge<N>>
extends Subgraph<N,E>
implements Path<N,E>

Class realizing a path in a directed graph.

See Also:
Serialized Form

Constructor Summary
BasePath(Graph<N,E> graph)
          Constructor.
 
Method Summary
 boolean addEdge(E edge)
          Adds the specified edge to this graph if it is not already present (optional operation).
 boolean addNode(N node)
          Adds the specified node to this graph if it is not already present (optional operation).
 Path<N,E> concat(Path<N,E> other)
          Concatenates the specified path to the end of this path.
 N firstNode()
          Returns the first node of this path.
 Iterator<N> iterator()
           
 N lastNode()
          Returns the last node of this path.
 boolean removeFirstNode()
          Removes the first node (and edge to second node) from this path (optional operation).
 boolean removeLastNode()
          Removes the last node (and edge to last node) from this path (optional operation).
 
Methods inherited from class com.kuka.graph.impl.Subgraph
createEdge, createNode, graph
 
Methods inherited from class com.kuka.graph.impl.AbstractBaseGraph
clone, containsEdge, containsNode, edges, getEdge, incomingEdges, neighbors, nodes, outgoingEdges, removeEdge, removeNode
 
Methods inherited from class com.kuka.graph.impl.AbstractGraph
addAllEdges, addAllNodes, clear, containsAllEdges, containsAllNodes, containsEdge, edges, edgeSize, isEmpty, nodes, nodeSize, removeAllEdges, removeAllNodes, removeEdge, retainAllEdges, retainAllNodes, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.kuka.graph.Graph
addAllEdges, addAllNodes, clear, containsAllEdges, containsAllNodes, containsEdge, containsEdge, containsNode, createEdge, createNode, edges, edges, edgeSize, getEdge, incomingEdges, isEmpty, neighbors, nodes, nodes, nodeSize, outgoingEdges, removeAllEdges, removeAllNodes, removeEdge, removeEdge, removeNode, retainAllEdges, retainAllNodes
 

Constructor Detail

BasePath

public BasePath(Graph<N,E> graph)
Constructor.

Parameters:
graph - the graph in which this path lies.
Method Detail

iterator

public Iterator<N> iterator()
Specified by:
iterator in interface Iterable<N>
Overrides:
iterator in class AbstractGraph<N,E extends Edge<N>>

firstNode

public N firstNode()
Description copied from interface: Path
Returns the first node of this path.

Specified by:
firstNode in interface Path<N,E extends Edge<N>>
Returns:
the first node

lastNode

public N lastNode()
Description copied from interface: Path
Returns the last node of this path.

Specified by:
lastNode in interface Path<N,E extends Edge<N>>
Returns:
the last node

removeFirstNode

public boolean removeFirstNode()
Description copied from interface: Path
Removes the first node (and edge to second node) from this path (optional operation).

Returns true if this path is not empty (or equivalently, if this path changed as a result of the call).

Specified by:
removeFirstNode in interface Path<N,E extends Edge<N>>
Returns:
true if the first node was removed from the path

removeLastNode

public boolean removeLastNode()
Description copied from interface: Path
Removes the last node (and edge to last node) from this path (optional operation).

Returns true if this path is not empty (or equivalently, if this path changed as a result of the call).

Specified by:
removeLastNode in interface Path<N,E extends Edge<N>>
Returns:
true if the last node was removed from the path

addNode

public boolean addNode(N node)
Description copied from interface: Graph
Adds the specified node to this graph if it is not already present (optional operation).

More formally, adds the specified node n to this graph if the graph contains no element n2 such that n.equals(n2)) . If this graph already contains the element, the call leaves the graph unchanged and returns false.

Specified by:
addNode in interface Graph<N,E extends Edge<N>>
Overrides:
addNode in class Subgraph<N,E extends Edge<N>>
Parameters:
node - node to be added to this graph
Returns:
true if this graph did not already contain the specified node

addEdge

public boolean addEdge(E edge)
Description copied from interface: Graph
Adds the specified edge to this graph if it is not already present (optional operation).

More formally, adds the specified edge e to this graph if the graph contains no element e2 such that e.equals(e2)) . If this graph already contains the element, the call leaves the graph unchanged and returns false.

Specified by:
addEdge in interface Graph<N,E extends Edge<N>>
Overrides:
addEdge in class Subgraph<N,E extends Edge<N>>
Parameters:
edge - edge to be added to this graph
Returns:
true if this graph did not already contain the specified edge

concat

public Path<N,E> concat(Path<N,E> other)
Description copied from interface: Path
Concatenates the specified path to the end of this path.

If the length of the specified path is 0, then this path is returned. Otherwise the elements of the specified are only added to the end of this path if the target node of the last element of this path is equal to the source node of the first element of the specified path.

Specified by:
concat in interface Path<N,E extends Edge<N>>
Parameters:
other - the path to be concatenated to the end of this path
Returns:
this path


Copyright © 2019. All rights reserved.