com.kuka.graph.impl
Class FastUncheckedPath<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.FastUncheckedPath<N,E>
Type Parameters:
N - the type of nodes
E - the type of edges
All Implemented Interfaces:
Graph<N,E>, Path<N,E>, Serializable, Cloneable, Iterable<N>

public class FastUncheckedPath<N,E extends Edge<N>>
extends AbstractBaseGraph<N,E>
implements Path<N,E>

Implements a path. It is assumed that the edges are inserted in the order of the path.

See Also:
Serialized Form

Constructor Summary
FastUncheckedPath()
           
 
Method Summary
 boolean addEdge(E edge)
          Adds the specified edge 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.
 E createEdge(N source, N target)
          Creates a new edge from the specified source node to the target node, adds it to this graph and returns the created edge.
 N createNode()
          Creates a new node, adds it to this graph and returns the created node.
 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.AbstractBaseGraph
addNode, 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, addNode, clear, containsAllEdges, containsAllNodes, containsEdge, containsEdge, containsNode, edges, edges, edgeSize, getEdge, incomingEdges, isEmpty, neighbors, nodes, nodes, nodeSize, outgoingEdges, removeAllEdges, removeAllNodes, removeEdge, removeEdge, removeNode, retainAllEdges, retainAllNodes
 

Constructor Detail

FastUncheckedPath

public FastUncheckedPath()
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

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 AbstractBaseGraph<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

createNode

public N createNode()
Description copied from interface: Graph
Creates a new node, adds it to this graph and returns the created node.

Specified by:
createNode in interface Graph<N,E extends Edge<N>>
Returns:
the created node

createEdge

public E createEdge(N source,
                    N target)
Description copied from interface: Graph
Creates a new edge from the specified source node to the target node, adds it to this graph and returns the created edge. If graph does not contain the specified nodes they are added, too.

Specified by:
createEdge in interface Graph<N,E extends Edge<N>>
Parameters:
source - the source node of the edge that is to be created
target - the target node of the edge that is to be created
Returns:
the created 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.