#include <Graph.h>
Inheritance diagram for Graph:
Public Member Functions | |
Graph () | |
Create empty undirected graph. | |
Graph (int n, bool d) | |
Create directed graphs with n vertices. | |
Graph (int n) | |
Create undirected graph with n vertices. | |
~Graph () | |
Release graph memory. | |
void | load (char *fileName) |
Load up the graph encoded in the file. | |
const int | numVertices () const |
bool | directed () const |
bool | isEdge (int, int) const |
Does the edge (u,v) exist in the graph? | |
bool | isEdge (int, int, int &) const |
Does the edge (u,v) exist in the graph? And if so, what is its weight? | |
int | edgeWeight (int, int) const |
Return edge weight, or INT_MIN if not present. | |
VertexList::const_iterator | begin (int u) const |
VertexList::const_iterator | end (int u) const |
void | addEdge (int u, int v) |
void | addEdge (int, int, int) |
Add edge to graph structure from (u,v). | |
bool | removeEdge (int, int) |
Remove edge, and if undirected, remove its opposite as well. | |
Protected Attributes | |
VertexList * | vertices_ |
int | n_ |
bool | directed_ |
Graph::Graph | ( | ) | [inline] |
Create empty undirected graph.
Graph::Graph | ( | int | n, | |
bool | d | |||
) | [inline] |
Create directed graphs with n vertices.
Graph::Graph | ( | int | n | ) | [inline] |
Create undirected graph with n vertices.
Graph::~Graph | ( | ) | [inline] |
Release graph memory.
void Graph::addEdge | ( | int | u, | |
int | v, | |||
int | w | |||
) |
Add edge to graph structure from (u,v).
If the graph is undirected, then we must add in reverse as well. It is up to user to ensure that no edge already exists. The check will not be performed here.
u | integer identifier of a vertex | |
v | integer identifier of a vertex | |
w | planned weight. |
Reimplemented in GraphList.
void Graph::addEdge | ( | int | u, | |
int | v | |||
) | [inline] |
VertexList::const_iterator Graph::begin | ( | int | u | ) | const [inline] |
bool Graph::directed | ( | ) | const [inline] |
int Graph::edgeWeight | ( | int | u, | |
int | v | |||
) | const |
Return edge weight, or INT_MIN if not present.
u | integer identifier of a vertex | |
v | integer identifier of a vertex |
VertexList::const_iterator Graph::end | ( | int | u | ) | const [inline] |
bool Graph::isEdge | ( | int | u, | |
int | v, | |||
int & | w | |||
) | const |
Does the edge (u,v) exist in the graph? And if so, what is its weight?
u | integer identifier of a vertex | |
v | integer identifier of a vertex | |
w | returned weight of the edge, should it exist |
bool Graph::isEdge | ( | int | u, | |
int | v | |||
) | const |
Does the edge (u,v) exist in the graph?
u | integer identifier of a vertex | |
v | integer identifier of a vertex |
void Graph::load | ( | char * | fileName | ) |
Load up the graph encoded in the file.
File contains:
Header V E v1,v2 v1,v5 ...
fileName | contains the graph information. |
const int Graph::numVertices | ( | ) | const [inline] |
bool Graph::removeEdge | ( | int | u, | |
int | v | |||
) |
Remove edge, and if undirected, remove its opposite as well.
u | integer identifier of a vertex | |
v | integer identifier of a vertex |
Reimplemented in GraphList.
bool Graph::directed_ [protected] |
int Graph::n_ [protected] |
VertexList* Graph::vertices_ [protected] |