xc
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members

The Graph class provides the abstraction of a graph. More...

#include <Graph.h>

Inheritance diagram for XC::Graph:
Inheritance graph
[legend]
Collaboration diagram for XC::Graph:
Collaboration graph
[legend]

Public Member Functions

 Graph (int numVertices=32)
 Constructor. More...
 
 Graph (const Graph &other)
 Copy constructor.
 
Graphoperator= (const Graph &other)
 Assignment operator.
 
virtual bool addVertex (const Vertex &vertexPtr, bool checkAdjacency=true)
 Appends a vertex to the graph. More...
 
virtual int addEdge (int vertexTag, int otherVertexTag)
 Adds an edge to the graph. More...
 
virtual VertexgetVertexPtr (int vertexTag)
 Returns a pointer to the vertex identified by the tag being passed as parameter.
 
virtual const VertexgetVertexPtr (int vertexTag) const
 Returns a pointer to the vertex identified by the tag being passed as parameter. More...
 
virtual VertexItergetVertices (void)
 Returns an iterator to the vertices of the graph. More...
 
virtual int getNumVertex (void) const
 Return the number of vertices in the graph.
 
virtual int getNumEdge (void) const
 Return the number of edges in the graph.
 
virtual int getFreeTag (void)
 Returns the siguiente identifier (tag) libre.
 
virtual bool removeVertex (int tag, bool removeEdgeFlag=true)
 Removes from the graph the vertex identified by the tag being passed as parameter. More...
 
const VertexBuscaRef (int ref) const
 
void getBand (int &, int &) const
 Returns the ends of the bandwidth.
 
int getVertexDiffMaxima (void) const
 Returns the maximum (positive) of the difference between vertices indexes. More...
 
int getVertexDiffExtrema (void) const
 Returns the extreme (positive or negative) of the difference between vertices indexes. More...
 
virtual int merge (Graph &other)
 Mezcla los dos grafos.
 
virtual void Print (std::ostream &os, int flag=0) const
 Prints the graph.
 
int sendSelf (Communicator &)
 Sends object through the communicator argument.
 
int recvSelf (const Communicator &)
 Receives object through the communicator argument.
 
- Public Member Functions inherited from XC::MovableObject
 MovableObject (int classTag, int dbTag)
 Constructor. More...
 
 MovableObject (int classTag)
 Constructor. More...
 
 MovableObject (const MovableObject &)
 Copy constructor. Doesn't copy the dbTag.
 
MovableObjectoperator= (const MovableObject &)
 Assignment operator. Doesn't copy the dbTag.
 
int getClassTag (void) const
 Return the class identifier.
 
int getDbTag (void) const
 Return the object identifier in the database.
 
int getDbTag (Communicator &)
 Return the object identifier in the database.
 
void setDbTag (int dbTag)
 Sets the object identifier in the database.
 
void setDbTag (Communicator &)
 Sets the object identifier in the database if not already set. More...
 
virtual int setParameter (const std::vector< std::string > &argv, Parameter &param)
 Sets the value param to the parameter argv.
 
virtual int updateParameter (int parameterID, Information &info)
 Updates the parameter identified by parameterID with info.
 
virtual int activateParameter (int parameterID)
 Activates the parameter identified by parameterID.
 
virtual int setVariable (const std::string &variable, Information &)
 Set the value of the variable idenfified by var.
 
virtual int getVariable (const std::string &variable, Information &)
 Return the value of the variable idenfified by var.
 
- Public Member Functions inherited from XC::DistributedBase
 DistributedBase (void)
 Constructor.
 
virtual ~DistributedBase (void)
 Destructor.
 
virtual DbTagDatagetDbTagData (void) const
 Returns a vector to store class dbTags.
 
const int & getDbTagDataPos (const int &i) const
 Returns the data at the i-th position.
 
void setDbTagDataPos (const int &i, const int &v)
 Sets the data at the i-th position.
 
void inicComm (const int &dataSize) const
 Initializes communication.
 

Protected Member Functions

void inic (const size_t &)
 
void copy (const Graph &other)
 
int sendData (Communicator &)
 Send object members through the communicator argument.
 
