Graph

class Graph

Subclassed by WGraph< T >

Public Types

typedef int Weight

Public Functions

inline Graph()
inline Graph(const int vertexCount, const bool isDirected)
inline void reset(const int vertexCount, const bool isDirected)
inline bool isDirected() const
inline int vertexCount() const
inline int neighbourCount(const int vertex) const
inline int edgeCount() const
inline int neighbour(const int vertex, const int neighbourPos) const

Returns the id of the n-th neighbour of a vertex.

inline const std::vector<EdgeTo> &edgesToNeighbours(const int vertex) const

Returns the edges connected to a vertex.

inline std::vector<int> neighbours(const int vertex) const

Returns the neighbours of a vertex.

inline int weight(const int edgeId) const

Always returns 1 (the graph is not weighted)

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

Always returns 1 (the graph is not weighted)

inline int edgeId(const int vertex, const int neighbourPos) const

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

inline int edgeIdTo(const int vertex, const int neighbour)

Returns the id of the first edge from one vertex to another (-1 if it doesn’t exist)

inline std::vector<Edge> edges() const

Returns a vector listing all the edges of the graph.

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

Creates a new edge between two vertices.

inline Graph transposeGraph() const

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

Protected Attributes

bool m_isDirected
int m_edgeCount
std::vector<std::vector<EdgeTo>> m_vertices
struct Edge

Public Members

int vertex1
int vertex2
int edgeId
struct EdgeTo

Public Members

int neighbour
int edgeId