Weighted Graph

template<class T>
class WGraph : public Graph

Public Types

typedef T Weight

Public Functions

inline WGraph()
inline WGraph(const int vertexCount, const bool isDirected)
inline void reset(const int vertexCount, const bool isDirected)

Reset the graph.

inline T weight(const int edgeId) const

Returns the weight of the n-th edge.

inline T weight(const int vertex, const int neighbourPos) const

Returns the weight of the n-th out-edge of a vertex.

inline void setWeight(const int vertex, const int neighbourPos, const T weight)

Sets the weight of the n-th out-edge of a vertex.

inline void setWeight(const int edgeId, const T weight)

Sets the weight of the n-th edge.

inline void addEdge(const int vertex1, const int vertex2, const T weight)

Creates a new edge between two vertices.

inline WGraph<T> transposeGraph() const

Returns the graph obtained after changing the direction of the edges.

Protected Attributes

std::vector<T> m_weights

Private Functions

inline void addEdge(const int vertex1, const int vertex2) = delete