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

public class Subgraph<N,E extends Edge<N>>
extends AbstractBaseGraph<N,E>

Class realizing a subgraph of a directed graph. A subgraph is itself a directed graph. However, only nodes and edges present in the super graph may be added. No new nodes may be created.

See Also:
Serialized Form

Constructor Summary
Subgraph(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).
 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.
protected  Graph<N,E> 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, 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
 

Constructor Detail

Subgraph

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

Parameters:
graph - the graph of which this graph is a subgraph.
Method Detail

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

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.

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

graph

protected Graph<N,E> graph()
Returns:
the graph of which this graph is a subgraph.


Copyright © 2019. All rights reserved.