-
Notifications
You must be signed in to change notification settings - Fork 0
graph
template <class value_type> struct graph
This structure implements a graph of labeled nodes with unlabeled arcs. The nodes are stored as a linked list and the arcs are stored as an array of iterators at each graph node.
We use a linked list to store the nodes so that the arcs aren't invalidated every time we add or remove a node. Furthermore, the arcs are unlabeled because a graph with labeled arcs can be implemented by a bipartite graph with unlabeled arcs.
struct iteratorstruct const_iteratortypedef array<iterator> linkstypedef array<const_iterator> const_linkstypedef array<iterator>::iterator link_iteratortypedef array<const_iterator>::iterator const_link_iteratortypedef array<iterator>::const_iterator link_const_iteratortypedef array<const_iterator>::const_iterator const_link_const_iteratorstruct end_nodestruct node
-
end_node left, rightimplements the linked list of nodes
graph()The default constructor sets up the linked list of nodes the same way index_list does.
graph(const graph<value_type> ©)Copy the contents of another graph into this one.
void clear()
Deletes all of the nodes in this graph, making it empty.
int size()
Returns the number of nodes in this graph.
iterator begin()
const_iterator begin() constReturns an iterator to the first node in the list.
iterator end()
const_iterator end() constreturns an iterator to one after the last node in the list.
iterator rbegin()
const_iterator rbegin() constreturns an iterator to the last node in the list.
iterator rend()
const_iterator rend() constreturns an iterator to one before the first node in the list.
links next(const links &curr)
const_links next(const const_links &curr)Get the nodes proceeding one or more nodes in curr in the graph by following outgoing arcs.
links prev(const links &curr)
const_links prev(const const_links &curr)Get the nodes preceding one or more nodes in curr in the graph by following incoming arcs.
map<iterator, array<link_iterator> > next_conj(links curr)Map each node proceeding one or more nodes in curr to the nodes it proceeds.
map<iterator, array<link_iterator> > prev_conj(links curr)Map each node preceding one or more nodes in curr to the nodes it preceeds.
iterator insert(const value_type &value)Create a new node in the graph.
graph<value_type> &operator=(const graph<value_type> ©)Copy one graph to another.
void update_index(end_node *loc)Update the node indices after modifying the graph.