Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

Vertex.cpp

Go to the documentation of this file.
00001 /* ****************************************************************** **
00002 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00003 **          Pacific Earthquake Engineering Research Center            **
00004 **                                                                    **
00005 **                                                                    **
00006 ** (C) Copyright 1999, The Regents of the University of California    **
00007 ** All Rights Reserved.                                               **
00008 **                                                                    **
00009 ** Commercial use of this program without express permission of the   **
00010 ** University of California, Berkeley, is strictly prohibited.  See   **
00011 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00012 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00013 **                                                                    **
00014 ** Developed by:                                                      **
00015 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00016 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00017 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00018 **                                                                    **
00019 ** ****************************************************************** */
00020                                                                         
00021 // $Revision: 1.1.1.1 $
00022 // $Date: 2000/09/15 08:23:21 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/graph/graph/Vertex.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/graph/graph/Vertex.C
00027 // 
00028 // Written: fmk 
00029 // Created: 11/96
00030 // Revision: A
00031 //
00032 // Description: This file contains the class implementation for Vertex.
00033 // Vertex is an element of a graph.
00034 //
00035 // What: "@(#) Vertex.C, revA"
00036 
00037 #include <Vertex.h>
00038 
00039 Vertex::Vertex(int tag, int ref, double weight, int color)
00040 :TaggedObject(tag), myRef(ref), myWeight(weight), myColor(color), 
00041  myDegree(0), myTmp(0), myAdjacency(0,8)
00042 {
00043 
00044 }    
00045 
00046 Vertex::~Vertex()
00047 {
00048 
00049 }    
00050 
00051 void 
00052 Vertex::setWeight(double newWeight) 
00053 { 
00054     myWeight = newWeight;
00055 }
00056 
00057 void 
00058 Vertex::setColor(int newColor) 
00059 {
00060     myColor = newColor;
00061 }
00062 
00063 void 
00064 Vertex::setTmp(int newTmp) 
00065 {
00066     myTmp = newTmp;
00067 }
00068 
00069 int 
00070 Vertex::getRef(void) const 
00071 {
00072     return myRef;
00073 }
00074 
00075 double
00076 Vertex::getWeight(void) const 
00077 {
00078     return myWeight;
00079 }
00080 
00081 int 
00082 Vertex::getColor(void) const
00083 {
00084     return myColor;
00085 }
00086 
00087 int 
00088 Vertex::getTmp(void) const
00089 {
00090     return myTmp;
00091 }
00092 
00093 int 
00094 Vertex::addEdge(int otherTag)
00095 {
00096     // don't allow itself to be added
00097     if (otherTag == this->getTag())
00098       return 0;
00099 
00100     // check the otherVertex has not already been added
00101     if (myAdjacency.getLocation(otherTag) < 0) {
00102  myAdjacency[myDegree]  = otherTag;
00103  myDegree++;
00104  return 0;
00105     }
00106     else
00107  return 1;
00108 }
00109 
00110 
00111 int 
00112 Vertex::getDegree(void) const
00113 {
00114     return myDegree;
00115 }
00116 
00117 const ID &
00118 Vertex::getAdjacency(void) const
00119 {
00120     return myAdjacency;
00121 }
00122 
00123 void
00124 Vertex::Print(ostream &s, int flag)
00125 {
00126     s << this->getTag() << " " ;
00127     s << myRef << " ";
00128     if (flag == 1) 
00129  s << myWeight << " " ;
00130     else if (flag ==2) 
00131  s << myColor << " " ;
00132     else if (flag == 3)
00133  s << myWeight << " " << myColor << " " ;    
00134 
00135     s << "ADJACENCY: " << myAdjacency;     
00136 }
00137 
00138 
Copyright Contact Us