Data Structures & Algorithms in C++
Goodrich, Tamassia, Mount and Goldwasser
|
#include <graph.h>
Data Structures | |
class | Edge |
Edge instance serves as a token for an underlying edge. More... | |
struct | EdgeHash |
Hash functor that allows use of Edge as an unordered set/map key. More... | |
class | Vertex |
Vertex instance serves as a token for an underlying vertex. More... | |
struct | VertexHash |
Hash functor that allows use of Vertex as an unordered set/map key. More... | |
Public Member Functions | |
Graph (bool is_directed) | |
Creates a new graph (directed or undirected, as specified by argument) | |
bool | is_directed () const |
Returns true if graph is directed, false otherwise. | |
int | num_vertices () const |
Returns the number of vertices in the graph. | |
int | num_edges () const |
Returns the number of edges in the graph. | |
std::list< Vertex > | vertices () const |
Returns a list of Vertex tokens. | |
std::list< Edge > | edges () const |
Returns a list of Edge tokens. | |
bool | has_edge (Vertex u, Vertex v) const |
Return true if there exists an edge from u to v, false otherwise. | |
Edge | get_edge (Vertex u, Vertex v) const |
Return the edge from u to v; undefined behavior if no such edge exists. | |
int | degree (Vertex v, bool outgoing=true) const |
Returns the number of outgoing (or incoming) edges for Vertex v. | |
std::list< Vertex > | neighbors (Vertex v, bool outgoing=true) const |
Returns a list of outgoing (or incoming) Vertex tokens for neighbors of Vertex v. | |
std::list< Edge > | incident_edges (Vertex v, bool outgoing=true) const |
Returns a list of outgoing (or incoming) Edge tokens for Vertex v. | |
std::pair< Vertex, Vertex > | endpoints (Edge e) const |
Returns the (origin,destination) pair for Edge e. | |
Vertex | opposite (Edge e, Vertex v) const |
Returns the opposite endpoint to Vertex v for Edge e. | |
Vertex | insert_vertex (V elem) |
Create a new vertex storing given element, and return Vertex token. | |
Edge | insert_edge (Vertex u, Vertex v, int weight=1, E elem=E()) |
void | erase (Edge e) |
void | erase (Vertex v) |
Graph (const Graph &other) | |
Copy constructor. | |
Graph & | operator= (const Graph &other) |
Copy assignment. | |
Graph (Graph &&)=default | |
Move constructor. | |
Graph & | operator= (Graph &&)=default |
Move assignment. | |
~Graph ()=default | |
Destructs a graph. | |
|
inline |
Creates a new graph (directed or undirected, as specified by argument)
|
inline |
Copy constructor.
|
default |
Move constructor.
|
default |
Destructs a graph.
|
inline |
Returns the number of outgoing (or incoming) edges for Vertex v.
|
inline |
Returns a list of Edge tokens.
|
inline |
Returns the (origin,destination) pair for Edge e.
|
inline |
|
inline |
|
inline |
Return the edge from u to v; undefined behavior if no such edge exists.
|
inline |
Return true if there exists an edge from u to v, false otherwise.
|
inline |
|
inline |
Inserts new edge from u to v, storing given element, and given weight (default 1) If edge already exists, updates weight and element for that existing edge. Returns Edge token
|
inline |
Create a new vertex storing given element, and return Vertex token.
|
inline |
Returns true if graph is directed, false otherwise.
|
inline |
|
inline |
Returns the number of edges in the graph.
|
inline |
Returns the number of vertices in the graph.
|
inline |
Copy assignment.
|
default |
Move assignment.
|
inline |
|
inline |
Returns a list of Vertex tokens.