org.jgrapht.graph.GraphDelegator Maven / Gradle / Ivy
Go to download
JGraphT is a free Java graph library
that provides mathematical graph-theory objects and algorithms
The newest version!
/* ==========================================
* JGraphT : a free Java graph-theory library
* ==========================================
*
* Project Info: http://jgrapht.sourceforge.net/
* Project Creator: Barak Naveh (http://sourceforge.net/users/barak_naveh)
*
* (C) Copyright 2003-2007, by Barak Naveh and Contributors.
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation,
* Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
/* -------------------
* GraphDelegator.java
* -------------------
* (C) Copyright 2003-2007, by Barak Naveh and Contributors.
*
* Original Author: Barak Naveh
* Contributor(s): Christian Hammer
*
* $Id: GraphDelegator.java 568 2007-09-30 00:12:18Z perfecthash $
*
* Changes
* -------
* 24-Jul-2003 : Initial revision (BN);
* 11-Mar-2004 : Made generic (CH);
* 07-May-2006 : Changed from List to Set (JVS);
* 28-May-2006 : Moved connectivity info from edge to graph (JVS);
*
*/
package org.jgrapht.graph;
import java.io.*;
import java.util.*;
import org.jgrapht.*;
/**
* A graph backed by the the graph specified at the constructor, which delegates
* all its methods to the backing graph. Operations on this graph "pass through"
* to the to the backing graph. Any modification made to this graph or the
* backing graph is reflected by the other.
*
* This graph does not pass the hashCode and equals operations through
* to the backing graph, but relies on Object's equals and
* hashCode methods.
*
* This class is mostly used as a base for extending subclasses.
*
* @author Barak Naveh
* @since Jul 20, 2003
*/
public class GraphDelegator
extends AbstractGraph
implements Graph,
Serializable
{
//~ Static fields/initializers ---------------------------------------------
private static final long serialVersionUID = 3257005445226181425L;
//~ Instance fields --------------------------------------------------------
/**
* The graph to which operations are delegated.
*/
private Graph delegate;
//~ Constructors -----------------------------------------------------------
/**
* Constructor for GraphDelegator.
*
* @param g the backing graph (the delegate).
*
* @throws IllegalArgumentException iff g==null
*/
public GraphDelegator(Graph g)
{
super();
if (g == null) {
throw new IllegalArgumentException("g must not be null.");
}
delegate = g;
}
//~ Methods ----------------------------------------------------------------
/**
* @see Graph#getAllEdges(Object, Object)
*/
public Set getAllEdges(V sourceVertex, V targetVertex)
{
return delegate.getAllEdges(sourceVertex, targetVertex);
}
/**
* @see Graph#getEdge(Object, Object)
*/
public E getEdge(V sourceVertex, V targetVertex)
{
return delegate.getEdge(sourceVertex, targetVertex);
}
/**
* @see Graph#getEdgeFactory()
*/
public EdgeFactory getEdgeFactory()
{
return delegate.getEdgeFactory();
}
/**
* @see Graph#addEdge(Object, Object)
*/
public E addEdge(V sourceVertex, V targetVertex)
{
return delegate.addEdge(sourceVertex, targetVertex);
}
/**
* @see Graph#addEdge(Object, Object, Object)
*/
public boolean addEdge(V sourceVertex, V targetVertex, E e)
{
return delegate.addEdge(sourceVertex, targetVertex, e);
}
/**
* @see Graph#addVertex(Object)
*/
public boolean addVertex(V v)
{
return delegate.addVertex(v);
}
/**
* @see Graph#containsEdge(Object)
*/
public boolean containsEdge(E e)
{
return delegate.containsEdge(e);
}
/**
* @see Graph#containsVertex(Object)
*/
public boolean containsVertex(V v)
{
return delegate.containsVertex(v);
}
/**
* @see UndirectedGraph#degreeOf(Object)
*/
public int degreeOf(V vertex)
{
return ((UndirectedGraph) delegate).degreeOf(vertex);
}
/**
* @see Graph#edgeSet()
*/
public Set edgeSet()
{
return delegate.edgeSet();
}
/**
* @see Graph#edgesOf(Object)
*/
public Set edgesOf(V vertex)
{
return delegate.edgesOf(vertex);
}
/**
* @see DirectedGraph#inDegreeOf(Object)
*/
public int inDegreeOf(V vertex)
{
return ((DirectedGraph) delegate).inDegreeOf(vertex);
}
/**
* @see DirectedGraph#incomingEdgesOf(Object)
*/
public Set incomingEdgesOf(V vertex)
{
return ((DirectedGraph) delegate).incomingEdgesOf(vertex);
}
/**
* @see DirectedGraph#outDegreeOf(Object)
*/
public int outDegreeOf(V vertex)
{
return ((DirectedGraph) delegate).outDegreeOf(vertex);
}
/**
* @see DirectedGraph#outgoingEdgesOf(Object)
*/
public Set outgoingEdgesOf(V vertex)
{
return ((DirectedGraph) delegate).outgoingEdgesOf(vertex);
}
/**
* @see Graph#removeEdge(Object)
*/
public boolean removeEdge(E e)
{
return delegate.removeEdge(e);
}
/**
* @see Graph#removeEdge(Object, Object)
*/
public E removeEdge(V sourceVertex, V targetVertex)
{
return delegate.removeEdge(sourceVertex, targetVertex);
}
/**
* @see Graph#removeVertex(Object)
*/
public boolean removeVertex(V v)
{
return delegate.removeVertex(v);
}
/**
* @see java.lang.Object#toString()
*/
public String toString()
{
return delegate.toString();
}
/**
* @see Graph#vertexSet()
*/
public Set vertexSet()
{
return delegate.vertexSet();
}
/**
* @see Graph#getEdgeSource(Object)
*/
public V getEdgeSource(E e)
{
return delegate.getEdgeSource(e);
}
/**
* @see Graph#getEdgeTarget(Object)
*/
public V getEdgeTarget(E e)
{
return delegate.getEdgeTarget(e);
}
/**
* @see Graph#getEdgeWeight(Object)
*/
public double getEdgeWeight(E e)
{
return delegate.getEdgeWeight(e);
}
/**
* @see WeightedGraph#setEdgeWeight(Object, double)
*/
public void setEdgeWeight(E e, double weight)
{
((WeightedGraph) delegate).setEdgeWeight(e, weight);
}
}
// End GraphDelegator.java