[Lemon-commits] Peter Kovacs: Various improvements and fixes (ma...
Lemon HG
hg at lemon.cs.elte.hu
Tue Apr 14 11:42:46 CEST 2009
details: http://lemon.cs.elte.hu/hg/lemon/rev/d11bf7998905
changeset: 611:d11bf7998905
user: Peter Kovacs <kpeter [at] inf.elte.hu>
date: Tue Apr 14 10:33:17 2009 +0200
description:
Various improvements and fixes (mainly in the doc) (#190)
diffstat:
lemon/adaptors.h | 3 +
lemon/concepts/graph_components.h | 867 ++++++++++++++++++++--------------------
2 files changed, 441 insertions(+), 429 deletions(-)
diffs (truncated from 1611 to 300 lines):
diff --git a/lemon/adaptors.h b/lemon/adaptors.h
--- a/lemon/adaptors.h
+++ b/lemon/adaptors.h
@@ -2192,6 +2192,9 @@
typedef typename ItemSetTraits<DGR, Edge>::ItemNotifier EdgeNotifier;
EdgeNotifier& notifier(Edge) const { return _digraph->notifier(Edge()); }
+
+ typedef EdgeNotifier ArcNotifier;
+ ArcNotifier& notifier(Arc) const { return _digraph->notifier(Edge()); }
protected:
diff --git a/lemon/concepts/graph_components.h b/lemon/concepts/graph_components.h
--- a/lemon/concepts/graph_components.h
+++ b/lemon/concepts/graph_components.h
@@ -31,17 +31,16 @@
namespace lemon {
namespace concepts {
- /// \brief Skeleton class for graph Node and Arc types
+ /// \brief Concept class for \c Node, \c Arc and \c Edge types.
///
- /// This class describes the interface of Node and Arc (and Edge
- /// in undirected graphs) subtypes of graph types.
+ /// This class describes the concept of \c Node, \c Arc and \c Edge
+ /// subtypes of digraph and graph types.
///
/// \note This class is a template class so that we can use it to
- /// create graph skeleton classes. The reason for this is than Node
- /// and Arc types should \em not derive from the same base class.
- /// For Node you should instantiate it with character 'n' and for Arc
- /// with 'a'.
-
+ /// create graph skeleton classes. The reason for this is that \c Node
+ /// and \c Arc (or \c Edge) types should \e not derive from the same
+ /// base class. For \c Node you should instantiate it with character
+ /// \c 'n', for \c Arc with \c 'a' and for \c Edge with \c 'e'.
#ifndef DOXYGEN
template <char sel = '0'>
#endif
@@ -49,45 +48,49 @@
public:
/// \brief Default constructor.
///
+ /// Default constructor.
/// \warning The default constructor is not required to set
/// the item to some well-defined value. So you should consider it
/// as uninitialized.
GraphItem() {}
+
/// \brief Copy constructor.
///
/// Copy constructor.
+ GraphItem(const GraphItem &) {}
+
+ /// \brief Constructor for conversion from \c INVALID.
///
- GraphItem(const GraphItem &) {}
- /// \brief Invalid constructor \& conversion.
- ///
- /// This constructor initializes the item to be invalid.
+ /// Constructor for conversion from \c INVALID.
+ /// It initializes the item to be invalid.
/// \sa Invalid for more details.
GraphItem(Invalid) {}
- /// \brief Assign operator for nodes.
+
+ /// \brief Assignment operator.
///
- /// The nodes are assignable.
- ///
- GraphItem& operator=(GraphItem const&) { return *this; }
+ /// Assignment operator for the item.
+ GraphItem& operator=(const GraphItem&) { return *this; }
+
/// \brief Equality operator.
///
- /// Two iterators are equal if and only if they represents the
- /// same node in the graph or both are invalid.
- bool operator==(GraphItem) const { return false; }
+ /// Equality operator.
+ bool operator==(const GraphItem&) const { return false; }
+
/// \brief Inequality operator.
///
- /// \sa operator==(const Node& n)
+ /// Inequality operator.
+ bool operator!=(const GraphItem&) const { return false; }
+
+ /// \brief Ordering operator.
///
- bool operator!=(GraphItem) const { return false; }
-
- /// \brief Artificial ordering operator.
- ///
- /// To allow the use of graph descriptors as key type in std::map or
- /// similar associative container we require this.
+ /// This operator defines an ordering of the items.
+ /// It makes possible to use graph item types as key types in
+ /// associative containers (e.g. \c std::map).
///
/// \note This operator only have to define some strict ordering of
/// the items; this order has nothing to do with the iteration
/// ordering of the items.
- bool operator<(GraphItem) const { return false; }
+ bool operator<(const GraphItem&) const { return false; }
template<typename _GraphItem>
struct Constraints {
@@ -99,7 +102,6 @@
i1 = i2 = i3;
bool b;
- // b = (ia == ib) && (ia != ib) && (ia < ib);
b = (ia == ib) && (ia != ib);
b = (ia == INVALID) && (ib != INVALID);
b = (ia < ib);
@@ -110,13 +112,12 @@
};
};
- /// \brief An empty base directed graph class.
+ /// \brief Base skeleton class for directed graphs.
///
- /// This class provides the minimal set of features needed for a
- /// directed graph structure. All digraph concepts have to
- /// conform to this base directed graph. It just provides types
- /// for nodes and arcs and functions to get the source and the
- /// target of the arcs.
+ /// This class describes the base interface of directed graph types.
+ /// All digraph %concepts have to conform to this class.
+ /// It just provides types for nodes and arcs and functions
+ /// to get the source and the target nodes of arcs.
class BaseDigraphComponent {
public:
@@ -124,31 +125,27 @@
/// \brief Node class of the digraph.
///
- /// This class represents the Nodes of the digraph.
- ///
+ /// This class represents the nodes of the digraph.
typedef GraphItem<'n'> Node;
/// \brief Arc class of the digraph.
///
- /// This class represents the Arcs of the digraph.
+ /// This class represents the arcs of the digraph.
+ typedef GraphItem<'a'> Arc;
+
+ /// \brief Return the source node of an arc.
///
- typedef GraphItem<'e'> Arc;
+ /// This function returns the source node of an arc.
+ Node source(const Arc&) const { return INVALID; }
- /// \brief Gives back the target node of an arc.
+ /// \brief Return the target node of an arc.
///
- /// Gives back the target node of an arc.
+ /// This function returns the target node of an arc.
+ Node target(const Arc&) const { return INVALID; }
+
+ /// \brief Return the opposite node on the given arc.
///
- Node target(const Arc&) const { return INVALID;}
-
- /// \brief Gives back the source node of an arc.
- ///
- /// Gives back the source node of an arc.
- ///
- Node source(const Arc&) const { return INVALID;}
-
- /// \brief Gives back the opposite node on the given arc.
- ///
- /// Gives back the opposite node on the given arc.
+ /// This function returns the opposite node on the given arc.
Node oppositeNode(const Node&, const Arc&) const {
return INVALID;
}
@@ -174,91 +171,96 @@
};
};
- /// \brief An empty base undirected graph class.
+ /// \brief Base skeleton class for undirected graphs.
///
- /// This class provides the minimal set of features needed for an
- /// undirected graph structure. All undirected graph concepts have
- /// to conform to this base graph. It just provides types for
- /// nodes, arcs and edges and functions to get the
- /// source and the target of the arcs and edges,
- /// conversion from arcs to edges and function to get
- /// both direction of the edges.
+ /// This class describes the base interface of undirected graph types.
+ /// All graph %concepts have to conform to this class.
+ /// It extends the interface of \ref BaseDigraphComponent with an
+ /// \c Edge type and functions to get the end nodes of edges,
+ /// to convert from arcs to edges and to get both direction of edges.
class BaseGraphComponent : public BaseDigraphComponent {
public:
typedef BaseDigraphComponent::Node Node;
typedef BaseDigraphComponent::Arc Arc;
- /// \brief Undirected arc class of the graph.
+
+ /// \brief Undirected edge class of the graph.
///
- /// This class represents the edges of the graph.
- /// The undirected graphs can be used as a directed graph which
- /// for each arc contains the opposite arc too so the graph is
- /// bidirected. The edge represents two opposite
- /// directed arcs.
- class Edge : public GraphItem<'u'> {
+ /// This class represents the undirected edges of the graph.
+ /// Undirected graphs can be used as directed graphs, each edge is
+ /// represented by two opposite directed arcs.
+ class Edge : public GraphItem<'e'> {
public:
- typedef GraphItem<'u'> Parent;
+ typedef GraphItem<'e'> Parent;
+
/// \brief Default constructor.
///
+ /// Default constructor.
/// \warning The default constructor is not required to set
/// the item to some well-defined value. So you should consider it
/// as uninitialized.
Edge() {}
+
/// \brief Copy constructor.
///
/// Copy constructor.
+ Edge(const Edge &) : Parent() {}
+
+ /// \brief Constructor for conversion from \c INVALID.
///
- Edge(const Edge &) : Parent() {}
- /// \brief Invalid constructor \& conversion.
- ///
- /// This constructor initializes the item to be invalid.
+ /// Constructor for conversion from \c INVALID.
+ /// It initializes the item to be invalid.
/// \sa Invalid for more details.
Edge(Invalid) {}
- /// \brief Converter from arc to edge.
+
+ /// \brief Constructor for conversion from an arc.
///
+ /// Constructor for conversion from an arc.
/// Besides the core graph item functionality each arc should
/// be convertible to the represented edge.
Edge(const Arc&) {}
- /// \brief Assign arc to edge.
+
+ /// \brief Assign an arc to an edge.
///
+ /// This function assigns an arc to an edge.
/// Besides the core graph item functionality each arc should
/// be convertible to the represented edge.
Edge& operator=(const Arc&) { return *this; }
};
- /// \brief Returns the direction of the arc.
+ /// \brief Return one end node of an edge.
+ ///
+ /// This function returns one end node of an edge.
+ Node u(const Edge&) const { return INVALID; }
+
+ /// \brief Return the other end node of an edge.
+ ///
+ /// This function returns the other end node of an edge.
+ Node v(const Edge&) const { return INVALID; }
+
+ /// \brief Return a directed arc related to an edge.
+ ///
+ /// This function returns a directed arc from its direction and the
+ /// represented edge.
+ Arc direct(const Edge&, bool) const { return INVALID; }
+
+ /// \brief Return a directed arc related to an edge.
+ ///
+ /// This function returns a directed arc from its source node and the
+ /// represented edge.
+ Arc direct(const Edge&, const Node&) const { return INVALID; }
+
+ /// \brief Return the direction of the arc.
///
/// Returns the direction of the arc. Each arc represents an
/// edge with a direction. It gives back the
/// direction.
bool direction(const Arc&) const { return true; }
- /// \brief Returns the directed arc.
+ /// \brief Return the opposite arc.
///
- /// Returns the directed arc from its direction and the
- /// represented edge.
- Arc direct(const Edge&, bool) const { return INVALID;}
More information about the Lemon-commits
mailing list