com.kuka.graph.impl
Class AbstractBaseGraph<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>
Type Parameters:
N - the node type.
E - the edge type.
All Implemented Interfaces:
Graph<N,E>, Serializable, Cloneable, Iterable<N>
Direct Known Subclasses:
AbstractBaseListenableGraph, FastUncheckedPath, Subgraph

public abstract class AbstractBaseGraph<N,E extends Edge<N>>
extends AbstractGraph<N,E>
implements Cloneable, Serializable

Abstract base implementation for directed graphs.

All queries (like neighbors, incoming and outgoing edges) are efficient, but memory consumption is quite huge.

See Also:
Serialized Form

Constructor Summary
AbstractBaseGraph()
           
 
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).
 Object clone()
           
 boolean containsEdge(E edge)
          Returns true if this graph contains the specified edge.
 boolean containsNode(N node)
          Returns true if this graph contains the specified node.
 Set<E> edges()
          Returns an unmodifiable Set view of the edges contained in this graph.
 E getEdge(N source, N target)
          Returns the edge e=(source,target) from the specified source node to the target node, or null if this graph contains no such edge.
 Set<E> incomingEdges(N node)
          Returns the set of all incoming edges of the specified node.
 Set<N> neighbors(N node)
          Returns the set of all neighbors of the specified node.
 Set<N> nodes()
          Returns an unmodifiable Set view of the nodes contained in this graph.
 Set<E> outgoingEdges(N node)
          Returns the set of all outgoing edges of the specified node.
 boolean removeEdge(E edge)
          Removes the specified edge e from this graph if it is present (optional operation).
 boolean removeNode(N node)
          Removes the specified node n from this graph if it is present (optional operation).
 
Methods inherited from class com.kuka.graph.impl.AbstractGraph
addAllEdges, addAllNodes, clear, containsAllEdges, containsAllNodes, containsEdge, edges, edgeSize, isEmpty, iterator, 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
createEdge, createNode
 

Constructor Detail

AbstractBaseGraph

public AbstractBaseGraph()
Method Detail

containsNode

public boolean containsNode(N node)
Description copied from interface: Graph
Returns true if this graph contains the specified node. More formally, returns true if and only if this graph contains a node n* such that node.equals(n*).

Specified by:
containsNode in interface Graph<N,E extends Edge<N>>
Parameters:
node - node whose presence in this graph is to be tested
Returns:
true if this graph contains the specified node

containsEdge

public boolean containsEdge(E edge)
Description copied from interface: Graph
Returns true if this graph contains the specified edge. More formally, returns true if and only if this graph contains an edge e* such that edge.equals(e*).

Specified by:
containsEdge in interface Graph<N,E extends Edge<N>>
Parameters:
edge - edge whose presence in this graph is to be tested
Returns:
true if this graph contains the specified edge

nodes

public final Set<N> nodes()
Description copied from interface: Graph
Returns an unmodifiable Set view of the nodes contained in this graph. The set is backed by the graph, so changes to the graph are reflected in the set. If the graph is modified while an iteration over the set is in progress, the results of the iteration are undefined.

Specified by:
nodes in interface Graph<N,E extends Edge<N>>
Returns:
a set view of the nodes contained in this graph

edges

public final Set<E> edges()
Description copied from interface: Graph
Returns an unmodifiable Set view of the edges contained in this graph. The set is backed by the graph, so changes to the graph are reflected in the set. If the graph is modified while an iteration over the set is in progress, the results of the iteration are undefined.

Specified by:
edges in interface Graph<N,E extends Edge<N>>
Returns:
a set view of the edges contained in this graph

getEdge

public E getEdge(N source,
                 N target)
Description copied from interface: Graph
Returns the edge e=(source,target) from the specified source node to the target node, or null if this graph contains no such edge.

More formally, if this graph contains an edge e* such that e.equals(e*), where e=(source,target), then this method returns e*, otherwise it returns null.

Specified by:
getEdge in interface Graph<N,E extends Edge<N>>
Parameters:
source - the source node of the edge that is to be returned
target - the target node of the edge that is to be returned
Returns:
the the edge from the specified source node to the target node, or null if this graph contains no such edge

outgoingEdges

public Set<E> outgoingEdges(N node)
Description copied from interface: Graph
Returns the set of all outgoing edges of the specified node. If no such edge exists, then the returned set is empty.

More formally, this method returns all edges e in this graph such that the given node is the source node of e, i.e. e=(node,*).

Specified by:
outgoingEdges in interface Graph<N,E extends Edge<N>>
Parameters:
node - the source node
Returns:
the set of all edges with the given node as source

incomingEdges

public Set<E> incomingEdges(N node)
Description copied from interface: Graph
Returns the set of all incoming edges of the specified node. If no such edge exists, then the returned set is empty.

More formally, this method returns all edges e in this graph such that the given node is the target node of e, i.e. e=(*,node).

Specified by:
incomingEdges in interface Graph<N,E extends Edge<N>>
Parameters:
node - the target node
Returns:
the set of all edges with the given node as target

neighbors

public Set<N> neighbors(N node)
Description copied from interface: Graph
Returns the set of all neighbors of the specified node. If no such node exists, the the returned set is empty.

Specified by:
neighbors in interface Graph<N,E extends Edge<N>>
Parameters:
node - the node of which all neighboring nodes are to be returned
Returns:
the set of all neighbors of the given node

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>>
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>>
Parameters:
edge - edge to be added to this graph
Returns:
true if this graph did not already contain the specified edge

removeNode

public boolean removeNode(N node)
Description copied from interface: Graph
Removes the specified node n from this graph if it is present (optional operation).

More formally, removes a node n* such that n.equals(n*) , if this graph contains such a node. Furthermore, all edges incident to this node are removed. Returns true if this graph contained the node (or equivalently, if this graph changed as a result of the call).

Specified by:
removeNode in interface Graph<N,E extends Edge<N>>
Parameters:
node - node to be removed from this graph, if present
Returns:
true if this graph contained the specified node

removeEdge

public boolean removeEdge(E edge)
Description copied from interface: Graph
Removes the specified edge e from this graph if it is present (optional operation).

More formally, removes an edge e* such that e.equals(e*), if this graph contains such an edge. Returns true if this graph contained the edge (or equivalently, if this graph changed as a result of the call).

Specified by:
removeEdge in interface Graph<N,E extends Edge<N>>
Parameters:
edge - edge to be removed from this graph, if present
Returns:
true if this graph contained the specified edge

clone

public Object clone()
             throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException


Copyright © 2019. All rights reserved.