View Javadoc

1   package edu.uci.ics.jung.graph.util;
2   
3   import java.io.Serializable;
4   import java.util.Collection;
5   
6   import edu.uci.ics.jung.graph.DirectedGraph;
7   import edu.uci.ics.jung.graph.Forest;
8   import edu.uci.ics.jung.graph.Graph;
9   import edu.uci.ics.jung.graph.Tree;
10  import edu.uci.ics.jung.graph.UndirectedGraph;
11  /**
12   * Provides specialized implementations of <code>GraphDecorator</code>.  Currently these 
13   * wrapper types include "synchronized" and "unmodifiable".
14   *
15   * <p>The methods of this class may each throw a <code>NullPointerException</code>
16   * if the graphs or class objects provided to them are null.
17   *
18   * @author Tom Nelson
19   */
20  
21  public class Graphs {
22  	
23  	/**
24  	 * Returns a synchronized graph backed by the passed argument graph.
25  	 * @param <V> the vertex type
26  	 * @param <E> the edge type
27  	 * @param graph the graph for which a synchronized wrapper is to be created
28  	 * @return a synchronized graph backed by the passed argument graph
29  	 */
30  	public static <V,E> Graph<V,E> synchronizedGraph(Graph<V,E> graph) {
31  		return new SynchronizedGraph<V,E>(graph);
32  	}
33  	
34  	/**
35  	 * Returns a synchronized DirectedGraph backed by the passed DirectedGraph.
36       * @param <V> the vertex type
37       * @param <E> the edge type
38       * @param graph the graph for which a synchronized wrapper is to be created
39  	 * @return a synchronized DirectedGraph backed by the passed DirectedGraph
40  	 */
41  	public static <V,E> DirectedGraph<V,E> synchronizedDirectedGraph(DirectedGraph<V,E> graph) {
42  		return new SynchronizedDirectedGraph<V,E>(graph);
43  	}
44  	
45  	/**
46  	 * Returns a synchronized UndirectedGraph backed by the passed UndirectedGraph.
47       * @param <V> the vertex type
48       * @param <E> the edge type
49       * @param graph the graph for which a synchronized wrapper is to be created
50  	 * @return a synchronized UndirectedGraph backed by the passed UndirectedGraph
51  	 */
52  	public static <V,E> UndirectedGraph<V,E> synchronizedUndirectedGraph(UndirectedGraph<V,E> graph) {
53  		return new SynchronizedUndirectedGraph<V,E>(graph);
54  	}
55  	
56  	/**
57  	 * Returns a synchronized Forest backed by the passed Forest.
58       * @param <V> the vertex type
59       * @param <E> the edge type
60       * @param forest the forest for which a synchronized wrapper is to be created
61  	 * @return a synchronized Forest backed by the passed Forest
62  	 */
63  	public static <V,E> SynchronizedForest<V,E> synchronizedForest(Forest<V,E> forest) {
64  		return new SynchronizedForest<V,E>(forest);
65  	}
66  	
67  	/**
68  	 * Returns a synchronized Tree backed by the passed Tree.
69       * @param <V> the vertex type
70       * @param <E> the edge type
71       * @param tree the tree for which a synchronized wrapper is to be created
72  	 * @return a synchronized Tree backed by the passed Tree
73  	 */
74  	public static <V,E> SynchronizedTree<V,E> synchronizedTree(Tree<V,E> tree) {
75  		return new SynchronizedTree<V,E>(tree);
76  	}
77  	
78  	/**
79  	 * Returns an unmodifiable Graph backed by the passed Graph.
80       * @param <V> the vertex type
81       * @param <E> the edge type
82       * @param graph the graph for which the unmodifiable wrapper is to be returned
83  	 * @return an unmodifiable Graph backed by the passed Graph
84  	 */
85  	public static <V,E> Graph<V,E> unmodifiableGraph(Graph<V,E> graph) {
86  		return new UnmodifiableGraph<V,E>(graph);
87  	}
88  	
89  	/**
90  	 * Returns an unmodifiable <code>DirectedGraph</code> backed by the passed graph.
91  	 * @param <V> the vertex type
92  	 * @param <E> the edge type
93  	 * @param graph the graph for which the unmodifiable wrapper is to be returned
94  	 * @return an unmodifiable <code>DirectedGraph</code> backed by the passed graph
95  	 */
96  	public static <V,E> DirectedGraph<V,E> unmodifiableDirectedGraph(DirectedGraph<V,E> graph) {
97  		return new UnmodifiableDirectedGraph<V,E>(graph);
98  	}
99  	
100 	/**
101 	 * Returns an unmodifiable <code>UndirectedGraph</code> backed by the passed graph.
102 	 * @param <V> the vertex type
103 	 * @param <E> the edge type
104 	 * @param graph the graph for which the unmodifiable wrapper is to be returned
105 	 * @return an unmodifiable <code>UndirectedGraph</code> backed by the passed graph
106 	 */
107 	public static <V,E> UndirectedGraph<V,E> unmodifiableUndirectedGraph(UndirectedGraph<V,E> graph) {
108 		return new UnmodifiableUndirectedGraph<V,E>(graph);
109 	}
110 	
111 	/**
112      * Returns an unmodifiable <code>Tree</code> backed by the passed tree.
113      * @param <V> the vertex type
114      * @param <E> the edge type
115      * @param tree the tree for which the unmodifiable wrapper is to be returned
116      * @return an unmodifiable <code>Tree</code> backed by the passed tree
117 	 */
118 	public static <V,E> UnmodifiableTree<V,E> unmodifiableTree(Tree<V,E> tree) {
119 		return new UnmodifiableTree<V,E>(tree);
120 	}
121 	
122     /**
123      * Returns an unmodifiable <code>Forest</code> backed by the passed forest.
124      * @param <V> the vertex type
125      * @param <E> the edge type
126      * @param forest the forest for which the unmodifiable wrapper is to be returned
127      * @return an unmodifiable <code>Forest</code> backed by the passed forest
128      */
129 	public static <V,E> UnmodifiableForest<V,E> unmodifiableForest(Forest<V,E> forest) {
130 		return new UnmodifiableForest<V,E>(forest);
131 	}
132 	
133 	
134 	@SuppressWarnings("serial")
135 	static abstract class SynchronizedAbstractGraph<V,E> implements Graph<V,E>, Serializable {
136 		protected Graph<V,E> delegate;
137 
138 		private SynchronizedAbstractGraph(Graph<V, E> delegate) {
139 			if(delegate == null) {
140 				throw new NullPointerException();
141 			}
142 			this.delegate = delegate;
143 		}
144 
145 		/**
146 		 * @see edu.uci.ics.jung.graph.Graph#getDefaultEdgeType()
147 		 */
148 		public EdgeType getDefaultEdgeType()
149 		{
150 			return delegate.getDefaultEdgeType();
151 		}
152 		
153 		/**
154 		 * @see edu.uci.ics.jung.graph.Graph#addEdge(Object, Object, Object, EdgeType)
155 		 */
156 		public synchronized boolean addEdge(E e, V v1, V v2, EdgeType edgeType) {
157 			return delegate.addEdge(e, v1, v2, edgeType);
158 		}
159 
160         /**
161          * @see edu.uci.ics.jung.graph.Hypergraph#addEdge(Object, Collection, EdgeType)
162          */
163 		public synchronized boolean addEdge(E e, Collection<? extends V> 
164 			vertices, EdgeType edgeType) 
165 		{
166 			return delegate.addEdge(e, vertices, edgeType);
167 		}
168 		
169 		/**
170 		 * @see edu.uci.ics.jung.graph.Graph#addEdge(Object, Object, Object)
171 		 */
172 		public synchronized boolean addEdge(E e, V v1, V v2) {
173 			return delegate.addEdge(e, v1, v2);
174 		}
175 
176 		/**
177 		 * @see edu.uci.ics.jung.graph.Hypergraph#addVertex(java.lang.Object)
178 		 */
179 		public synchronized boolean addVertex(V vertex) {
180 			return delegate.addVertex(vertex);
181 		}
182 
183 		/**
184 		 * @see edu.uci.ics.jung.graph.Hypergraph#isIncident(java.lang.Object, java.lang.Object)
185 		 */
186 		public synchronized boolean isIncident(V vertex, E edge) {
187 			return delegate.isIncident(vertex, edge);
188 		}
189 
190 		/**
191 		 * @see edu.uci.ics.jung.graph.Hypergraph#isNeighbor(java.lang.Object, java.lang.Object)
192 		 */
193 		public synchronized boolean isNeighbor(V v1, V v2) {
194 			return delegate.isNeighbor(v1, v2);
195 		}
196 
197 		/**
198 		 * @see edu.uci.ics.jung.graph.Hypergraph#degree(java.lang.Object)
199 		 */
200 		public synchronized int degree(V vertex) {
201 			return delegate.degree(vertex);
202 		}
203 
204 		/**
205 		 * @see edu.uci.ics.jung.graph.Hypergraph#findEdge(java.lang.Object, java.lang.Object)
206 		 */
207 		public synchronized E findEdge(V v1, V v2) {
208 			return delegate.findEdge(v1, v2);
209 		}
210 
211         /**
212          * @see edu.uci.ics.jung.graph.Hypergraph#findEdgeSet(java.lang.Object, java.lang.Object)
213          */
214         public synchronized Collection<E> findEdgeSet(V v1, V v2)
215         {
216             return delegate.findEdgeSet(v1, v2);
217         }
218         
219 		/**
220 		 * @see edu.uci.ics.jung.graph.Hypergraph#getEdges()
221 		 */
222 		public synchronized Collection<E> getEdges() {
223 			return delegate.getEdges();
224 		}
225 
226 		/**
227 		 * @see edu.uci.ics.jung.graph.Graph#getEdges(EdgeType)
228 		 */
229 		public synchronized Collection<E> getEdges(EdgeType edgeType) {
230 			return delegate.getEdges(edgeType);
231 		}
232 
233 		/**
234 		 * @see edu.uci.ics.jung.graph.Graph#getEndpoints(java.lang.Object)
235 		 */
236 		public synchronized Pair<V> getEndpoints(E edge) {
237 			return delegate.getEndpoints(edge);
238 		}
239 
240 		/**
241 		 * @see edu.uci.ics.jung.graph.Hypergraph#getIncidentEdges(java.lang.Object)
242 		 */
243 		public synchronized Collection<E> getIncidentEdges(V vertex) {
244 			return delegate.getIncidentEdges(vertex);
245 		}
246 
247 		/**
248 		 * @see edu.uci.ics.jung.graph.Hypergraph#getIncidentVertices(java.lang.Object)
249 		 */
250 		public synchronized Collection<V> getIncidentVertices(E edge) {
251 			return delegate.getIncidentVertices(edge);
252 		}
253 
254 		/**
255 		 * @see edu.uci.ics.jung.graph.Graph#getInEdges(java.lang.Object)
256 		 */
257 		public synchronized Collection<E> getInEdges(V vertex) {
258 			return delegate.getInEdges(vertex);
259 		}
260 
261 		/**
262 		 * @see edu.uci.ics.jung.graph.Hypergraph#getNeighbors(java.lang.Object)
263 		 */
264 		public synchronized Collection<V> getNeighbors(V vertex) {
265 			return delegate.getNeighbors(vertex);
266 		}
267 
268 		/**
269 		 * @see edu.uci.ics.jung.graph.Graph#getOpposite(java.lang.Object, java.lang.Object)
270 		 */
271 		public synchronized V getOpposite(V vertex, E edge) {
272 			return delegate.getOpposite(vertex, edge);
273 		}
274 
275 		/**
276 		 * @see edu.uci.ics.jung.graph.Graph#getOutEdges(java.lang.Object)
277 		 */
278 		public synchronized Collection<E> getOutEdges(V vertex) {
279 			return delegate.getOutEdges(vertex);
280 		}
281 
282 		/**
283 		 * @see edu.uci.ics.jung.graph.Graph#getPredecessors(java.lang.Object)
284 		 */
285 		public synchronized Collection<V> getPredecessors(V vertex) {
286 			return delegate.getPredecessors(vertex);
287 		}
288 
289 		/**
290 		 * @see edu.uci.ics.jung.graph.Graph#getSuccessors(java.lang.Object)
291 		 */
292 		public synchronized Collection<V> getSuccessors(V vertex) {
293 			return delegate.getSuccessors(vertex);
294 		}
295 
296 		/**
297 		 * @see edu.uci.ics.jung.graph.Hypergraph#getVertices()
298 		 */
299 		public synchronized Collection<V> getVertices() {
300 			return delegate.getVertices();
301 		}
302 
303 		/**
304 		 * @see edu.uci.ics.jung.graph.Hypergraph#getEdgeCount()
305 		 */
306 		public synchronized int getEdgeCount() {
307 			return delegate.getEdgeCount();
308 		}
309 
310 		/**
311 		 * @see edu.uci.ics.jung.graph.Hypergraph#getEdgeCount(EdgeType)
312 		 */
313 		public synchronized int getEdgeCount(EdgeType edge_type) 
314 		{
315 		    return delegate.getEdgeCount(edge_type);
316 		}
317 		
318 		/**
319 		 * @see edu.uci.ics.jung.graph.Hypergraph#getVertexCount()
320 		 */
321 		public synchronized int getVertexCount() {
322 			return delegate.getVertexCount();
323 		}
324 
325 		/**
326 		 * @see edu.uci.ics.jung.graph.Graph#inDegree(java.lang.Object)
327 		 */
328 		public synchronized int inDegree(V vertex) {
329 			return delegate.inDegree(vertex);
330 		}
331 
332 		/**
333 		 * @see edu.uci.ics.jung.graph.Graph#getEdgeType(java.lang.Object)
334 		 */
335 		public synchronized EdgeType getEdgeType(E edge) {
336 			return delegate.getEdgeType(edge);
337 		}
338 
339 		/**
340 		 * @see edu.uci.ics.jung.graph.Graph#isPredecessor(java.lang.Object, java.lang.Object)
341 		 */
342 		public synchronized boolean isPredecessor(V v1, V v2) {
343 			return delegate.isPredecessor(v1, v2);
344 		}
345 
346 		/**
347 		 * @see edu.uci.ics.jung.graph.Graph#isSuccessor(java.lang.Object, java.lang.Object)
348 		 */
349 		public synchronized boolean isSuccessor(V v1, V v2) {
350 			return delegate.isSuccessor(v1, v2);
351 		}
352 
353 		/**
354 		 * @see edu.uci.ics.jung.graph.Hypergraph#getNeighborCount(java.lang.Object)
355 		 */
356 		public synchronized int getNeighborCount(V vertex) {
357 			return delegate.getNeighborCount(vertex);
358 		}
359 
360 		/**
361 		 * @see edu.uci.ics.jung.graph.Graph#getPredecessorCount(java.lang.Object)
362 		 */
363 		public synchronized int getPredecessorCount(V vertex) {
364 			return delegate.getPredecessorCount(vertex);
365 		}
366 
367 		/**
368 		 * @see edu.uci.ics.jung.graph.Graph#getSuccessorCount(java.lang.Object)
369 		 */
370 		public synchronized int getSuccessorCount(V vertex) {
371 			return delegate.getSuccessorCount(vertex);
372 		}
373 
374 		/**
375 		 * @see edu.uci.ics.jung.graph.Graph#outDegree(java.lang.Object)
376 		 */
377 		public synchronized int outDegree(V vertex) {
378 			return delegate.outDegree(vertex);
379 		}
380 
381 		/**
382 		 * @see edu.uci.ics.jung.graph.Hypergraph#removeEdge(java.lang.Object)
383 		 */
384 		public synchronized boolean removeEdge(E edge) {
385 			return delegate.removeEdge(edge);
386 		}
387 
388 		/**
389 		 * @see edu.uci.ics.jung.graph.Hypergraph#removeVertex(java.lang.Object)
390 		 */
391 		public synchronized boolean removeVertex(V vertex) {
392 			return delegate.removeVertex(vertex);
393 		}
394 
395 		/**
396 		 * @see edu.uci.ics.jung.graph.Graph#getDest(java.lang.Object)
397 		 */
398 		public synchronized V getDest(E directed_edge) {
399 			return delegate.getDest(directed_edge);
400 		}
401 
402 		/**
403 		 * @see edu.uci.ics.jung.graph.Graph#getSource(java.lang.Object)
404 		 */
405 		public synchronized V getSource(E directed_edge) {
406 			return delegate.getSource(directed_edge);
407 		}
408 
409 		/**
410 		 * @see edu.uci.ics.jung.graph.Graph#isDest(java.lang.Object, java.lang.Object)
411 		 */
412 		public synchronized boolean isDest(V vertex, E edge) {
413 			return delegate.isDest(vertex, edge);
414 		}
415 
416 		/**
417 		 * @see edu.uci.ics.jung.graph.Graph#isSource(java.lang.Object, java.lang.Object)
418 		 */
419 		public synchronized boolean isSource(V vertex, E edge) {
420 			return delegate.isSource(vertex, edge);
421 		}
422 		
423 		/**
424 		 * @see edu.uci.ics.jung.graph.Hypergraph#getIncidentCount(Object)
425 		 */
426         public synchronized int getIncidentCount(E edge)
427         {
428             return delegate.getIncidentCount(edge);
429         }
430 
431 		/**
432 		 * @see edu.uci.ics.jung.graph.Hypergraph#addEdge(java.lang.Object, java.util.Collection)
433 		 */
434 		public synchronized boolean addEdge(E hyperedge, Collection<? extends V> vertices) {
435 			return delegate.addEdge(hyperedge, vertices);
436 		}
437 
438 		/**
439 		 * @see edu.uci.ics.jung.graph.Hypergraph#containsEdge(java.lang.Object)
440 		 */
441 		public synchronized boolean containsEdge(E edge) {
442 			return delegate.containsEdge(edge);
443 		}
444 
445 		/**
446 		 * @see edu.uci.ics.jung.graph.Hypergraph#containsVertex(java.lang.Object)
447 		 */
448 		public synchronized boolean containsVertex(V vertex) {
449 			return delegate.containsVertex(vertex);
450 		}
451         
452 	}
453 	
454 	@SuppressWarnings("serial")
455     static class SynchronizedGraph<V,E> extends SynchronizedAbstractGraph<V,E> implements Serializable {
456 		
457 		private SynchronizedGraph(Graph<V,E> delegate) {
458 			super(delegate);
459 		}
460 	}
461 	
462 	@SuppressWarnings("serial")
463     static class SynchronizedUndirectedGraph<V,E> extends SynchronizedAbstractGraph<V,E> 
464 		implements UndirectedGraph<V,E>, Serializable {
465 		private SynchronizedUndirectedGraph(UndirectedGraph<V,E> delegate) {
466 			super(delegate);
467 		}
468 	}
469 	
470 	@SuppressWarnings("serial")
471     static class SynchronizedDirectedGraph<V,E> extends SynchronizedAbstractGraph<V,E> 
472 		implements DirectedGraph<V,E>, Serializable {
473 		
474 		private SynchronizedDirectedGraph(DirectedGraph<V,E> delegate) {
475 			super(delegate);
476 		}
477 
478 		@Override
479 	    public synchronized V getDest(E directed_edge) {
480 			return ((DirectedGraph<V,E>)delegate).getDest(directed_edge);
481 		}
482 
483 		@Override
484     	public synchronized V getSource(E directed_edge) {
485 			return ((DirectedGraph<V,E>)delegate).getSource(directed_edge);
486 		}
487 
488 		@Override
489 	    public synchronized boolean isDest(V vertex, E edge) {
490 			return ((DirectedGraph<V,E>)delegate).isDest(vertex, edge);
491 		}
492 
493 		@Override
494     	public synchronized boolean isSource(V vertex, E edge) {
495 			return ((DirectedGraph<V,E>)delegate).isSource(vertex, edge);
496 		}
497 	}
498 	
499 	@SuppressWarnings("serial")
500     static class SynchronizedTree<V,E> extends SynchronizedForest<V,E> implements Tree<V,E> {
501 
502 		/**
503 		 * Creates a new instance based on the provided {@code delegate}.
504 		 * @param delegate
505 		 */
506 		public SynchronizedTree(Tree<V, E> delegate) {
507 			super(delegate);
508 		}
509 
510 		public synchronized int getDepth(V vertex) {
511 			return ((Tree<V,E>)delegate).getDepth(vertex);
512 		}
513 
514 		public synchronized int getHeight() {
515 			return ((Tree<V,E>)delegate).getHeight();
516 		}
517 
518 		public synchronized V getRoot() {
519 			return ((Tree<V,E>)delegate).getRoot();
520 		}
521 	}
522 	
523 	@SuppressWarnings("serial")
524     static class SynchronizedForest<V,E> extends SynchronizedDirectedGraph<V,E> implements Forest<V,E> {
525 
526         /**
527          * Creates a new instance based on the provided {@code delegate}.
528          * @param delegate
529          */
530 		public SynchronizedForest(Forest<V, E> delegate) {
531 			super(delegate);
532 		}
533 
534 		public synchronized Collection<Tree<V, E>> getTrees() {
535 			return ((Forest<V,E>)delegate).getTrees();
536 		}
537 
538         public int getChildCount(V vertex)
539         {
540             return ((Forest<V,E>)delegate).getChildCount(vertex);
541         }
542 
543         public Collection<E> getChildEdges(V vertex)
544         {
545             return ((Forest<V,E>)delegate).getChildEdges(vertex);
546         }
547 
548         public Collection<V> getChildren(V vertex)
549         {
550             return ((Forest<V,E>)delegate).getChildren(vertex);
551         }
552 
553         public V getParent(V vertex)
554         {
555             return ((Forest<V,E>)delegate).getParent(vertex);
556         }
557 
558         public E getParentEdge(V vertex)
559         {
560             return ((Forest<V,E>)delegate).getParentEdge(vertex);
561         }
562 	}
563 	
564 	@SuppressWarnings("serial")
565 	static abstract class UnmodifiableAbstractGraph<V,E> implements Graph<V,E>, Serializable {
566 		protected Graph<V,E> delegate;
567 
568 
569 		private UnmodifiableAbstractGraph(Graph<V, E> delegate) {
570 			if(delegate == null) {
571 				throw new NullPointerException();
572 			}
573 			this.delegate = delegate;
574 		}
575 
576 		/**
577 		 * @see edu.uci.ics.jung.graph.Graph#getDefaultEdgeType()
578 		 */
579 		public EdgeType getDefaultEdgeType()
580 		{
581 			return delegate.getDefaultEdgeType();
582 		}
583 		
584 		/**
585 		 * @see edu.uci.ics.jung.graph.Graph#addEdge(Object, Object, Object, EdgeType)
586 		 */
587 		public boolean addEdge(E e, V v1, V v2, EdgeType edgeType) {
588 			throw new UnsupportedOperationException();
589 		}
590 
591         /**
592          * @see edu.uci.ics.jung.graph.Graph#addEdge(Object, Collection, EdgeType)
593          */
594 		public boolean addEdge(E e, Collection<? extends V> vertices, 
595 			EdgeType edgeType) 
596 		{
597 			throw new UnsupportedOperationException();
598 		}
599 		
600         /**
601          * @see edu.uci.ics.jung.graph.Graph#addEdge(Object, Object, Object)
602          */
603 		public boolean addEdge(E e, V v1, V v2) {
604 			throw new UnsupportedOperationException();
605 		}
606 
607 		/**
608 		 * @see edu.uci.ics.jung.graph.Hypergraph#addVertex(java.lang.Object)
609 		 */
610 		public boolean addVertex(V vertex) {
611 			throw new UnsupportedOperationException();
612 		}
613 
614 		/**
615 		 * @see edu.uci.ics.jung.graph.Hypergraph#isIncident(java.lang.Object, java.lang.Object)
616 		 */
617 		public boolean isIncident(V vertex, E edge) {
618 			return delegate.isIncident(vertex, edge);
619 		}
620 
621 		/**
622 		 * @see edu.uci.ics.jung.graph.Hypergraph#isNeighbor(java.lang.Object, java.lang.Object)
623 		 */
624 		public boolean isNeighbor(V v1, V v2) {
625 			return delegate.isNeighbor(v1, v2);
626 		}
627 
628 		/**
629 		 * @see edu.uci.ics.jung.graph.Hypergraph#degree(java.lang.Object)
630 		 */
631 		public int degree(V vertex) {
632 			return delegate.degree(vertex);
633 		}
634 
635 		/**
636 		 * @see edu.uci.ics.jung.graph.Hypergraph#findEdge(java.lang.Object, java.lang.Object)
637 		 */
638 		public E findEdge(V v1, V v2) {
639 			return delegate.findEdge(v1, v2);
640 		}
641         
642         /**
643          * @see edu.uci.ics.jung.graph.Hypergraph#findEdgeSet(java.lang.Object, java.lang.Object)
644          */
645         public Collection<E> findEdgeSet(V v1, V v2)
646         {
647             return delegate.findEdgeSet(v1, v2);
648         }
649 
650 		/**
651 		 * @see edu.uci.ics.jung.graph.Hypergraph#getEdges()
652 		 */
653 		public Collection<E> getEdges() {
654 			return delegate.getEdges();
655 		}
656 
657 		/**
658 		 * @see edu.uci.ics.jung.graph.Hypergraph#getEdgeCount()
659 		 */
660 		public int getEdgeCount() {
661 			return delegate.getEdgeCount();
662 		}
663 
664         /**
665          * @see edu.uci.ics.jung.graph.Hypergraph#getEdgeCount(EdgeType)
666          */
667         public int getEdgeCount(EdgeType edge_type) 
668         {
669             return delegate.getEdgeCount(edge_type);
670         }
671 
672 		/**
673 		 * @see edu.uci.ics.jung.graph.Hypergraph#getVertexCount()
674 		 */
675 		public int getVertexCount() {
676 			return delegate.getVertexCount();
677 		}
678 
679 		/**
680 		 * @see edu.uci.ics.jung.graph.Graph#getEdges(edu.uci.ics.jung.graph.util.EdgeType)
681 		 */
682 		public Collection<E> getEdges(EdgeType edgeType) {
683 			return delegate.getEdges(edgeType);
684 		}
685 
686 		/**
687 		 * @see edu.uci.ics.jung.graph.Graph#getEndpoints(java.lang.Object)
688 		 */
689 		public Pair<V> getEndpoints(E edge) {
690 			return delegate.getEndpoints(edge);
691 		}
692 
693 		/**
694 		 * @see edu.uci.ics.jung.graph.Hypergraph#getIncidentEdges(java.lang.Object)
695 		 */
696 		public Collection<E> getIncidentEdges(V vertex) {
697 			return delegate.getIncidentEdges(vertex);
698 		}
699 
700 		/**
701 		 * @see edu.uci.ics.jung.graph.Hypergraph#getIncidentVertices(java.lang.Object)
702 		 */
703 		public Collection<V> getIncidentVertices(E edge) {
704 			return delegate.getIncidentVertices(edge);
705 		}
706 
707 		/**
708 		 * @see edu.uci.ics.jung.graph.Graph#getInEdges(java.lang.Object)
709 		 */
710 		public Collection<E> getInEdges(V vertex) {
711 			return delegate.getInEdges(vertex);
712 		}
713 
714 		/**
715 		 * @see edu.uci.ics.jung.graph.Hypergraph#getNeighbors(java.lang.Object)
716 		 */
717 		public Collection<V> getNeighbors(V vertex) {
718 			return delegate.getNeighbors(vertex);
719 		}
720 
721 		/**
722 		 * @see edu.uci.ics.jung.graph.Graph#getOpposite(java.lang.Object, java.lang.Object)
723 		 */
724 		public V getOpposite(V vertex, E edge) {
725 			return delegate.getOpposite(vertex, edge);
726 		}
727 
728 		/**
729 		 * @see edu.uci.ics.jung.graph.Graph#getOutEdges(java.lang.Object)
730 		 */
731 		public Collection<E> getOutEdges(V vertex) {
732 			return delegate.getOutEdges(vertex);
733 		}
734 
735 		/**
736 		 * @see edu.uci.ics.jung.graph.Graph#getPredecessors(java.lang.Object)
737 		 */
738 		public Collection<V> getPredecessors(V vertex) {
739 			return delegate.getPredecessors(vertex);
740 		}
741 
742 		/**
743 		 * @see edu.uci.ics.jung.graph.Graph#getSuccessors(java.lang.Object)
744 		 */
745 		public Collection<V> getSuccessors(V vertex) {
746 			return delegate.getSuccessors(vertex);
747 		}
748 
749 		/**
750 		 * @see edu.uci.ics.jung.graph.Hypergraph#getVertices()
751 		 */
752 		public Collection<V> getVertices() {
753 			return delegate.getVertices();
754 		}
755 
756 		/**
757 		 * @see edu.uci.ics.jung.graph.Graph#inDegree(java.lang.Object)
758 		 */
759 		public int inDegree(V vertex) {
760 			return delegate.inDegree(vertex);
761 		}
762 
763 		/**
764 		 * @see edu.uci.ics.jung.graph.Graph#getEdgeType(java.lang.Object)
765 		 */
766 		public EdgeType getEdgeType(E edge) {
767 			return delegate.getEdgeType(edge);
768 		}
769 
770 		/**
771 		 * @see edu.uci.ics.jung.graph.Graph#isPredecessor(java.lang.Object, java.lang.Object)
772 		 */
773 		public boolean isPredecessor(V v1, V v2) {
774 			return delegate.isPredecessor(v1, v2);
775 		}
776 
777 		/**
778 		 * @see edu.uci.ics.jung.graph.Graph#isSuccessor(java.lang.Object, java.lang.Object)
779 		 */
780 		public boolean isSuccessor(V v1, V v2) {
781 			return delegate.isSuccessor(v1, v2);
782 		}
783 
784 		/**
785 		 * @see edu.uci.ics.jung.graph.Hypergraph#getNeighborCount(java.lang.Object)
786 		 */
787 		public int getNeighborCount(V vertex) {
788 			return delegate.getNeighborCount(vertex);
789 		}
790 
791 		/**
792 		 * @see edu.uci.ics.jung.graph.Graph#getPredecessorCount(java.lang.Object)
793 		 */
794 		public int getPredecessorCount(V vertex) {
795 			return delegate.getPredecessorCount(vertex);
796 		}
797 
798 		/**
799 		 * @see edu.uci.ics.jung.graph.Graph#getSuccessorCount(java.lang.Object)
800 		 */
801 		public int getSuccessorCount(V vertex) {
802 			return delegate.getSuccessorCount(vertex);
803 		}
804 
805 		/**
806 		 * @see edu.uci.ics.jung.graph.Graph#outDegree(java.lang.Object)
807 		 */
808 		public int outDegree(V vertex) {
809 			return delegate.outDegree(vertex);
810 		}
811 
812 		/**
813 		 * @see edu.uci.ics.jung.graph.Hypergraph#removeEdge(java.lang.Object)
814 		 */
815 		public boolean removeEdge(E edge) {
816 			throw new UnsupportedOperationException();
817 		}
818 
819 		/**
820 		 * @see edu.uci.ics.jung.graph.Hypergraph#removeVertex(java.lang.Object)
821 		 */
822 		public boolean removeVertex(V vertex) {
823 			throw new UnsupportedOperationException();
824 		}
825 		
826 		/**
827 		 * @see edu.uci.ics.jung.graph.Graph#getDest(java.lang.Object)
828 		 */
829 		public V getDest(E directed_edge) {
830 			return delegate.getDest(directed_edge);
831 		}
832 
833 		/**
834 		 * @see edu.uci.ics.jung.graph.Graph#getSource(java.lang.Object)
835 		 */
836 		public V getSource(E directed_edge) {
837 			return delegate.getSource(directed_edge);
838 		}
839 
840 		/**
841 		 * @see edu.uci.ics.jung.graph.Graph#isDest(java.lang.Object, java.lang.Object)
842 		 */
843 		public boolean isDest(V vertex, E edge) {
844 			return delegate.isDest(vertex, edge);
845 		}
846 
847 		/**
848 		 * @see edu.uci.ics.jung.graph.Graph#isSource(java.lang.Object, java.lang.Object)
849 		 */
850 		public boolean isSource(V vertex, E edge) {
851 			return delegate.isSource(vertex, edge);
852 		}
853 
854 		/**
855 		 * @see edu.uci.ics.jung.graph.Hypergraph#getIncidentCount(Object)
856 		 */
857         public int getIncidentCount(E edge)
858         {
859             return delegate.getIncidentCount(edge);
860         }
861 
862 		/**
863 		 * @see edu.uci.ics.jung.graph.Hypergraph#addEdge(java.lang.Object, java.util.Collection)
864 		 */
865 		public boolean addEdge(E hyperedge, Collection<? extends V> vertices) {
866 			return delegate.addEdge(hyperedge, vertices);
867 		}
868 
869 		/**
870 		 * @see edu.uci.ics.jung.graph.Hypergraph#containsEdge(java.lang.Object)
871 		 */
872 		public boolean containsEdge(E edge) {
873 			return delegate.containsEdge(edge);
874 		}
875 
876 		/**
877 		 * @see edu.uci.ics.jung.graph.Hypergraph#containsVertex(java.lang.Object)
878 		 */
879 		public boolean containsVertex(V vertex) {
880 			return delegate.containsVertex(vertex);
881 		}
882 	}
883 	
884 	@SuppressWarnings("serial")
885     static class UnmodifiableGraph<V,E> extends UnmodifiableAbstractGraph<V,E> implements Serializable {
886 		private UnmodifiableGraph(Graph<V,E> delegate) {
887 			super(delegate);
888 		}
889 	}
890 	
891 	@SuppressWarnings("serial")
892     static class UnmodifiableDirectedGraph<V,E> extends UnmodifiableAbstractGraph<V,E> 
893 		implements DirectedGraph<V,E>, Serializable {
894 		private UnmodifiableDirectedGraph(DirectedGraph<V,E> delegate) {
895 			super(delegate);
896 		}
897 
898 		@Override
899 	    public V getDest(E directed_edge) {
900 			return ((DirectedGraph<V,E>)delegate).getDest(directed_edge);
901 		}
902 
903 		@Override
904     	public V getSource(E directed_edge) {
905 			return ((DirectedGraph<V,E>)delegate).getSource(directed_edge);
906 		}
907 
908 		@Override
909     	public boolean isDest(V vertex, E edge) {
910 			return ((DirectedGraph<V,E>)delegate).isDest(vertex, edge);
911 		}
912 
913 		@Override
914     	public boolean isSource(V vertex, E edge) {
915 			return ((DirectedGraph<V,E>)delegate).isSource(vertex, edge);
916 		}
917 	}
918 	
919 	@SuppressWarnings("serial")
920     static class UnmodifiableUndirectedGraph<V,E> extends UnmodifiableAbstractGraph<V,E> 
921 		implements UndirectedGraph<V,E>, Serializable {
922 		private UnmodifiableUndirectedGraph(UndirectedGraph<V,E> delegate) {
923 			super(delegate);
924 		}
925 	}
926 	
927 	@SuppressWarnings("serial")
928     static class UnmodifiableForest<V,E> extends UnmodifiableGraph<V,E>
929 		implements Forest<V,E>, Serializable {
930 		private UnmodifiableForest(Forest<V,E> delegate) {
931 			super(delegate);
932 		}
933 
934 		public Collection<Tree<V, E>> getTrees() {
935 			return ((Forest<V,E>)delegate).getTrees();
936 		}
937 
938         public int getChildCount(V vertex)
939         {
940             return ((Forest<V,E>)delegate).getChildCount(vertex);
941         }
942 
943         public Collection<E> getChildEdges(V vertex)
944         {
945             return ((Forest<V,E>)delegate).getChildEdges(vertex);
946         }
947 
948         public Collection<V> getChildren(V vertex)
949         {
950             return ((Forest<V,E>)delegate).getChildren(vertex);
951         }
952 
953         public V getParent(V vertex)
954         {
955             return ((Forest<V,E>)delegate).getParent(vertex);
956         }
957 
958         public E getParentEdge(V vertex)
959         {
960             return ((Forest<V,E>)delegate).getParentEdge(vertex);
961         }
962 	}
963 	
964 	@SuppressWarnings("serial")
965     static class UnmodifiableTree<V,E> extends UnmodifiableForest<V,E>
966 	     implements Tree<V,E>, Serializable {
967 		private UnmodifiableTree(Tree<V,E> delegate) {
968 			super(delegate);
969 		}
970 
971 		public int getDepth(V vertex) {
972 			return ((Tree<V,E>)delegate).getDepth(vertex);
973 		}
974 
975 		public int getHeight() {
976 			return ((Tree<V,E>)delegate).getHeight();
977 		}
978 
979 		public V getRoot() {
980 			return ((Tree<V,E>)delegate).getRoot();
981 		}
982 
983 		@Override
984     	public Collection<Tree<V, E>> getTrees() {
985 			return ((Tree<V,E>)delegate).getTrees();
986 		}
987 	}
988 
989 }