int recvData (const Communicator &)
 Receives object members through the communicator argument.
 

Protected Attributes

ArrayOfTaggedObjects myVertices
 
VertexIter theVertexIter
 
int numEdge
 
int nextFreeTag
 

Friends

std::ostream & operator<< (std::ostream &, const Graph &)
 

Detailed Description

The Graph class provides the abstraction of a graph.

Provides the interface for all graph classes, a collection of vertices and edges. The Graph class is a container class which stores and provides access to Vertex objects. The Vertices contain information about the edges in this design. A Graph is a container class responsible for holding the vertex set and edge set. The class is responsible for:

  1. providing methods to add vertices and edges.
  2. accessing the vertices and edges. All the methods for the class are declared as virtual to allow subclasses to change its behavior.

Constructor & Destructor Documentation

◆ Graph()

XC::Graph::Graph ( int  numVertices = 32)

Constructor.

To create an empty Graph.

Member Function Documentation

◆ addEdge()

int XC::Graph::addEdge ( int  vertexTag,
int  otherVertexTag 
)
virtual

Adds an edge to the graph.

Previously we check that its vertices are already defined in the graph, otherwise it returns -1 (error condition)

Causes the Graph to add an edge {(vertexTag,otherVertexTag)} to the Graph. A check is first made to see if vertices with tags given by vertexTag and otherVertexTag exist in the graph. If they do not exist a \(-1\) is returned, otherwise the method invokes {addEdge()} on each of the corresponding vertices in the graph. Increments numEdge by \(1\) and returns \(0\) if successful, a \(1\) if the edge already existed, and a \(-2\) if one addEdge() was successful, but the other was not.

Parameters
vertexTagend of the edge.
otherVertexTagthe other end of the edge.

Reimplemented in XC::ArrayGraph.

◆ addVertex()

bool XC::Graph::addVertex ( const Vertex vrt,
bool  checkAdjacency = true 
)
virtual

Appends a vertex to the graph.

If the adjacency list of the vertex is not empty, we check before that all the vertices of the list are already on the graph.

Causes the graph to add a vertex to the graph. If checkAdjacency is true, a check is made to ensure that all the Vertices in the adjacency list of the Vertex are in the Graph. If a vertex in the adjacency is not in the Graph the vertex is not added, a warning message is printed and false is returned. If successful, returns the result of invoking addComponent() on the TaggedStorage object used to store the Vertices.

◆ getVertexDiffExtrema()

int XC::Graph::getVertexDiffExtrema ( void  ) const

Returns the extreme (positive or negative) of the difference between vertices indexes.

◆ getVertexDiffMaxima()

int XC::Graph::getVertexDiffMaxima ( void  ) const

Returns the maximum (positive) of the difference between vertices indexes.

◆ getVertexPtr()

const XC::Vertex * XC::Graph::getVertexPtr ( int  vertexTag) const
virtual

Returns a pointer to the vertex identified by the tag being passed as parameter.

A method which returns a pointer to the vertex whose tag is given by {vertexTag}. If no such vertex exists in the graph \(0\) is returned. Invokes {getComponentPtr(vertexTag)} on the vertex storage object and casts this to a Vertex * if not null.

Reimplemented in XC::ArrayGraph.

◆ getVertices()

XC::VertexIter & XC::Graph::getVertices ( void  )
virtual

Returns an iterator to the vertices of the graph.

A method which returns a reference to the graphs VertexIter. This iter can be used for iterating through the vertices of the graph.

Reimplemented in XC::ArrayGraph.

◆ removeVertex()

bool XC::Graph::removeVertex ( int  tag,
bool  flag = true 
)
virtual

Removes from the graph the vertex identified by the tag being passed as parameter.

To remove the Vertex from the Graph whose tag is equal to {vertexTag}. If removeEdgeFlag is true will also remove the Vertex from the remaining Vertices adjacency lists. returns a pointer to the removed Vertex if successful, \(0\) if the Vertex was not in the Graph. Invokes {removeComponent(vertexTag)} on the vertex storage object and casts this to a Vertex * if not null. DOES NOT YET DEAL WITH removeEdgeFlag.


The documentation for this class was generated from the following files: