001    package org.apache.commons.graph;
002    
003    /*
004     * Licensed to the Apache Software Foundation (ASF) under one
005     * or more contributor license agreements.  See the NOTICE file
006     * distributed with this work for additional information
007     * regarding copyright ownership.  The ASF licenses this file
008     * to you under the Apache License, Version 2.0 (the
009     * "License"); you may not use this file except in compliance
010     * with the License.  You may obtain a copy of the License at
011     *
012     *   http://www.apache.org/licenses/LICENSE-2.0
013     *
014     * Unless required by applicable law or agreed to in writing,
015     * software distributed under the License is distributed on an
016     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017     * KIND, either express or implied.  See the License for the
018     * specific language governing permissions and limitations
019     * under the License.
020     */
021    
022    import java.util.Set;
023    
024    /**
025     * A Graph data structure consists of a finite (and possibly mutable) set of ordered pairs,
026     * called {@link Edge}s or arcs, of certain entities called {@link Vertex} or node.
027     * As in mathematics, an {@link Edge} {@code (x,y)} is said to point or go from {@code x} to {@code y}.
028     *
029     * @param <V> the Graph vertices type
030     * @param <E> the Graph edges type
031     */
032    public interface Graph<V extends Vertex, E extends Edge<V>>
033    {
034    
035        /**
036         * Returns the total set of Vertices in the graph.
037         *
038         * @return the total set of Vertices in the graph.
039         */
040        Set<V> getVertices();
041    
042        /**
043         * Returns the total set of Edges in the graph.
044         *
045         * @return the total set of Edges in the graph.
046         */
047        Set<E> getEdges();
048    
049        /**
050         * Returns all edges which touch this vertex, where the input vertex is in the edge head.
051         *
052         * @return all edges which touch this vertex, where the input vertex is in the edge head.
053         */
054        Set<E> getEdges( V v );
055    
056        /**
057         * Return the set of {@link Vertex} on the input {@link Edge} (2 for normal edges, > 2 for HyperEdges)
058         *
059         * @return the set of {@link Vertex} on this Edge.
060         */
061        Set<V> getVertices( E e );
062    
063    }