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    
021    package org.dbreplicator.graph;
022    
023    import org.apache.log4j.Logger;
024        /**
025            Instances of this class act as wrappers for the real vertex object, which
026            can be for example Integer, or any object. Instances of this
027            class always "hang" from a <CODE>ListElement</CODE> instance.
028        */
029    
030        public class Vertex {
031    
032    
033           protected static Logger log = Logger.getLogger(Vertex.class.getName());
034    
035            /**
036                    The number of edges this vertex has coming in
037                    from another vertex.
038            */
039            private int inGraphEdges;
040    
041            /**
042                    The number of edges this vertex has going out
043                    to another vertex.
044            */
045            private int outGraphEdges;
046    
047            /**
048                    A link to the beginning of a linked list structure of
049                    the edges that leave this vertex.
050            */
051            public ListElement firstEdge;
052    
053            /**
054                    A link to the actual abject, which can be any Object,
055                    which this vertex instance "wraps".
056            */
057            public Object vertexObject;
058    
059            /**
060                    A Graph marker variable used for cycle detection, topological sorting
061                    and similar.
062            */
063            public int graphMarker;
064    
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 Vertex(Object objToEmbed){
073    
074              // Initialize all vars..
075              inGraphEdges=0;
076              outGraphEdges=0;
077              graphMarker=0;
078              firstEdge=null;
079              vertexObject=objToEmbed;
080            }
081    
082            public String toString() {
083              return vertexObject.toString();
084            }
085    
086    
087            /**
088                    Returns the number of edges coming into this vertex.
089                    @return The in-degree of this vertex.
090            */
091            public int whatIsInDegree(){
092                    return this.inGraphEdges;
093            }
094    
095            /**
096                    Returns the number of edges leaving this vertex.
097                    @return The out-degree of this vertex.
098            */
099            public int whatIsOutDegree(){
100                    return this.outGraphEdges;
101            }
102    
103            /**
104                    Accessor method to increment in-degree by one.
105            */
106            public void addInDegree(){
107                    this.inGraphEdges++;
108            }
109    
110            /**
111                    Accessor method to increment out-degree by one.
112            */
113            public void addOutDegree(){
114                    this.outGraphEdges++;
115            }
116        }





























































Powered by Drupal - Theme by Danger4k