| lab_flow
    Foreboding Flow | 
Represents a graph; used by the GraphTools class. More...
#include <graph.h>
| Public Member Functions | |
| Graph (bool weighted) | |
| Constructor to create an empty graph.  More... | |
| Graph (bool weighted, bool directed) | |
| Constructor to create an empty graph.  More... | |
| Graph (bool weighted, int numVertices, unsigned long seed) | |
| Constructor to create a random, connected graph.  More... | |
| vector< Vertex > | getAdjacent (Vertex source) const | 
| Gets all adjacent vertices to the parameter vertex.  More... | |
| Vertex | getStartingVertex () const | 
| Returns one vertex in the graph.  More... | |
| vector< Vertex > | getVertices () const | 
| Gets all vertices in the graph.  More... | |
| Edge | getEdge (Vertex source, Vertex destination) const | 
| Gets an edge between two vertices.  More... | |
| vector< Edge > | getEdges () const | 
| Gets all the edges in the graph.  More... | |
| bool | vertexExists (Vertex v) const | 
| Checks if the given vertex exists.  More... | |
| bool | edgeExists (Vertex source, Vertex destination) const | 
| Checks if edge exists between two vertices exists.  More... | |
| Edge | setEdgeLabel (Vertex source, Vertex destination, string label) | 
| Sets the edge label of the edge between vertices u and v.  More... | |
| string | getEdgeLabel (Vertex source, Vertex destination) const | 
| Gets the edge label of the edge between vertices u and v.  More... | |
| int | getEdgeWeight (Vertex source, Vertex destination) const | 
| Gets the weight of the edge between two vertices.  More... | |
| void | insertVertex (Vertex v) | 
| Inserts a new vertex into the graph and initializes its label as "".  More... | |
| Vertex | removeVertex (Vertex v) | 
| Removes a given vertex from the graph.  More... | |
| bool | insertEdge (Vertex source, Vertex destination) | 
| Inserts an edge between two vertices.  More... | |
| Edge | removeEdge (Vertex source, Vertex destination) | 
| Removes the edge between two vertices.  More... | |
| Edge | setEdgeWeight (Vertex source, Vertex destination, int weight) | 
| Sets the weight of the edge between two vertices.  More... | |
| void | initSnapshot (string title) | 
| Creates a name for snapshots of the graph.  More... | |
| void | snapshot () | 
| Saves a snapshot of the graph to file.  More... | |
| void | print () const | 
| Prints the graph to stdout.  More... | |
| void | savePNG (string title) const | 
| Saves the graph as a PNG image.  More... | |
| bool | isDirected () const | 
| void | clear () | 
| Static Public Attributes | |
| static const Vertex | InvalidVertex = "_CS225INVALIDVERTEX" | 
| static const Edge | InvalidEdge = Edge(Graph::InvalidVertex, Graph::InvalidVertex, Graph::InvalidWeight, Graph::InvalidLabel) | 
| static const int | InvalidWeight = INT_MIN | 
| static const string | InvalidLabel = "_CS225INVALIDLABEL" | 
| Private Member Functions | |
| bool | assertVertexExists (Vertex v, string functionName) const | 
| Returns whether a given vertex exists in the graph.  More... | |
| bool | assertEdgeExists (Vertex source, Vertex destination, string functionName) const | 
| Returns whether thee edge exists in the graph.  More... | |
| void | error (string message) const | 
| Prints a graph error and quits the program.  More... | |
| Private Attributes | |
| unordered_map< Vertex, unordered_map< Vertex, Edge > > | adjacency_list | 
| bool | weighted | 
| bool | directed | 
| Random | random | 
| int | picNum | 
| string | picName | 
Represents a graph; used by the GraphTools class.
| Graph::Graph | ( | bool | weighted | ) | 
Constructor to create an empty graph.
| weighted | - specifies whether the graph is a weighted graph or not | 
| Graph::Graph | ( | bool | weighted, | 
| bool | directed | ||
| ) | 
Constructor to create an empty graph.
| weighted | - specifies whether the graph is a weighted graph or not | 
| directed | - specifies whether the graph is directed | 
| Graph::Graph | ( | bool | weighted, | 
| int | numVertices, | ||
| unsigned long | seed | ||
| ) | 
Constructor to create a random, connected graph.
| weighted | - specifies whether the graph is a weighted graph or not | 
| numVertices | - the number of vertices the graph will have | 
| seed | - a random seed to create the graph with | 
| 
 | private | 
Returns whether thee edge exists in the graph.
| source | - one vertex | 
| destination | - another vertex | 
| functionName | - the name of the calling function to return in the event of an error | 
| 
 | private | 
Returns whether a given vertex exists in the graph.
| v | - the vertex to check | 
| functionName | - the name of the calling function to return in the event of an error | 
| 
 | private | 
Prints a graph error and quits the program.
The program is exited with a segfault to provide a stack trace.
| message | - the error message that is printed | 
Gets all adjacent vertices to the parameter vertex.
| source | - vertex to get neighbors from | 
Gets an edge between two vertices.
| source | - one vertex the edge is connected to | 
| destination | - the other vertex the edge is connected to | 
Gets the edge label of the edge between vertices u and v.
| source | - one vertex the edge is connected to | 
| destination | - the other vertex the edge is connected to | 
| vector< Edge > Graph::getEdges | ( | ) | const | 
Gets all the edges in the graph.
Gets the weight of the edge between two vertices.
| source | - one vertex the edge is connected to | 
| destination | - the other vertex the edge is connected to | 
| Vertex Graph::getStartingVertex | ( | ) | const | 
Returns one vertex in the graph.
This function can be used to find a random vertex with which to start a traversal.
| vector< Vertex > Graph::getVertices | ( | ) | const | 
Gets all vertices in the graph.
| void Graph::initSnapshot | ( | string | title | ) | 
Creates a name for snapshots of the graph.
| title | - the name to save the snapshots as | 
Inserts an edge between two vertices.
A boolean is returned for use with the random graph generation. Hence, an error is not thrown when it fails to insert an edge.
| source | - one vertex the edge is connected to | 
| destination | - the other vertex the edge is connected to | 
| void Graph::insertVertex | ( | Vertex | v | ) | 
Inserts a new vertex into the graph and initializes its label as "".
| v | - the name for the vertex | 
| void Graph::print | ( | ) | const | 
Prints the graph to stdout.
Removes the edge between two vertices.
| source | - one vertex the edge is connected to | 
| destination | - the other vertex the edge is connected to | 
Removes a given vertex from the graph.
| v | - the vertex to remove | 
| void Graph::savePNG | ( | string | title | ) | const | 
Saves the graph as a PNG image.
| title | - the filename of the PNG image | 
Sets the edge label of the edge between vertices u and v.
| source | - one vertex the edge is connected to | 
| destination | - the other vertex the edge is connected to | 
Sets the weight of the edge between two vertices.
| source | - one vertex the edge is connected to | 
| destination | - the other vertex the edge is connected to | 
| weight | - the weight to set to the edge | 
| void Graph::snapshot | ( | ) | 
Saves a snapshot of the graph to file.
initSnapshot() must be run first.
| bool Graph::vertexExists | ( | Vertex | v | ) | const | 
Checks if the given vertex exists.