| 1 | /* |
| 2 | * Copyright 2008 The Closure Compiler Authors. |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.google.javascript.jscomp.graph; |
| 18 | |
| 19 | import java.util.Collection; |
| 20 | import java.util.Iterator; |
| 21 | import java.util.List; |
| 22 | |
| 23 | /** |
| 24 | * A generic undirected graph. |
| 25 | * |
| 26 | * @param <N> Value type that the graph node stores. |
| 27 | * @param <E> Value type that the graph edge stores. |
| 28 | */ |
| 29 | public abstract class UndiGraph<N, E> extends Graph<N, E> { |
| 30 | |
| 31 | /** |
| 32 | * Gets an immutable collection of all the nodes in this graph. |
| 33 | */ |
| 34 | abstract Collection<UndiGraphNode<N, E>> getUndirectedGraphNodes(); |
| 35 | |
| 36 | abstract UndiGraphNode<N, E> createUndirectedGraphNode(N nodeValue); |
| 37 | |
| 38 | public abstract UndiGraphNode<N, E> getUndirectedGraphNode(N nodeValue); |
| 39 | |
| 40 | abstract List<UndiGraphEdge<N, E>> getUndirectedGraphEdges(N n1, N n2); |
| 41 | |
| 42 | /** |
| 43 | * A generic undirected graph node. |
| 44 | * |
| 45 | * @param <N> Value type that the graph node stores. |
| 46 | * @param <E> Value type that the graph edge stores. |
| 47 | */ |
| 48 | public static interface UndiGraphNode<N, E> extends GraphNode<N, E> { |
| 49 | public List<UndiGraphEdge<N, E>> getNeighborEdges(); |
| 50 | public Iterator<UndiGraphEdge<N, E>> getNeighborEdgesIterator(); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * A generic undirected graph edge. |
| 55 | * |
| 56 | * @param <N> Value type that the graph node stores. |
| 57 | * @param <E> Value type that the graph edge stores. |
| 58 | */ |
| 59 | public static interface UndiGraphEdge<N, E> extends GraphEdge<N, E> { |
| 60 | } |
| 61 | } |