xc
ArrayGraph.h
1 //----------------------------------------------------------------------------
2 // XC program; finite element analysis code
3 // for structural analysis and design.
4 //
5 // Copyright (C) Luis Claudio Pérez Tato
6 //
7 // This program derives from OpenSees <http://opensees.berkeley.edu>
8 // developed by the «Pacific earthquake engineering research center».
9 //
10 // Except for the restrictions that may arise from the copyright
11 // of the original program (see copyright_opensees.txt)
12 // XC is free software: you can redistribute it and/or modify
13 // it under the terms of the GNU General Public License as published by
14 // the Free Software Foundation, either version 3 of the License, or
15 // (at your option) any later version.
16 //
17 // This software is distributed in the hope that it will be useful, but
18 // WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with this program.
25 // If not, see <http://www.gnu.org/licenses/>.
26 //----------------------------------------------------------------------------
27 /* ****************************************************************** **
28 ** OpenSees - Open System for Earthquake Engineering Simulation **
29 ** Pacific Earthquake Engineering Research Center **
30 ** **
31 ** **
32 ** (C) Copyright 1999, The Regents of the University of California **
33 ** All Rights Reserved. **
34 ** **
35 ** Commercial use of this program without express permission of the **
36 ** University of California, Berkeley, is strictly prohibited. See **
37 ** file 'COPYRIGHT' in main directory for information on usage and **
38 ** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
39 ** **
40 ** Developed by: **
41 ** Frank McKenna (fmckenna@ce.berkeley.edu) **
42 ** Gregory L. Fenves (fenves@ce.berkeley.edu) **
43 ** Filip C. Filippou (filippou@ce.berkeley.edu) **
44 ** **
45 ** ****************************************************************** */
46 
47 // $Revision: 1.2 $
48 // $Date: 2003/02/14 23:01:22 $
49 // $Source: /usr/local/cvs/OpenSees/SRC/graph/graph/ArrayGraph.h,v $
50 
51 
52 // File: ~/graph/graph/ArrayGraph.h
53 //
54 // Written: fmk
55 // Created: Sun Sept 15 11:47:47: 1996
56 // Revision: A
57 //
58 // Description: This file contains the class definition for ArrayGraph.
59 // The vertices in an ArrayGraph are held in an array. This is more efficient
60 // than holding them in a List data structure, but problems can arise with
61 // large Graphs in getting enough contiguous memory for the array.
62 //
63 // What: "@(#) ArrayGraph.h, revA"
64 
65 #ifndef ArrayGraph_h
66 #define ArrayGraph_h
67 
68 #include "Graph.h"
69 #include <solution/graph/graph/ArrayVertexIter.h>
70 #include <vector>
71 
72 namespace XC {
74 //
90 class ArrayGraph: public Graph
91  {
92  private:
93  int numVertex;
94  int lastEmpty;
95  std::vector<Vertex *> theVertices;
96  ArrayVertexIter myIter;
97  void free_mem(void);
98  protected:
99  int getArraySize(void) const;
100 
101  friend class ArrayVertexIter;
102  ArrayGraph(const ArrayGraph &);
103  ArrayGraph &operator=(const ArrayGraph &);
104  public:
105  ArrayGraph(int arraySize);
106  virtual ~ArrayGraph(void);
107 
108  virtual bool addVertex(const Vertex &vertexPtr);
109  virtual int addEdge(int vertexTag, int otherVertexTag);
110 
111  virtual Vertex *getVertexPtr(int vertexTag);
112  virtual const Vertex *getVertexPtr(int vertexTag) const;
113  virtual VertexIter &getVertices(void);
114  int getNumVertex(void) const;
115  int getNumEdge(void) const;
116 
117  virtual void Print(std::ostream &s) const;
118  friend std::ostream &operator<<(std::ostream &, const ArrayGraph &);
119  };
120 
121 std::ostream &operator<<(std::ostream &, const ArrayGraph &);
122 } // end of XC namespace
123 
124 #endif
125 
Vertex of a graph.
Definition: Vertex.h:79
Graph that uses an array to store its vertices.
Definition: ArrayGraph.h:90
virtual VertexIter & getVertices(void)
A method which first invokes {reset()} on the graphs ArrayVertexIter and then returns a reference to ...
Definition: ArrayGraph.cpp:244
virtual ~ArrayGraph(void)
Destructor.
Definition: ArrayGraph.cpp:94
virtual int addEdge(int vertexTag, int otherVertexTag)
Add an edge to the graph.
Definition: ArrayGraph.cpp:226
virtual void Print(std::ostream &s) const
Print the graph.
Definition: ArrayGraph.cpp:270
int getNumVertex(void) const
Return the number of vertices in the graph, returns numVertex.
Definition: ArrayGraph.cpp:252
ArrayVertexIter is an iter for returning the vertices of an object of class ArrayGraph.
Definition: ArrayVertexIter.h:77
The Graph class provides the abstraction of a graph.
Definition: Graph.h:93
int getNumEdge(void) const
A method to return the number of edges in the graph.
Definition: ArrayGraph.cpp:256
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:34
int getArraySize(void) const
Return the size of the graphs array.
Definition: ArrayGraph.cpp:260
virtual bool addVertex(const Vertex &vertexPtr)
Add a vertex to the graph.
Definition: ArrayGraph.cpp:110
virtual Vertex * getVertexPtr(int vertexTag)
Return a pointer to the vertex identified by the tag.
Definition: ArrayGraph.cpp:176
Iterator over the vertices of the graph.
Definition: VertexIter.h:75