edge Class Reference

An edge in a graph. More...

List of all members.

Public Member Functions

 edge ()
node source () const
node target () const
void reverse ()
void change_source (node n)
void change_target (node n)
const nodeopposite (node n) const
bool is_hidden () const

Friends

class graph
class node


Detailed Description

An edge in a graph.

Constructor & Destructor Documentation

edge::edge (  ) 

Default constructor. Creates an invalid edge. The only way to obtain a valid edge is through graph::new_edge. Example:

   graph g;
   node n1, n2;
   edge e;

   n1 = g.new_node();
   n2 = g.new_node();
   e = g.new_edge(n1, n2);
 

See also:
graph::new_edge


Member Function Documentation

node edge::source (  )  const

Returns the source node of the edge.

Returns:
source

node edge::target (  )  const

Returns the target node of the edge.

Returns:
target

void edge::reverse (  ) 

Changes the direction of this edge.

void edge::change_source ( node  n  ) 

Makes n the source of this edge. Takes O(1) time.

Parameters:
<code>n</code> new source

void edge::change_target ( node  n  ) 

Makes n the target of this edge. Takes O(1) time.

Parameters:
<code>n</code> new target

const node& edge::opposite ( node  n  )  const

Returns the node opposite to n referring to this edge.

Parameters:
<code>n</code> a node incident to this edge

bool edge::is_hidden (  )  const

Returns true iff node is hidden.

Returns:
true iff node is hidden.
See also:
graph::hide_edge

graph::restore_edge