All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.salesforce.jgrapht.graph.GraphDelegator Maven / Gradle / Ivy

Go to download

This project contains the apt processor that implements all the checks enumerated in @Verify. It is a self contained, and shaded jar.

There is a newer version: 2.0.7
Show newest version
/*
 * (C) Copyright 2003-2017, by Barak Naveh and Contributors.
 *
 * JGraphT : a free Java graph-theory library
 *
 * This program and the accompanying materials are dual-licensed under
 * either
 *
 * (a) the terms of the GNU Lesser General Public License version 2.1
 * as published by the Free Software Foundation, or (at your option) any
 * later version.
 *
 * or (per the licensee's choosing)
 *
 * (b) the terms of the Eclipse Public License v1.0 as published by
 * the Eclipse Foundation.
 */
package com.salesforce.jgrapht.graph;

import java.io.*;
import java.util.*;

import com.salesforce.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. *

* * @param the graph vertex type * @param the graph edge type * * @author Barak Naveh * @since Jul 20, 2003 */ public class GraphDelegator extends AbstractGraph implements Graph, Serializable { private static final long serialVersionUID = 3257005445226181425L; /** * The graph to which operations are delegated. */ private Graph delegate; /** * 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; } /** * {@inheritDoc} */ @Override public Set getAllEdges(V sourceVertex, V targetVertex) { return delegate.getAllEdges(sourceVertex, targetVertex); } /** * {@inheritDoc} */ @Override public E getEdge(V sourceVertex, V targetVertex) { return delegate.getEdge(sourceVertex, targetVertex); } /** * {@inheritDoc} */ @Override public EdgeFactory getEdgeFactory() { return delegate.getEdgeFactory(); } /** * {@inheritDoc} */ @Override public E addEdge(V sourceVertex, V targetVertex) { return delegate.addEdge(sourceVertex, targetVertex); } /** * {@inheritDoc} */ @Override public boolean addEdge(V sourceVertex, V targetVertex, E e) { return delegate.addEdge(sourceVertex, targetVertex, e); } /** * {@inheritDoc} */ @Override public boolean addVertex(V v) { return delegate.addVertex(v); } /** * {@inheritDoc} */ @Override public boolean containsEdge(E e) { return delegate.containsEdge(e); } /** * {@inheritDoc} */ @Override public boolean containsVertex(V v) { return delegate.containsVertex(v); } /** * Returns the degree of the specified vertex. * * @param vertex vertex whose degree is to be calculated * @return the degree of the specified vertex * @see UndirectedGraph#degreeOf(Object) */ public int degreeOf(V vertex) { return ((UndirectedGraph) delegate).degreeOf(vertex); } /** * {@inheritDoc} */ @Override public Set edgeSet() { return delegate.edgeSet(); } /** * {@inheritDoc} */ @Override public Set edgesOf(V vertex) { return delegate.edgesOf(vertex); } /** * Returns the "in degree" of the specified vertex. * * @param vertex vertex whose in degree is to be calculated * @return the in degree of the specified vertex * @see DirectedGraph#inDegreeOf(Object) */ public int inDegreeOf(V vertex) { return ((DirectedGraph) delegate).inDegreeOf(vertex); } /** * Returns a set of all edges incoming into the specified vertex. * * @param vertex the vertex for which the list of incoming edges to be returned * @return a set of all edges incoming into the specified vertex * @see DirectedGraph#incomingEdgesOf(Object) */ public Set incomingEdgesOf(V vertex) { return ((DirectedGraph) delegate).incomingEdgesOf(vertex); } /** * Returns the "out degree" of the specified vertex. * * @param vertex vertex whose out degree is to be calculated * @return the out degree of the specified vertex * @see DirectedGraph#outDegreeOf(Object) */ public int outDegreeOf(V vertex) { return ((DirectedGraph) delegate).outDegreeOf(vertex); } /** * Returns a set of all edges outgoing from the specified vertex. * * @param vertex the vertex for which the list of outgoing edges to be returned * @return a set of all edges outgoing from the specified vertex * @see DirectedGraph#outgoingEdgesOf(Object) */ public Set outgoingEdgesOf(V vertex) { return ((DirectedGraph) delegate).outgoingEdgesOf(vertex); } /** * {@inheritDoc} */ @Override public boolean removeEdge(E e) { return delegate.removeEdge(e); } /** * {@inheritDoc} */ @Override public E removeEdge(V sourceVertex, V targetVertex) { return delegate.removeEdge(sourceVertex, targetVertex); } /** * {@inheritDoc} */ @Override public boolean removeVertex(V v) { return delegate.removeVertex(v); } /** * {@inheritDoc} */ @Override public String toString() { return delegate.toString(); } /** * {@inheritDoc} */ @Override public Set vertexSet() { return delegate.vertexSet(); } /** * {@inheritDoc} */ @Override public V getEdgeSource(E e) { return delegate.getEdgeSource(e); } /** * {@inheritDoc} */ @Override public V getEdgeTarget(E e) { return delegate.getEdgeTarget(e); } /** * {@inheritDoc} */ @Override public double getEdgeWeight(E e) { return delegate.getEdgeWeight(e); } /** * Assigns a weight to an edge. * * @param e edge on which to set weight * @param weight new weight for edge */ public void setEdgeWeight(E e, double weight) { ((WeightedGraph) delegate).setEdgeWeight(e, weight); } } // End GraphDelegator.java




© 2015 - 2025 Weber Informatics LLC | Privacy Policy