topsort Class Reference

[Index] [Hierarchy] [Headers]


Topological sorting. More...

#include <GTL/topsort.h>

Inherits: dfs

Public Members


Detailed Description

Assigns to each node n a number top_num such that for every edge (u,v) top_num[u] < top_num[v], if possible, i.e. iff the directed graph is acyclic.

Similar to the testing of biconnectivity, which extends DFS to calculate low-numbers, the topsort-algorithm extends DFS to calculate the new numbering (and thus to test whether such a numbering is possible).

In order to traverse all the nodes in the order of its top-numbers, a new iterator, topsort_iterator is provided.


topsort() [public]

default constructor; enables scanning of the whole_graph.

See Also:
dfs::dfs

int top_num(const node& n) const [public]

Number in topological order.

Parameters:
n node.
Returns:
number in topological order.

bool is_acyclic() const [public]

Tests if graph was acyclic.

Returns:
true iff graph was acyclic.

topsort_iterator top_order_begin() const [public]

Iterate through nodes in topsort-order.

Returns:
start-iterator.

topsort_iterator top_order_end() const [public]

Iterate through nodes in topsort-order.

Returns:
end-iterator.

int check(graph& G) [public virtual]

Preconditions:

Parameters:
G graph.
Returns:
algorithm::GTL_OK if topsort may be applied to G.
See Also:
dfs::check

void reset() [public virtual]

Reset

See Also:
dfs::reset

Kdoc