⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 directedgraph.java

📁 UML设计测试工具
💻 JAVA
字号:
/* * USE - UML based specification environment * Copyright (C) 1999-2004 Mark Richters, University of Bremen * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program 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 * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *//* $ProjectHeader: use 2-3-0-release.1 Mon, 12 Sep 2005 20:18:33 +0200 green $ */package org.tzi.use.graph;import java.util.Collection;import java.util.Iterator;import java.util.Set;/**  * Basic interface of graphs with directed edges. A graph is a collection * of node objects which may be connected by directed edges. * * @version     $ProjectVersion: 2-3-0-release.1 $ * @author  Mark Richters */public interface DirectedGraph extends Collection {    // Query Operations (from Collection)    /**     * Returns the number of nodes in this graph.  If this graph     * contains more than <tt>Integer.MAX_VALUE</tt> elements, returns     * <tt>Integer.MAX_VALUE</tt>.     *      * @return the number of nodes in this graph     */    int size();    /**     * Returns <tt>true</tt> if this graph contains no nodes.     *     * @return <tt>true</tt> if this graph contains no nodes     */    boolean isEmpty();    /**     * Returns <tt>true</tt> if this graph contains the specified     * node.  More formally, returns <tt>true</tt> if and only if this     * graph contains at least one node <tt>e</tt> such that     * <tt>(o==null ? e==null : o.equals(e))</tt>.     *     * @param o element whose presence in this graph is to be tested.     * @return <tt>true</tt> if this graph contains the specified     *         node     */    boolean contains(Object o);    /**     * Returns an iterator over the nodes in this collection.  There are no     * guarantees concerning the order in which the nodes are returned.     *      * @return an <tt>Iterator</tt> over the nodes in this graph     */    Iterator iterator();    /**     * Returns an array containing all of the nodes in this graph.     * Obeys the general contract of the <tt>Collection.toArray</tt> method.     *     * @return an array containing all of the nodes in this set.     */    Object[] toArray();    // Modification Operations    /**     * Adds the specified node to this graph if it is not already     * present.  If this graph already contains the specified node,     * the call leaves this Graph unchanged and returns     * <tt>false</tt>.     *     * @param o node to be added to this graph.     * @return <tt>true</tt> if this graph did not already contain the     *          specified node.     * @throws NullPointerException n is null.       */    boolean add(Object o);    /**     * Removes the specified node and all incident edges from this     * graph if it is present.  If this graph does not contain the     * specified node, the call leaves this Graph unchanged and     * returns <tt>false</tt>.     *     * @param o node to be removed from this graph.     * @return <tt>true</tt> if this graph did contain the     *          specified node and removed it.       */    boolean remove(Object o);    // Graph specific Operations    /**     * Returns the number of all edges in this graph.     *     * @return the number of edges in this graph     */    int numEdges();    /**     * Returns the number of cyclic edges in this graph.     *     * @return the number of cyclic edges in this graph     */    int numCycles();    /**     * Returns the number of all incoming edges for the specified node.     *     * @return the number of incoming edges for node n     * @throws NullPointerException n is null.     * @throws NodeDoesNotExistException n is not part of this graph.     */    int numIncomingEdges(Object n);    /**     * Returns the number of all outgoing edges of the specified node.     *     * @return the number of outgoing edges for node n     * @throws NullPointerException n is null.     * @throws NodeDoesNotExistException n is not part of this graph.     */    int numOutgoingEdges(Object n);    /**     * Returns an iterator over the edges in this collection. There     * are no guarantees concerning the order in which the edges are     * returned. The iterator delivers instances of type     * <code>DirectedEdge</code>.     *      * @return an <tt>Iterator</tt> over the edges in this graph      * @see DirectedEdge     */    Iterator edgeIterator();    /**      * Adds the specified edge to this graph. Multiple edges between     * the same nodes may exist but they must be distinct, i.e. their      * equals method is pair-wise false.     *     * @param e edge to be added to this graph.     * @return <tt>true</tt> if this graph did not already contain the     *          specified edge.     * @throws NodeDoesNotExistException node referenced by e is     *            not part of this graph.     * @throws NullPointerException e is null.     */    boolean addEdge(DirectedEdge e);    /**      * Removes the specified edge from this graph.     *     * @param e edge to be removed from this graph.     * @return <tt>true</tt> if the specified edge could be removed.     * @throws NullPointerException e is null.     */    boolean removeEdge(DirectedEdge e);    // Views    /**     * Returns a set view of nodes which are directly reachable by outgoing     * edges from <code>n</code>.     *     * @return a set view of reachable target nodes.     * @throws NodeDoesNotExistException node n is not part of this graph.     * @throws NullPointerException n is null.     */    Set targetNodeSet(Object n);    /**     * Returns a set view of nodes which are reachable by one ore more      * outgoing edges from <code>n</code>.     *     * @return a set view of all reachable target nodes.     * @throws NodeDoesNotExistException node n is not part of this graph.     * @throws NullPointerException n is null.     */    Set targetNodeClosureSet(Object n);    /**     * Returns a set view of nodes which have directed edges targeting     * <code>n</code>.     *     * @return a set view of connected source nodes.     * @throws NodeDoesNotExistException node n is not part of this graph.     * @throws NullPointerException n is null.  */    Set sourceNodeSet(Object n);    /**     * Returns a set view of all nodes which have a path to     * <code>n</code>.     *     * @return a set view of all nodes leading to n.     * @throws NodeDoesNotExistException node n is not part of this graph.     * @throws NullPointerException n is null.     */    Set sourceNodeClosureSet(Object n);    /**     * Returns the set of edges between two nodes.     *     * @return Set(Object)     * @throws NodeDoesNotExistException node n1 or n2 is not in this graph.     * @throws NullPointerException n1 or n2 is null.     */    Set edgesBetween(Object n1, Object n2);    /**     * Returns true if there is a set of directed edges from n1 to n2.     *     * @return true if there is a set of directed edges from n1 to n2.     * @throws NodeDoesNotExistException node n1 or n2 is not in this graph.     * @throws NullPointerException n1 or n2 is null.     */    boolean existsPath(Object n1, Object n2);    /**     * Returns true if the graph contains at least one cycle.     *     * @return true if the graph contains at least one cycle.     */    boolean hasCycle();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -