TSPLIB
Public Member Functions | Protected Member Functions | Private Attributes | Friends
Graph Class Reference

#include <ValidateGraph.hpp>

List of all members.

Public Member Functions

 Graph (const std::vector< std::vector< double > > &adjacencyMatrix)
 Graph (const Graph &graph)
Graphoperator= (const Graph &graph)
bool getIsUndirected () const
std::vector< std::vector
< double > >::size_type 
getN () const
double getEdgeCost (const std::vector< std::vector< double > >::size_type i, const std::vector< double >::size_type j) const

Protected Member Functions

void setAdjacencyMatrixElement (const std::vector< std::vector< double > >::size_type i, const std::vector< double >::size_type j, const double value)
double getAdjacencyMatrixElement (const std::vector< std::vector< double > >::size_type i, const std::vector< double >::size_type j) const

Private Attributes

bool isUndirected
std::vector< std::vector
< double > >::size_type 
n
std::vector< std::vector
< double > > 
adjacencyMatrix

Friends

std::ostream & operator<< (std::ostream &os, Graph &graph)

Detailed Description

Saves one weighted complete graph. This class provides no checks of ranges.

Definition at line 35 of file ValidateGraph.hpp.


Constructor & Destructor Documentation

Graph::Graph ( const std::vector< std::vector< double > > &  adjacencyMatrix)

Constructor for the class Graph.

Parameters:
adjacencyMatrixAdjacency matrix of a weighted undirected complete graph. The elements in the matrix are the costs. The matrix can be either only a lower triangular matrix for undirected graphs or it can be a square matrix for the directed graph. In both cases on the main diagonale there must be 0.

Definition at line 17 of file ValidateGraph.cpp.

Graph::Graph ( const Graph graph)

Copy constructor for the class Graph.

Parameters:
graphInstance to be copied.

Definition at line 48 of file ValidateGraph.cpp.

References getAdjacencyMatrixElement(), getIsUndirected(), and getN().


Member Function Documentation

double Graph::getAdjacencyMatrixElement ( const std::vector< std::vector< double > >::size_type  i,
const std::vector< double >::size_type  j 
) const [inline, protected]

Returns one element in the adjacency matrix. The parameters are not checked.

Parameters:
iRow.
jColumn.
Returns:
Value of the element on the i-th row and j-th column.

Definition at line 80 of file ValidateGraph.hpp.

References adjacencyMatrix.

Referenced by getEdgeCost(), Graph(), and operator=().

double Graph::getEdgeCost ( const std::vector< std::vector< double > >::size_type  i,
const std::vector< double >::size_type  j 
) const [inline]

Returns the cost of the edge from i to j. The parameters are not checked.

Parameters:
iStart vertex.
jEnd vertex.
Returns:
Weight of the edge from i to j.

Definition at line 144 of file ValidateGraph.hpp.

References getAdjacencyMatrixElement(), and isUndirected.

Referenced by operator<<().

bool Graph::getIsUndirected ( ) const [inline]

Returns the indicator indicating if the graph is undirected.

Returns:
Indicator indicating if the graph is undirected.
  • true The Graph is undirected.
  • false The Graph is directed.

Definition at line 126 of file ValidateGraph.hpp.

References isUndirected.

Referenced by Graph(), main(), operator<<(), and operator=().

std::vector<std::vector<double> >::size_type Graph::getN ( ) const [inline]

Returns the number of vertices in the graph of the instance.

Returns:
Number of vertices in the graph of the instance.

Definition at line 134 of file ValidateGraph.hpp.

References n.

Referenced by Graph(), main(), operator<<(), and operator=().

Graph & Graph::operator= ( const Graph graph)

Implements the operator "=".

Parameters:
graphRight side of the operator.
Returns:
Left side of the operator.

Definition at line 79 of file ValidateGraph.cpp.

References getAdjacencyMatrixElement(), getIsUndirected(), and getN().

void Graph::setAdjacencyMatrixElement ( const std::vector< std::vector< double > >::size_type  i,
const std::vector< double >::size_type  j,
const double  value 
) [inline, protected]

Sets one element in the adjacency matrix. The parameters are not checked.

Parameters:
iRow.
jColumn.
valueNew value of the element on the i-th row and j-th column.

Definition at line 67 of file ValidateGraph.hpp.

References adjacencyMatrix.


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
Graph graph 
) [friend]

Implements the operator "<<".

Parameters:
osOstream.
graphGraph.
Returns:
Ostream with the information about the graph instance.

Definition at line 117 of file ValidateGraph.cpp.


Member Data Documentation

std::vector<std::vector<double> > Graph::adjacencyMatrix [private]

Adjacency matrix of a weighted undirected complete graph. The elements in the matrix are the costs. The elements in the matrix are the costs. The matrix can be either only a lower triangular matrix for undirected graphs or it can be a square matrix for the directed graph.

Definition at line 58 of file ValidateGraph.hpp.

Referenced by getAdjacencyMatrixElement(), and setAdjacencyMatrixElement().

bool Graph::isUndirected [private]

Indicator indicating if the graph is undirected.

  • true The Graph is undirected.
  • false The Graph is directed.

Definition at line 44 of file ValidateGraph.hpp.

Referenced by getEdgeCost(), and getIsUndirected().

std::vector<std::vector<double> >::size_type Graph::n [private]

Number of vertices in the graph of the instance.

Definition at line 49 of file ValidateGraph.hpp.

Referenced by getN().


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Friends Defines