Template Class PointerGraph

Nested Relationships

Nested Types

Class Documentation

template<class T, class W = int>
class PointerGraph

an oriented graph of node objects linked by pointers

Public Functions

PointerGraph(void) = default
PointerGraph(const PointerGraph&) = delete
PointerGraph &operator=(const PointerGraph&) = delete
inline int n(void) const
Node *insertNode(const T &t)

a new isolated node of label t

Node *find(const T &t)

the first node of label t, nullptr if none

bool hasEdge(const Node *u, const Node *v) const
Pre:

u and v are nodes of the graph

void insertEdge(Node *u, Node *v, const W &w = W())

the edge ( u , v ) of weight w, if not there

Pre:

u and v are nodes of the graph

Post:

hasEdge( u , v )

void deleteEdge(Node *u, Node *v)
Pre:

u and v are nodes of the graph

Post:

! hasEdge( u , v )

bool deleteNode(Node *u)

deletes u if isolated; false otherwise

Pre:

u is a node of the graph

void forceDeleteNode(Node *u)

deletes the edges of u and then u

Pre:

u is a node of the graph

std::vector<Node*> adjacent(const Node *u) const

the nodes adjacent to u

Pre:

u is a node of the graph

template<class F>
void dfs(Node *r, F &&f)

the depth first visit from r, f on each node reached

Pre:

r is a node of the graph

template<class F>
void bfs(Node *r, F &&f)

the breadth first visit from r

Pre:

r is a node of the graph

struct Edge

an edge, to its other end

Public Members

Node *to
W weight
struct Node

a node

Public Members

T label
int degree = 0

the edges that enter or leave it

bool seen = false
std::list<Edge> out