xc
Graph.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.3 $
48 // $Date: 2005/11/03 23:11:55 $
49 // $Source: /usr/local/cvs/OpenSees/SRC/graph/graph/Graph.h,v $
50 
51 
52 #ifndef Graph_h
53 #define Graph_h
54 
55 // Written: fmk
56 // Revision: A
57 //
58 // Description: This file contains the class definition for Graph.
59 // The Graph class provides the abstraction of a graph, a collection of
60 // vertices and edges. The Graph class is a container class which stores
61 // and provides access to Vertex objects. The Vertices contain information
62 // about the edges in this design.
63 //
64 // What: "@(#) Graph.h, revA"
65 
66 #include <iostream>
67 #include "utility/actor/actor/MovableObject.h"
68 #include "utility/tagged/storage/ArrayOfTaggedObjects.h"
69 #include "solution/graph/graph/VertexIter.h"
70 
71 namespace XC {
72 class Vertex;
73 class VertexIter;
74 class TaggedObjectStorage;
75 class Channel;
76 class FEM_ObjectBroker;
77 
79 //
81 
93 class Graph: public MovableObject
94  {
95  protected:
96  ArrayOfTaggedObjects myVertices;
97  VertexIter theVertexIter;
98  int numEdge;
99  int nextFreeTag;
100 
101  void inic(const size_t &);
102  void copy(const Graph &other);
103  int sendData(CommParameters &);
104  int recvData(const CommParameters &);
105 
106  public:
107  Graph(int numVertices= 32);
108  Graph(const Graph &other);
109  Graph &operator=(const Graph &other);
110 
111  virtual bool addVertex(const Vertex &vertexPtr, bool checkAdjacency = true);
112  virtual int addEdge(int vertexTag, int otherVertexTag);
113 
114  virtual Vertex *getVertexPtr(int vertexTag);
115  virtual const Vertex *getVertexPtr(int vertexTag) const;
116  virtual VertexIter &getVertices(void);
117  virtual int getNumVertex(void) const;
118  virtual int getNumEdge(void) const;
119  virtual int getFreeTag(void);
120  virtual bool removeVertex(int tag, bool removeEdgeFlag = true);
121  const Vertex *BuscaRef(int ref) const;
122  void getBand(int &,int &) const;
123  int getVertexDiffMaxima(void) const;
124  int getVertexDiffExtrema(void) const;
125 
126 
127  virtual int merge(Graph &other);
128 
129  virtual void Print(std::ostream &os, int flag =0);
130  int sendSelf(CommParameters &);
131  int recvSelf(const CommParameters &);
132 
133  friend std::ostream &operator<<(std::ostream &, Graph &);
134  };
135 
136 std::ostream &operator<<(std::ostream &, Graph &);
137 } // end of XC namespace
138 
139 #endif
140 
virtual bool addVertex(const Vertex &vertexPtr, bool checkAdjacency=true)
Appends a vertex to the graph.
Definition: Graph.cpp:146
Vertex of a graph.
Definition: Vertex.h:79
Object that can move between processes.
Definition: MovableObject.h:99
int recvSelf(const CommParameters &)
Receives object through the channel being passed as parameter.
Definition: Graph.cpp:507
Graph & operator=(const Graph &other)
Assignment operator.
Definition: Graph.cpp:127
int recvData(const CommParameters &)
Receives object members through the channel being passed as parameter.
Definition: Graph.cpp:482
virtual int getFreeTag(void)
Returns the siguiente identifier (tag) libre.
Definition: Graph.cpp:301
virtual int addEdge(int vertexTag, int otherVertexTag)
Adds an edge to the graph.
Definition: Graph.cpp:203
virtual int merge(Graph &other)
Mezcla los dos grafos.
Definition: Graph.cpp:334
ArrayOfTaggedObjects is a storage class.
Definition: ArrayOfTaggedObjects.h:91
Graph(int numVertices=32)
Constructor.
Definition: Graph.cpp:118
virtual VertexIter & getVertices(void)
Returns an iterator to the vertices of the graph.
Definition: Graph.cpp:285
int sendSelf(CommParameters &)
Sends object through the channel being passed as parameter.
Definition: Graph.cpp:491
virtual int getNumEdge(void) const
Return the number of edges in the graph.
Definition: Graph.cpp:297
int getVertexDiffExtrema(void) const
Returns the extreme (positive or negative) of the difference between vertices indexes.
Definition: Graph.cpp:433
virtual int getNumVertex(void) const
Return the number of vertices in the graph.
Definition: Graph.cpp:293
The Graph class provides the abstraction of a graph.
Definition: Graph.h:93
virtual void Print(std::ostream &os, int flag=0)
Prints the graph.
Definition: Graph.cpp:462
virtual bool removeVertex(int tag, bool removeEdgeFlag=true)
Removes from the graph the vertex identified by the tag being passed as parameter.
Definition: Graph.cpp:314
int getVertexDiffMaxima(void) const
Returns the maximum (positive) of the difference between vertices indexes.
Definition: Graph.cpp:409
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:34
Communication parameters between processes.
Definition: CommParameters.h:65
int sendData(CommParameters &)
Send object members through the channel being passed as parameter.
Definition: Graph.cpp:473
Iterator over the vertices of the graph.
Definition: VertexIter.h:75
void getBand(int &, int &) const
Returns the extremos del ancho de banda.
Definition: Graph.cpp:379
virtual Vertex * getVertexPtr(int vertexTag)
Returns a pointer to the vertex identified by the tag being passed as parameter.
Definition: Graph.cpp:257