xc
Graph.h
1 // -*-c++-*-
2 //----------------------------------------------------------------------------
3 // XC program; finite element analysis code
4 // for structural analysis and design.
5 //
6 // Copyright (C) Luis C. Pérez Tato
7 //
8 // This program derives from OpenSees <http://opensees.berkeley.edu>
9 // developed by the «Pacific earthquake engineering research center».
10 //
11 // Except for the restrictions that may arise from the copyright
12 // of the original program (see copyright_opensees.txt)
13 // XC is free software: you can redistribute it and/or modify
14 // it under the terms of the GNU General Public License as published by
15 // the Free Software Foundation, either version 3 of the License, or
16 // (at your option) any later version.
17 //
18 // This software is distributed in the hope that it will be useful, but
19 // WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU General Public License for more details.
22 //
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program.
26 // If not, see <http://www.gnu.org/licenses/>.
27 //----------------------------------------------------------------------------
28 /* ****************************************************************** **
29 ** OpenSees - Open System for Earthquake Engineering Simulation **
30 ** Pacific Earthquake Engineering Research Center **
31 ** **
32 ** **
33 ** (C) Copyright 1999, The Regents of the University of California **
34 ** All Rights Reserved. **
35 ** **
36 ** Commercial use of this program without express permission of the **
37 ** University of California, Berkeley, is strictly prohibited. See **
38 ** file 'COPYRIGHT' in main directory for information on usage and **
39 ** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
40 ** **
41 ** Developed by: **
42 ** Frank McKenna (fmckenna@ce.berkeley.edu) **
43 ** Gregory L. Fenves (fenves@ce.berkeley.edu) **
44 ** Filip C. Filippou (filippou@ce.berkeley.edu) **
45 ** **
46 ** ****************************************************************** */
47 
48 // $Revision: 1.3 $
49 // $Date: 2005/11/03 23:11:55 $
50 // $Source: /usr/local/cvs/OpenSees/SRC/graph/graph/Graph.h,v $
51 
52 
53 #ifndef Graph_h
54 #define Graph_h
55 
56 // Written: fmk
57 // Revision: A
58 //
59 // Description: This file contains the class definition for Graph.
60 // The Graph class provides the abstraction of a graph, a collection of
61 // vertices and edges. The Graph class is a container class which stores
62 // and provides access to Vertex objects. The Vertices contain information
63 // about the edges in this design.
64 //
65 // What: "@(#) Graph.h, revA"
66 
67 #include <iostream>
68 #include "utility/actor/actor/MovableObject.h"
69 #include "utility/tagged/storage/ArrayOfTaggedObjects.h"
70 #include "solution/graph/graph/VertexIter.h"
71 
72 namespace XC {
73 class Vertex;
74 class VertexIter;
75 class TaggedObjectStorage;
76 class Channel;
77 class FEM_ObjectBroker;
78 
80 //
82 
94 class Graph: public MovableObject
95  {
96  protected:
97  ArrayOfTaggedObjects myVertices;
98  VertexIter theVertexIter;
99  int numEdge;
100  int nextFreeTag;
101 
102  void inic(const size_t &);
103  void copy(const Graph &other);
104  int sendData(Communicator &);
105  int recvData(const Communicator &);
106 
107  public:
108  Graph(int numVertices= 32);
109  Graph(const Graph &other);
110  Graph &operator=(const Graph &other);
111 
112  virtual bool addVertex(const Vertex &vertexPtr, bool checkAdjacency = true);
113  virtual int addEdge(int vertexTag, int otherVertexTag);
114 
115  virtual Vertex *getVertexPtr(int vertexTag);
116  virtual const Vertex *getVertexPtr(int vertexTag) const;
117  virtual VertexIter &getVertices(void);
118  virtual int getNumVertex(void) const;
119  virtual int getNumEdge(void) const;
120  virtual int getFreeTag(void);
121  virtual bool removeVertex(int tag, bool removeEdgeFlag = true);
122  const Vertex *BuscaRef(int ref) const;
123  void getBand(int &,int &) const;
124  int getVertexDiffMaxima(void) const;
125  int getVertexDiffExtrema(void) const;
126 
127 
128  virtual int merge(Graph &other);
129 
130  virtual void Print(std::ostream &os, int flag =0) const;
131  int sendSelf(Communicator &);
132  int recvSelf(const Communicator &);
133 
134  friend std::ostream &operator<<(std::ostream &, const Graph &);
135  };
136 
137 std::ostream &operator<<(std::ostream &, const Graph &);
138 } // end of XC namespace
139 
140 #endif
141 
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:80
int sendData(Communicator &)
Send object members through the communicator argument.
Definition: Graph.cpp:475
Communication parameters between processes.
Definition: Communicator.h:66
Object that can move between processes.
Definition: MovableObject.h:100
Graph & operator=(const Graph &other)
Assignment operator.
Definition: Graph.cpp:127
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:92
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 recvSelf(const Communicator &)
Receives object through the communicator argument.
Definition: Graph.cpp:509
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:435
int recvData(const Communicator &)
Receives object members through the communicator argument.
Definition: Graph.cpp:484
virtual int getNumVertex(void) const
Return the number of vertices in the graph.
Definition: Graph.cpp:293
virtual void Print(std::ostream &os, int flag=0) const
Prints the graph.
Definition: Graph.cpp:464
The Graph class provides the abstraction of a graph.
Definition: Graph.h:94
int sendSelf(Communicator &)
Sends object through the communicator argument.
Definition: Graph.cpp:493
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:410
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:35
Iterator over the vertices of the graph.
Definition: VertexIter.h:76
void getBand(int &, int &) const
Returns the ends of the bandwidth.
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