Home | Documentation | Download | Platforms | Projects | Mailing Lists | Version History

- Main Page
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# topsort Class Reference

Topological sorting. More...

Inheritance diagram for topsort:

[legend]
Collaboration diagram for topsort:

[legend]

List of all members.

## Public Member Functions

| topsort ()
int | top_num (const node &n) const
bool | is_acyclic () const
topsort_iterator | top_order_begin () const
topsort_iterator | top_order_end () const
virtual int | check (graph &G)
virtual void | reset ()
virtual void | init_handler (graph &G)
| Handler called before the start of DFS.
virtual void | leave_handler (graph &, node &, node &)
| Handler called after all the adjacent edges of n have been examined.
virtual void | old_adj_node_handler (graph &, edge &, node &)
| Handler called when a already marked node n connected to the actual node by e is found during the search of all adjacent edges of the actual node.

## Detailed Description

Topological sorting.

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.

## Constructor & Destructor Documentation

topsort::topsort | ( |  | ) | `[inline]`

default constructor; enables scanning of the whole_graph.

See also:
  dfs::dfs

## Member Function Documentation

int topsort::top_num | ( | const node & | n | ) | const`[inline]`

Number in topological order.

Parameters:

  | <code>n</code> | node.

Returns:
  number in topological order.

bool topsort::is_acyclic | ( |  | ) | const`[inline]`

Tests if graph was acyclic.

Returns:
  true iff graph was acyclic.

topsort_iterator topsort::top_order_begin | ( |  | ) | const`[inline]`

Iterate through nodes in topsort-order.

Returns:
  start-iterator.

topsort_iterator topsort::top_order_end | ( |  | ) | const`[inline]`

Iterate through nodes in topsort-order.

Returns:
  end-iterator.

virtual int topsort::check | ( | graph & | G | ) | `[virtual]`

Preconditions:

- `G` is directed.
- DFS may be applied

Parameters:

  | <code>G</code> | graph.

Returns:
  `algorithm::GTL_OK` if topsort may be applied to `G`.

See also:
  dfs::check

Reimplemented from dfs.

virtual void topsort::reset | ( |  | ) | `[virtual]`

Reset

See also:
  dfs::reset

Reimplemented from dfs.

virtual void topsort::init_handler | ( | graph & | G | ) | `[virtual]`

Handler called before the start of DFS.

Parameters:

  | G | graph for which DFS was invoked.

Reimplemented from dfs.

virtual void topsort::leave_handler | ( | graph & | G,
|  | node & | n,
|  | node & | f |
| ) |  |  | `[virtual]`

Handler called after all the adjacent edges of n have been examined.

Parameters:

  | G | graph for which DFS was invoked.
  | n | actual node.
  | f | predecessor.

Reimplemented from dfs.

virtual void topsort::old_adj_node_handler | ( | graph & | G,
|  | edge & | e,
|  | node & | n |
| ) |  |  | `[virtual]`

Handler called when a already marked node n connected to the actual node by e is found during the search of all adjacent edges of the actual node.

Parameters:

  | G | graph for which DFS was invoked.
  | e | edge connecting the actual node to the old one.
  | n | used node.

Reimplemented from dfs.

University of Passau - FMI - Theoretical Computer Science

Design © 2002, 2003 Marcus Raitner, University of Passau