KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > classycle > graph > AtomicVertex


1 /*
2  * Copyright (c) 2003-2006, Franz-Josef Elmer, All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * - Redistributions of source code must retain the above copyright notice,
8  * this list of conditions and the following disclaimer.
9  * - Redistributions in binary form must reproduce the above copyright notice,
10  * this list of conditions and the following disclaimer in the documentation
11  * and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
14  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
15  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
22  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */

25 package classycle.graph;
26
27 /**
28  * A subclass of {@link Vertex} with the following additional properties:
29  * <ul><li>A flag indicating whether this vertex belongs to the graph or not.
30  * <li>The order of visiting.
31  * <li>The low function.
32  * </ul>
33  * The last two properties are used in Tarjan's algorithm to find the
34  * strong components (see {@link StrongComponentProcessor}).
35  *
36  * @author Franz-Josef Elmer
37  */

38 public class AtomicVertex extends Vertex {
39   private boolean _graphVertexDefaultValue = true;
40   private boolean _graphVertex;
41   private int _order;
42   private int _low;
43
44   /** Creates an instance for the specified attributes. */
45   public AtomicVertex(Attributes attributes) {
46     super(attributes);
47   }
48
49   /**
50    * Reset this instance. That is, it becomes a unvisited vertex
51    * where <tt>order = low = -1</tt>. Whether it is a graph vertex or not
52    * depends on the default value defined by the method
53    * {@link #setDefaultValueOfGraphVertexFlag}.
54    */

55   public void reset() {
56     super.reset();
57     _graphVertex = _graphVertexDefaultValue;
58     _order = -1;
59     _low = -1;
60   }
61
62   /** Returns <tt>true</tt> if this vertex belongs to a graph. */
63   public boolean isGraphVertex() {
64     return _graphVertex;
65   }
66
67   /**
68    * Sets the default value of graphVertex flag.
69    * @see #reset()
70    */

71   public void setDefaultValueOfGraphVertexFlag(boolean flag) {
72     _graphVertexDefaultValue = flag;
73   }
74
75   /** Returns the order of visiting. */
76   public int getOrder() {
77     return _order;
78   }
79
80   /** Sets the order of visiting. */
81   public void setOrder(int order) {
82     _order = order;
83   }
84
85   /** Returns the current value of the low function. */
86   public int getLow() {
87     return _low;
88   }
89
90   /** Sets the current value of the low function. */
91   public void setLow(int low) {
92     _low = low;
93   }
94 } //class
Popular Tags