planarity Class Reference

Tests if a graph can be drawn on a plane without any edge crossings. More...

Inheritance diagram for planarity:

Inheritance graph
[legend]
Collaboration diagram for planarity:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 planarity ()
 Creates an object of the planarity test algorithm.
 ~planarity ()
 Destructor.
int check (graph &G)
 Checks whether planarity test can be applied to G.
int run (graph &G)
 Runs planarity test on G.
void reset ()
 Resets algorithm object, such that it can be applied to another graph.
void calc_embedding (bool p)
 If p is true a planar embedding will be calculated in the next run.
bool calc_embedding () const
 Returns true if a planar embedding will be calculated in the next run.
void calc_obstruction (bool p)
 If p is true the obstructions to planarity will be calculated in the next run.
bool calc_obstruction () const
 Returns true if the obstructions to planarity will be calculated in the next run.
void make_biconnected (bool p)
 Determines the strategy used to test a graph which is not biconnected.
bool make_biconnected () const
 Returns strategy for testing graphs, which are not biconnected.
bool is_planar () const
 Result of last test.
planar_embeddingget_embedding ()
 If graph in last run was planar a planar embedding is calculated during the reductions. This function gives access to it.
list< edge > & get_obstruction_edges ()
 Returns the edges of a subgraph homeomorphic to either K3,3 or K5 if graph in last run was not planar.
list< node > & get_obstruction_nodes ()
 Returns the nodes of a subgraph homeomorphic to either K3,3 or K5 if graph in last run was not planar.


Detailed Description

Tests if a graph can be drawn on a plane without any edge crossings.

Date
Revision

This class implements the Lempel-Even-Cederbaum planarity test using PQ-trees. In case the graph is planar a planar embedding is obtained, i.e. for each node in the graph an ordered adjacency list is calculated, such that there exists a planar drawing in which all adjacent edges around a node apply to this order.

If the graph is not planar Kuratowski's famous theorem states that it must contain a subgraph hoemeomorphic to either K5 (the complete graph with five nodes) or K3,3 (the complete bipartite graph with three nodes each side). In this case the nodes and edges of the tested graph that form either of these two are calculated.

In case the graph is planar and has $N$ nodes the algorithm needs $\mathcal{O}(N)$ time for the test (including the planar embedding). In case the graph isn't planar it needs at most $\mathcal{O}(E)$ time if $E$ is the number of edges for both the test and the detection of K5 or K3,3.


Constructor & Destructor Documentation

planarity::planarity (  ) 

Creates an object of the planarity test algorithm.

See also:
algorithm


Member Function Documentation

int planarity::check ( graph G  )  [virtual]

Checks whether planarity test can be applied to G.

This should return always GTL_OK. There aren't any restrictions on G, even multiple edges and selfloops are tolerated.

Note:
Selfloops and multiple edges will not be added to the planar embedding. planar_embedding::selfloops and planar_embedding::multiple_edges can be used to get these.
Parameters:
G arbitrary graph
Return values:
GTL_OK if planarity test can be applied
GTL_ERROR if not
See also:
algorithm::check

Implements algorithm.

int planarity::run ( graph G  )  [virtual]

Runs planarity test on G.

This should return always GTL_OK. The return value only tracks errors that might occur, it is definitly not the result of the test itself. The result of the test is stored in a member variable and can be accessed via is_planar.

Parameters:
G arbitrary graph
Return values:
GTL_OK if planarity test was sucessfully applied
GTL_ERROR if not
See also:
algorithm::run

Implements algorithm.

void planarity::reset (  )  [virtual]

Resets algorithm object, such that it can be applied to another graph.

See also:
algorithm::reset

Implements algorithm.

void planarity::calc_embedding ( bool  p  )  [inline]

If p is true a planar embedding will be calculated in the next run.

Parameters:
p true iff embedding should be calculated
See also:
get_embedding

planar_embedding

bool planarity::calc_embedding (  )  const [inline]

Returns true if a planar embedding will be calculated in the next run.

Return values:
true iff embedding will be calculated
See also:
get_embedding

planar_embedding

void planarity::calc_obstruction ( bool  p  )  [inline]

If p is true the obstructions to planarity will be calculated in the next run.

This implies the calculation of an embedding.

Parameters:
p true iff obstructions to planarity should be calculated
See also:
get_obstruction_edges

get_obstruction_nodes

bool planarity::calc_obstruction (  )  const [inline]

Returns true if the obstructions to planarity will be calculated in the next run.

Return values:
true iff obstructions to planarity will be calculated
See also:
get_obstruction_edges

get_obstruction_nodes

void planarity::make_biconnected ( bool  p  )  [inline]

Determines the strategy used to test a graph which is not biconnected.

If this is enabled the graph will be made biconnected by adding some new edges. This is usually faster than testing the biconnected components one by one, which is done if this option is disabled. By default this is enabled.

Note:
This is not fully tested, i.e. at the moment this feature should be used only for the test without embedding or kuratowski graphs.
Parameters:
p true iff graph should be made biconnected
See also:
biconnectivity::make_biconnected

bool planarity::make_biconnected (  )  const [inline]

Returns strategy for testing graphs, which are not biconnected.

Return values:
true iff graph will be made biconnected before test
See also:
biconnectivity::make_biconnected

bool planarity::is_planar (  )  const [inline]

Result of last test.

Return values:
true iff graph in last run was planar.

planar_embedding& planarity::get_embedding (  )  [inline]

If graph in last run was planar a planar embedding is calculated during the reductions. This function gives access to it.

Returns:
planar embedding of graph in last run
See also:
calc_embedding

list<edge>& planarity::get_obstruction_edges (  )  [inline]

Returns the edges of a subgraph homeomorphic to either K3,3 or K5 if graph in last run was not planar.

Returns:
edges of subgraph homeomorphic to either K3,3 or K5
See also:
get_obstruction_nodes

calc_obstruction

list<node>& planarity::get_obstruction_nodes (  )  [inline]

Returns the nodes of a subgraph homeomorphic to either K3,3 or K5 if graph in last run was not planar.

Returns:
nodes of subgraph homeomorphic to either K3,3 or K5
See also:
get_obstruction_edges

calc_obstruction