package edu.uci.ics.jung.graph.util;
import java.io.Serializable;
import java.util.Collection;
import edu.uci.ics.jung.graph.DirectedGraph;
import edu.uci.ics.jung.graph.Forest;
import edu.uci.ics.jung.graph.Graph;
import edu.uci.ics.jung.graph.Tree;
import edu.uci.ics.jung.graph.UndirectedGraph;
/**
* Provides specialized implementations of GraphDecorator. Currently these
* wrapper types include "synchronized" and "unmodifiable".
*
* The methods of this class may each throw a NullPointerException
* if the graphs or class objects provided to them are null.
*
* @author Tom Nelson
*/
public class Graphs {
/**
* Returns a synchronized graph backed by the passed argument graph.
* @param the vertex type
* @param the edge type
* @param graph the graph for which a synchronized wrapper is to be created
* @return a synchronized graph backed by the passed argument graph
*/
public static Graph synchronizedGraph(Graph graph) {
return new SynchronizedGraph(graph);
}
/**
* Returns a synchronized DirectedGraph backed by the passed DirectedGraph.
* @param the vertex type
* @param the edge type
* @param graph the graph for which a synchronized wrapper is to be created
* @return a synchronized DirectedGraph backed by the passed DirectedGraph
*/
public static DirectedGraph synchronizedDirectedGraph(DirectedGraph graph) {
return new SynchronizedDirectedGraph(graph);
}
/**
* Returns a synchronized UndirectedGraph backed by the passed UndirectedGraph.
* @param the vertex type
* @param the edge type
* @param graph the graph for which a synchronized wrapper is to be created
* @return a synchronized UndirectedGraph backed by the passed UndirectedGraph
*/
public static UndirectedGraph synchronizedUndirectedGraph(UndirectedGraph graph) {
return new SynchronizedUndirectedGraph(graph);
}
/**
* Returns a synchronized Forest backed by the passed Forest.
* @param the vertex type
* @param the edge type
* @param forest the forest for which a synchronized wrapper is to be created
* @return a synchronized Forest backed by the passed Forest
*/
public static SynchronizedForest synchronizedForest(Forest forest) {
return new SynchronizedForest(forest);
}
/**
* Returns a synchronized Tree backed by the passed Tree.
* @param the vertex type
* @param the edge type
* @param tree the tree for which a synchronized wrapper is to be created
* @return a synchronized Tree backed by the passed Tree
*/
public static SynchronizedTree synchronizedTree(Tree tree) {
return new SynchronizedTree(tree);
}
/**
* Returns an unmodifiable Graph backed by the passed Graph.
* @param the vertex type
* @param the edge type
* @param graph the graph for which the unmodifiable wrapper is to be returned
* @return an unmodifiable Graph backed by the passed Graph
*/
public static Graph unmodifiableGraph(Graph graph) {
return new UnmodifiableGraph(graph);
}
/**
* Returns an unmodifiable DirectedGraph backed by the passed graph.
* @param the vertex type
* @param the edge type
* @param graph the graph for which the unmodifiable wrapper is to be returned
* @return an unmodifiable DirectedGraph backed by the passed graph
*/
public static DirectedGraph unmodifiableDirectedGraph(DirectedGraph graph) {
return new UnmodifiableDirectedGraph(graph);
}
/**
* Returns an unmodifiable UndirectedGraph backed by the passed graph.
* @param the vertex type
* @param the edge type
* @param graph the graph for which the unmodifiable wrapper is to be returned
* @return an unmodifiable UndirectedGraph backed by the passed graph
*/
public static UndirectedGraph unmodifiableUndirectedGraph(UndirectedGraph graph) {
return new UnmodifiableUndirectedGraph(graph);
}
/**
* Returns an unmodifiable Tree backed by the passed tree.
* @param the vertex type
* @param the edge type
* @param tree the tree for which the unmodifiable wrapper is to be returned
* @return an unmodifiable Tree backed by the passed tree
*/
public static UnmodifiableTree unmodifiableTree(Tree tree) {
return new UnmodifiableTree(tree);
}
/**
* Returns an unmodifiable Forest backed by the passed forest.
* @param the vertex type
* @param the edge type
* @param forest the forest for which the unmodifiable wrapper is to be returned
* @return an unmodifiable Forest backed by the passed forest
*/
public static UnmodifiableForest unmodifiableForest(Forest forest) {
return new UnmodifiableForest(forest);
}
@SuppressWarnings("serial")
static abstract class SynchronizedAbstractGraph implements Graph, Serializable {
protected Graph delegate;
private SynchronizedAbstractGraph(Graph delegate) {
if(delegate == null) {
throw new NullPointerException();
}
this.delegate = delegate;
}
/**
* @see edu.uci.ics.jung.graph.Graph#getDefaultEdgeType()
*/
public EdgeType getDefaultEdgeType()
{
return delegate.getDefaultEdgeType();
}
/**
* @see edu.uci.ics.jung.graph.Graph#addEdge(Object, Object, Object, EdgeType)
*/
public synchronized boolean addEdge(E e, V v1, V v2, EdgeType edgeType) {
return delegate.addEdge(e, v1, v2, edgeType);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#addEdge(Object, Collection, EdgeType)
*/
public synchronized boolean addEdge(E e, Collection extends V>
vertices, EdgeType edgeType)
{
return delegate.addEdge(e, vertices, edgeType);
}
/**
* @see edu.uci.ics.jung.graph.Graph#addEdge(Object, Object, Object)
*/
public synchronized boolean addEdge(E e, V v1, V v2) {
return delegate.addEdge(e, v1, v2);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#addVertex(java.lang.Object)
*/
public synchronized boolean addVertex(V vertex) {
return delegate.addVertex(vertex);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#isIncident(java.lang.Object, java.lang.Object)
*/
public synchronized boolean isIncident(V vertex, E edge) {
return delegate.isIncident(vertex, edge);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#isNeighbor(java.lang.Object, java.lang.Object)
*/
public synchronized boolean isNeighbor(V v1, V v2) {
return delegate.isNeighbor(v1, v2);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#degree(java.lang.Object)
*/
public synchronized int degree(V vertex) {
return delegate.degree(vertex);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#findEdge(java.lang.Object, java.lang.Object)
*/
public synchronized E findEdge(V v1, V v2) {
return delegate.findEdge(v1, v2);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#findEdgeSet(java.lang.Object, java.lang.Object)
*/
public synchronized Collection findEdgeSet(V v1, V v2)
{
return delegate.findEdgeSet(v1, v2);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#getEdges()
*/
public synchronized Collection getEdges() {
return delegate.getEdges();
}
/**
* @see edu.uci.ics.jung.graph.Graph#getEdges(EdgeType)
*/
public synchronized Collection getEdges(EdgeType edgeType) {
return delegate.getEdges(edgeType);
}
/**
* @see edu.uci.ics.jung.graph.Graph#getEndpoints(java.lang.Object)
*/
public synchronized Pair getEndpoints(E edge) {
return delegate.getEndpoints(edge);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#getIncidentEdges(java.lang.Object)
*/
public synchronized Collection getIncidentEdges(V vertex) {
return delegate.getIncidentEdges(vertex);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#getIncidentVertices(java.lang.Object)
*/
public synchronized Collection getIncidentVertices(E edge) {
return delegate.getIncidentVertices(edge);
}
/**
* @see edu.uci.ics.jung.graph.Graph#getInEdges(java.lang.Object)
*/
public synchronized Collection getInEdges(V vertex) {
return delegate.getInEdges(vertex);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#getNeighbors(java.lang.Object)
*/
public synchronized Collection getNeighbors(V vertex) {
return delegate.getNeighbors(vertex);
}
/**
* @see edu.uci.ics.jung.graph.Graph#getOpposite(java.lang.Object, java.lang.Object)
*/
public synchronized V getOpposite(V vertex, E edge) {
return delegate.getOpposite(vertex, edge);
}
/**
* @see edu.uci.ics.jung.graph.Graph#getOutEdges(java.lang.Object)
*/
public synchronized Collection getOutEdges(V vertex) {
return delegate.getOutEdges(vertex);
}
/**
* @see edu.uci.ics.jung.graph.Graph#getPredecessors(java.lang.Object)
*/
public synchronized Collection getPredecessors(V vertex) {
return delegate.getPredecessors(vertex);
}
/**
* @see edu.uci.ics.jung.graph.Graph#getSuccessors(java.lang.Object)
*/
public synchronized Collection getSuccessors(V vertex) {
return delegate.getSuccessors(vertex);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#getVertices()
*/
public synchronized Collection getVertices() {
return delegate.getVertices();
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#getEdgeCount()
*/
public synchronized int getEdgeCount() {
return delegate.getEdgeCount();
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#getEdgeCount(EdgeType)
*/
public synchronized int getEdgeCount(EdgeType edge_type)
{
return delegate.getEdgeCount(edge_type);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#getVertexCount()
*/
public synchronized int getVertexCount() {
return delegate.getVertexCount();
}
/**
* @see edu.uci.ics.jung.graph.Graph#inDegree(java.lang.Object)
*/
public synchronized int inDegree(V vertex) {
return delegate.inDegree(vertex);
}
/**
* @see edu.uci.ics.jung.graph.Graph#getEdgeType(java.lang.Object)
*/
public synchronized EdgeType getEdgeType(E edge) {
return delegate.getEdgeType(edge);
}
/**
* @see edu.uci.ics.jung.graph.Graph#isPredecessor(java.lang.Object, java.lang.Object)
*/
public synchronized boolean isPredecessor(V v1, V v2) {
return delegate.isPredecessor(v1, v2);
}
/**
* @see edu.uci.ics.jung.graph.Graph#isSuccessor(java.lang.Object, java.lang.Object)
*/
public synchronized boolean isSuccessor(V v1, V v2) {
return delegate.isSuccessor(v1, v2);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#getNeighborCount(java.lang.Object)
*/
public synchronized int getNeighborCount(V vertex) {
return delegate.getNeighborCount(vertex);
}
/**
* @see edu.uci.ics.jung.graph.Graph#getPredecessorCount(java.lang.Object)
*/
public synchronized int getPredecessorCount(V vertex) {
return delegate.getPredecessorCount(vertex);
}
/**
* @see edu.uci.ics.jung.graph.Graph#getSuccessorCount(java.lang.Object)
*/
public synchronized int getSuccessorCount(V vertex) {
return delegate.getSuccessorCount(vertex);
}
/**
* @see edu.uci.ics.jung.graph.Graph#outDegree(java.lang.Object)
*/
public synchronized int outDegree(V vertex) {
return delegate.outDegree(vertex);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#removeEdge(java.lang.Object)
*/
public synchronized boolean removeEdge(E edge) {
return delegate.removeEdge(edge);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#removeVertex(java.lang.Object)
*/
public synchronized boolean removeVertex(V vertex) {
return delegate.removeVertex(vertex);
}
/**
* @see edu.uci.ics.jung.graph.Graph#getDest(java.lang.Object)
*/
public synchronized V getDest(E directed_edge) {
return delegate.getDest(directed_edge);
}
/**
* @see edu.uci.ics.jung.graph.Graph#getSource(java.lang.Object)
*/
public synchronized V getSource(E directed_edge) {
return delegate.getSource(directed_edge);
}
/**
* @see edu.uci.ics.jung.graph.Graph#isDest(java.lang.Object, java.lang.Object)
*/
public synchronized boolean isDest(V vertex, E edge) {
return delegate.isDest(vertex, edge);
}
/**
* @see edu.uci.ics.jung.graph.Graph#isSource(java.lang.Object, java.lang.Object)
*/
public synchronized boolean isSource(V vertex, E edge) {
return delegate.isSource(vertex, edge);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#getIncidentCount(Object)
*/
public synchronized int getIncidentCount(E edge)
{
return delegate.getIncidentCount(edge);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#addEdge(java.lang.Object, java.util.Collection)
*/
public synchronized boolean addEdge(E hyperedge, Collection extends V> vertices) {
return delegate.addEdge(hyperedge, vertices);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#containsEdge(java.lang.Object)
*/
public synchronized boolean containsEdge(E edge) {
return delegate.containsEdge(edge);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#containsVertex(java.lang.Object)
*/
public synchronized boolean containsVertex(V vertex) {
return delegate.containsVertex(vertex);
}
}
@SuppressWarnings("serial")
static class SynchronizedGraph extends SynchronizedAbstractGraph implements Serializable {
private SynchronizedGraph(Graph delegate) {
super(delegate);
}
}
@SuppressWarnings("serial")
static class SynchronizedUndirectedGraph extends SynchronizedAbstractGraph
implements UndirectedGraph, Serializable {
private SynchronizedUndirectedGraph(UndirectedGraph delegate) {
super(delegate);
}
}
@SuppressWarnings("serial")
static class SynchronizedDirectedGraph extends SynchronizedAbstractGraph
implements DirectedGraph, Serializable {
private SynchronizedDirectedGraph(DirectedGraph delegate) {
super(delegate);
}
@Override
public synchronized V getDest(E directed_edge) {
return ((DirectedGraph)delegate).getDest(directed_edge);
}
@Override
public synchronized V getSource(E directed_edge) {
return ((DirectedGraph)delegate).getSource(directed_edge);
}
@Override
public synchronized boolean isDest(V vertex, E edge) {
return ((DirectedGraph)delegate).isDest(vertex, edge);
}
@Override
public synchronized boolean isSource(V vertex, E edge) {
return ((DirectedGraph)delegate).isSource(vertex, edge);
}
}
@SuppressWarnings("serial")
static class SynchronizedTree extends SynchronizedForest implements Tree {
/**
* Creates a new instance based on the provided {@code delegate}.
* @param delegate
*/
public SynchronizedTree(Tree delegate) {
super(delegate);
}
public synchronized int getDepth(V vertex) {
return ((Tree)delegate).getDepth(vertex);
}
public synchronized int getHeight() {
return ((Tree)delegate).getHeight();
}
public synchronized V getRoot() {
return ((Tree)delegate).getRoot();
}
}
@SuppressWarnings("serial")
static class SynchronizedForest extends SynchronizedDirectedGraph implements Forest {
/**
* Creates a new instance based on the provided {@code delegate}.
* @param delegate
*/
public SynchronizedForest(Forest delegate) {
super(delegate);
}
public synchronized Collection> getTrees() {
return ((Forest)delegate).getTrees();
}
public int getChildCount(V vertex)
{
return ((Forest)delegate).getChildCount(vertex);
}
public Collection getChildEdges(V vertex)
{
return ((Forest)delegate).getChildEdges(vertex);
}
public Collection getChildren(V vertex)
{
return ((Forest)delegate).getChildren(vertex);
}
public V getParent(V vertex)
{
return ((Forest)delegate).getParent(vertex);
}
public E getParentEdge(V vertex)
{
return ((Forest)delegate).getParentEdge(vertex);
}
}
@SuppressWarnings("serial")
static abstract class UnmodifiableAbstractGraph implements Graph, Serializable {
protected Graph delegate;
private UnmodifiableAbstractGraph(Graph delegate) {
if(delegate == null) {
throw new NullPointerException();
}
this.delegate = delegate;
}
/**
* @see edu.uci.ics.jung.graph.Graph#getDefaultEdgeType()
*/
public EdgeType getDefaultEdgeType()
{
return delegate.getDefaultEdgeType();
}
/**
* @see edu.uci.ics.jung.graph.Graph#addEdge(Object, Object, Object, EdgeType)
*/
public boolean addEdge(E e, V v1, V v2, EdgeType edgeType) {
throw new UnsupportedOperationException();
}
/**
* @see edu.uci.ics.jung.graph.Graph#addEdge(Object, Collection, EdgeType)
*/
public boolean addEdge(E e, Collection extends V> vertices,
EdgeType edgeType)
{
throw new UnsupportedOperationException();
}
/**
* @see edu.uci.ics.jung.graph.Graph#addEdge(Object, Object, Object)
*/
public boolean addEdge(E e, V v1, V v2) {
throw new UnsupportedOperationException();
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#addVertex(java.lang.Object)
*/
public boolean addVertex(V vertex) {
throw new UnsupportedOperationException();
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#isIncident(java.lang.Object, java.lang.Object)
*/
public boolean isIncident(V vertex, E edge) {
return delegate.isIncident(vertex, edge);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#isNeighbor(java.lang.Object, java.lang.Object)
*/
public boolean isNeighbor(V v1, V v2) {
return delegate.isNeighbor(v1, v2);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#degree(java.lang.Object)
*/
public int degree(V vertex) {
return delegate.degree(vertex);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#findEdge(java.lang.Object, java.lang.Object)
*/
public E findEdge(V v1, V v2) {
return delegate.findEdge(v1, v2);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#findEdgeSet(java.lang.Object, java.lang.Object)
*/
public Collection findEdgeSet(V v1, V v2)
{
return delegate.findEdgeSet(v1, v2);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#getEdges()
*/
public Collection getEdges() {
return delegate.getEdges();
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#getEdgeCount()
*/
public int getEdgeCount() {
return delegate.getEdgeCount();
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#getEdgeCount(EdgeType)
*/
public int getEdgeCount(EdgeType edge_type)
{
return delegate.getEdgeCount(edge_type);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#getVertexCount()
*/
public int getVertexCount() {
return delegate.getVertexCount();
}
/**
* @see edu.uci.ics.jung.graph.Graph#getEdges(edu.uci.ics.jung.graph.util.EdgeType)
*/
public Collection getEdges(EdgeType edgeType) {
return delegate.getEdges(edgeType);
}
/**
* @see edu.uci.ics.jung.graph.Graph#getEndpoints(java.lang.Object)
*/
public Pair getEndpoints(E edge) {
return delegate.getEndpoints(edge);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#getIncidentEdges(java.lang.Object)
*/
public Collection getIncidentEdges(V vertex) {
return delegate.getIncidentEdges(vertex);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#getIncidentVertices(java.lang.Object)
*/
public Collection getIncidentVertices(E edge) {
return delegate.getIncidentVertices(edge);
}
/**
* @see edu.uci.ics.jung.graph.Graph#getInEdges(java.lang.Object)
*/
public Collection getInEdges(V vertex) {
return delegate.getInEdges(vertex);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#getNeighbors(java.lang.Object)
*/
public Collection getNeighbors(V vertex) {
return delegate.getNeighbors(vertex);
}
/**
* @see edu.uci.ics.jung.graph.Graph#getOpposite(java.lang.Object, java.lang.Object)
*/
public V getOpposite(V vertex, E edge) {
return delegate.getOpposite(vertex, edge);
}
/**
* @see edu.uci.ics.jung.graph.Graph#getOutEdges(java.lang.Object)
*/
public Collection getOutEdges(V vertex) {
return delegate.getOutEdges(vertex);
}
/**
* @see edu.uci.ics.jung.graph.Graph#getPredecessors(java.lang.Object)
*/
public Collection getPredecessors(V vertex) {
return delegate.getPredecessors(vertex);
}
/**
* @see edu.uci.ics.jung.graph.Graph#getSuccessors(java.lang.Object)
*/
public Collection getSuccessors(V vertex) {
return delegate.getSuccessors(vertex);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#getVertices()
*/
public Collection getVertices() {
return delegate.getVertices();
}
/**
* @see edu.uci.ics.jung.graph.Graph#inDegree(java.lang.Object)
*/
public int inDegree(V vertex) {
return delegate.inDegree(vertex);
}
/**
* @see edu.uci.ics.jung.graph.Graph#getEdgeType(java.lang.Object)
*/
public EdgeType getEdgeType(E edge) {
return delegate.getEdgeType(edge);
}
/**
* @see edu.uci.ics.jung.graph.Graph#isPredecessor(java.lang.Object, java.lang.Object)
*/
public boolean isPredecessor(V v1, V v2) {
return delegate.isPredecessor(v1, v2);
}
/**
* @see edu.uci.ics.jung.graph.Graph#isSuccessor(java.lang.Object, java.lang.Object)
*/
public boolean isSuccessor(V v1, V v2) {
return delegate.isSuccessor(v1, v2);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#getNeighborCount(java.lang.Object)
*/
public int getNeighborCount(V vertex) {
return delegate.getNeighborCount(vertex);
}
/**
* @see edu.uci.ics.jung.graph.Graph#getPredecessorCount(java.lang.Object)
*/
public int getPredecessorCount(V vertex) {
return delegate.getPredecessorCount(vertex);
}
/**
* @see edu.uci.ics.jung.graph.Graph#getSuccessorCount(java.lang.Object)
*/
public int getSuccessorCount(V vertex) {
return delegate.getSuccessorCount(vertex);
}
/**
* @see edu.uci.ics.jung.graph.Graph#outDegree(java.lang.Object)
*/
public int outDegree(V vertex) {
return delegate.outDegree(vertex);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#removeEdge(java.lang.Object)
*/
public boolean removeEdge(E edge) {
throw new UnsupportedOperationException();
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#removeVertex(java.lang.Object)
*/
public boolean removeVertex(V vertex) {
throw new UnsupportedOperationException();
}
/**
* @see edu.uci.ics.jung.graph.Graph#getDest(java.lang.Object)
*/
public V getDest(E directed_edge) {
return delegate.getDest(directed_edge);
}
/**
* @see edu.uci.ics.jung.graph.Graph#getSource(java.lang.Object)
*/
public V getSource(E directed_edge) {
return delegate.getSource(directed_edge);
}
/**
* @see edu.uci.ics.jung.graph.Graph#isDest(java.lang.Object, java.lang.Object)
*/
public boolean isDest(V vertex, E edge) {
return delegate.isDest(vertex, edge);
}
/**
* @see edu.uci.ics.jung.graph.Graph#isSource(java.lang.Object, java.lang.Object)
*/
public boolean isSource(V vertex, E edge) {
return delegate.isSource(vertex, edge);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#getIncidentCount(Object)
*/
public int getIncidentCount(E edge)
{
return delegate.getIncidentCount(edge);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#addEdge(java.lang.Object, java.util.Collection)
*/
public boolean addEdge(E hyperedge, Collection extends V> vertices) {
return delegate.addEdge(hyperedge, vertices);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#containsEdge(java.lang.Object)
*/
public boolean containsEdge(E edge) {
return delegate.containsEdge(edge);
}
/**
* @see edu.uci.ics.jung.graph.Hypergraph#containsVertex(java.lang.Object)
*/
public boolean containsVertex(V vertex) {
return delegate.containsVertex(vertex);
}
}
@SuppressWarnings("serial")
static class UnmodifiableGraph extends UnmodifiableAbstractGraph implements Serializable {
private UnmodifiableGraph(Graph delegate) {
super(delegate);
}
}
@SuppressWarnings("serial")
static class UnmodifiableDirectedGraph extends UnmodifiableAbstractGraph
implements DirectedGraph, Serializable {
private UnmodifiableDirectedGraph(DirectedGraph delegate) {
super(delegate);
}
@Override
public V getDest(E directed_edge) {
return ((DirectedGraph)delegate).getDest(directed_edge);
}
@Override
public V getSource(E directed_edge) {
return ((DirectedGraph)delegate).getSource(directed_edge);
}
@Override
public boolean isDest(V vertex, E edge) {
return ((DirectedGraph)delegate).isDest(vertex, edge);
}
@Override
public boolean isSource(V vertex, E edge) {
return ((DirectedGraph)delegate).isSource(vertex, edge);
}
}
@SuppressWarnings("serial")
static class UnmodifiableUndirectedGraph extends UnmodifiableAbstractGraph
implements UndirectedGraph, Serializable {
private UnmodifiableUndirectedGraph(UndirectedGraph delegate) {
super(delegate);
}
}
@SuppressWarnings("serial")
static class UnmodifiableForest extends UnmodifiableGraph
implements Forest, Serializable {
private UnmodifiableForest(Forest delegate) {
super(delegate);
}
public Collection> getTrees() {
return ((Forest)delegate).getTrees();
}
public int getChildCount(V vertex)
{
return ((Forest)delegate).getChildCount(vertex);
}
public Collection getChildEdges(V vertex)
{
return ((Forest)delegate).getChildEdges(vertex);
}
public Collection getChildren(V vertex)
{
return ((Forest)delegate).getChildren(vertex);
}
public V getParent(V vertex)
{
return ((Forest)delegate).getParent(vertex);
}
public E getParentEdge(V vertex)
{
return ((Forest)delegate).getParentEdge(vertex);
}
}
@SuppressWarnings("serial")
static class UnmodifiableTree extends UnmodifiableForest
implements Tree, Serializable {
private UnmodifiableTree(Tree delegate) {
super(delegate);
}
public int getDepth(V vertex) {
return ((Tree)delegate).getDepth(vertex);
}
public int getHeight() {
return ((Tree)delegate).getHeight();
}
public V getRoot() {
return ((Tree)delegate).getRoot();
}
@Override
public Collection> getTrees() {
return ((Tree)delegate).getTrees();
}
}
}
Ads help maintain this website.