|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.kuka.graph.impl.AbstractGraph<N,E>
com.kuka.graph.impl.TransposeGraph<N,E>
N - the type of the nodes.E - the type of the edges.public class TransposeGraph<N,E extends Edge<N>>
In the mathematical and algorithmic study of graph theory, the converse, transpose or reverse of a directed graph G is another directed graph on the same set of vertices with all of the edges reversed compared to the orientation of the corresponding edges in G. That is, if G contains an edge (i,j) then the transpose of G contains an edge (j,i) and vice versa.
This class implements the transpose graph as an unmodifiable view of the original graph, i.e. it is not allowed to change the transpose graph but changes to the original graph are also visible in the transpose graph.
See also https://en.wikipedia.org/wiki/Transpose_graph.
| Constructor Summary | |
|---|---|
TransposeGraph(Graph<N,E> graph)
Creates a transposed view of the given graph. |
|
| 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). |
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. |
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. |
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 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public TransposeGraph(Graph<N,E> graph)
graph - the graph from which the transposed view is to be created| Method Detail |
|---|
public boolean containsNode(N node)
Graph
node - node whose presence in this graph is to be tested
public boolean containsEdge(E edge)
Graph
edge - edge whose presence in this graph is to be tested
public Set<N> nodes()
GraphSet 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.
public Set<E> edges()
GraphSet 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.
public E getEdge(N source,
N target)
GraphMore 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.
source - the source node of the edge that is to be returnedtarget - the target node of the edge that is to be returned
public Set<E> outgoingEdges(N node)
GraphMore 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,*).
node - the source node
public Set<E> incomingEdges(N node)
GraphMore 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).
node - the target node
public Set<N> neighbors(N node)
In this transposed view of the underlying graph G all neighbors of the given node are returned after reversing all edges of G.
node - the node of which all neighboring nodes are to be returned
public N createNode()
Graph
public E createEdge(N source,
N target)
Graph
source - the source node of the edge that is to be createdtarget - the target node of the edge that is to be created
public boolean addNode(N node)
GraphMore 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.
node - node to be added to this graph
public boolean addEdge(E edge)
GraphMore 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.
edge - edge to be added to this graph
public boolean removeNode(N node)
GraphMore 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).
node - node to be removed from this graph, if present
public boolean removeEdge(E edge)
GraphMore 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).
edge - edge to be removed from this graph, if present
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||