JavaDoc


001    /**
002     * Copyright (c) 2003 Daffodil Software Ltd all rights reserved,
003     * Modifications Copyright (c) 2008 Regiscope Digital Imaging Co, LLC, All rights reserved.
004     * This program is free software; you can redistribute it and/or modify
005     * it under the terms of version 2 of the GNU General Public License as
006     * published by the Free Software Foundation.
007     * There are special exceptions to the terms and conditions of the GPL
008     * as it is applied to this software. See the GNU General Public License for more details.
009     *
010     * This program is distributed in the hope that it will be useful,
011     * but WITHOUT ANY WARRANTY; without even the implied warranty of
012     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013     * GNU General Public License for more details.
014     *
015     * You should have received a copy of the GNU General Public License
016     * along with this program; if not, write to the Free Software
017     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018     */
019    
020    package org.dbreplicator.graph;
021    
022        /**
023            Instances of this class act as wrappers for the real vertex object, which
024            can be for example java.lang.Integer, or any object. Instances of this
025            class always "hang" from a <CODE>JbListElement</CODE> instance.
026        */
027    
028        public class JbVertex {
029    
030            //-----------
031            // Variables
032            //-----------
033            /**
034                    The number of edges this vertex has coming in
035                    from another vertex.
036            */
037            private int inEdges;
038    
039            /**
040                    The number of edges this vertex has going out
041                    to another vertex.
042            */
043            private int outEdges;
044    
045            /**
046                    A link to the beginning of a linked list structure of
047                    the edges that leave this vertex.
048            */
049            public JbListElement firstEdge;
050    
051            /**
052                    A link to the actual abject, which can be any java.lang.Object,
053                    which this vertex instance "wraps".
054            */
055            public Object vertexObject;
056    
057            /**
058                    A marker variable used for cycle detection, topological sorting
059                    and similar.
060            */
061            public int marker;
062    
063            //-------------
064            // Constructor
065            //-------------
066    
067            /**
068                    A wrapper class for the actual java.lang.Object to be
069                    situated in the graph.
070                    @param objToEmbed The java.lang.Object that we wish to have wrapped.
071            */
072            public JbVertex(Object objToEmbed){
073    
074              // Initialize all vars..
075              inEdges=0;
076              outEdges=0;
077              marker=0;
078              firstEdge=null;
079              vertexObject=objToEmbed;
080            }
081    
082            public String toString() {
083              return vertexObject.toString();
084            }
085            //------------
086            // Methods
087            //------------
088    
089            /**
090                    Returns the number of edges coming into this vertex.
091                    @return The in-degree of this vertex.
092            */
093            public int whatIsInDegree(){
094                    return this.inEdges;
095            }
096    
097            /**
098                    Returns the number of edges leaving this vertex.
099                    @return The out-degree of this vertex.
100            */
101            public int whatIsOutDegree(){
102                    return this.outEdges;
103            }
104    
105            /**
106                    Accessor method to increment in-degree by one.
107            */
108            public void addInDegree(){
109                    this.inEdges++;
110            }
111    
112            /**
113                    Accessor method to increment out-degree by one.
114            */
115            public void addOutDegree(){
116                    this.outEdges++;
117            }
118        }





























































Powered by Drupal - Theme by Danger4k