lemon/graph_utils.h
changeset 2510 bb523a4758f7
parent 2485 88aa7870756a
child 2534 edad4c3e926d
equal deleted inserted replaced
67:fbf765cdfbaf 68:4314a52392e3
    47   ///This \c \#define creates convenience typedefs for the following types
    47   ///This \c \#define creates convenience typedefs for the following types
    48   ///of \c Graph: \c Node,  \c NodeIt, \c Edge, \c EdgeIt, \c InEdgeIt,
    48   ///of \c Graph: \c Node,  \c NodeIt, \c Edge, \c EdgeIt, \c InEdgeIt,
    49   ///\c OutEdgeIt
    49   ///\c OutEdgeIt
    50   ///\note If \c G it a template parameter, it should be used in this way.
    50   ///\note If \c G it a template parameter, it should be used in this way.
    51   ///\code
    51   ///\code
    52   ///  GRAPH_TYPEDEFS(typename G)
    52   ///  GRAPH_TYPEDEFS(typename G);
    53   ///\endcode
    53   ///\endcode
    54   ///
    54   ///
    55   ///\warning There are no typedefs for the graph maps because of the lack of
    55   ///\warning There are no typedefs for the graph maps because of the lack of
    56   ///template typedefs in C++.
    56   ///template typedefs in C++.
    57 #define GRAPH_TYPEDEFS(Graph)				\
    57 #define GRAPH_TYPEDEFS(Graph)				\
    58   typedef Graph::     Node      Node;			\
    58   typedef Graph::     Node      Node;			\
    59     typedef Graph::   NodeIt    NodeIt;			\
    59     typedef Graph::   NodeIt    NodeIt;			\
    60     typedef Graph::   Edge      Edge;			\
    60     typedef Graph::   Edge      Edge;			\
    61     typedef Graph::   EdgeIt    EdgeIt;			\
    61     typedef Graph::   EdgeIt    EdgeIt;			\
    62     typedef Graph:: InEdgeIt  InEdgeIt;			\
    62     typedef Graph:: InEdgeIt  InEdgeIt;			\
    63     typedef Graph::OutEdgeIt OutEdgeIt;			
    63     typedef Graph::OutEdgeIt OutEdgeIt
    64 
    64 
    65   ///Creates convenience typedefs for the undirected graph types and iterators
    65   ///Creates convenience typedefs for the undirected graph types and iterators
    66 
    66 
    67   ///This \c \#define creates the same convenience typedefs as defined by
    67   ///This \c \#define creates the same convenience typedefs as defined by
    68   ///\ref GRAPH_TYPEDEFS(Graph) and three more, namely it creates
    68   ///\ref GRAPH_TYPEDEFS(Graph) and three more, namely it creates
    69   ///\c UEdge, \c UEdgeIt, \c IncEdgeIt,
    69   ///\c UEdge, \c UEdgeIt, \c IncEdgeIt,
    70   ///
    70   ///
    71   ///\note If \c G it a template parameter, it should be used in this way.
    71   ///\note If \c G it a template parameter, it should be used in this way.
    72   ///\code
    72   ///\code
    73   ///  UGRAPH_TYPEDEFS(typename G)
    73   ///  UGRAPH_TYPEDEFS(typename G);
    74   ///\endcode
    74   ///\endcode
    75   ///
    75   ///
    76   ///\warning There are no typedefs for the graph maps because of the lack of
    76   ///\warning There are no typedefs for the graph maps because of the lack of
    77   ///template typedefs in C++.
    77   ///template typedefs in C++.
    78 #define UGRAPH_TYPEDEFS(Graph)				\
    78 #define UGRAPH_TYPEDEFS(Graph)				\
    79   GRAPH_TYPEDEFS(Graph)						\
    79   GRAPH_TYPEDEFS(Graph);				\
    80     typedef Graph:: UEdge   UEdge;			\
    80     typedef Graph:: UEdge   UEdge;			\
    81     typedef Graph:: UEdgeIt UEdgeIt;			\
    81     typedef Graph:: UEdgeIt UEdgeIt;			\
    82     typedef Graph:: IncEdgeIt   IncEdgeIt;		       
    82     typedef Graph:: IncEdgeIt   IncEdgeIt
    83 
    83 
    84   ///\brief Creates convenience typedefs for the bipartite undirected graph 
    84   ///\brief Creates convenience typedefs for the bipartite undirected graph 
    85   ///types and iterators
    85   ///types and iterators
    86 
    86 
    87   ///This \c \#define creates the same convenience typedefs as defined by
    87   ///This \c \#define creates the same convenience typedefs as defined by
    88   ///\ref UGRAPH_TYPEDEFS(Graph) and two more, namely it creates
    88   ///\ref UGRAPH_TYPEDEFS(Graph) and two more, namely it creates
    89   ///\c ANodeIt, \c BNodeIt, 
    89   ///\c ANodeIt, \c BNodeIt, 
    90   ///
    90   ///
    91   ///\note If \c G it a template parameter, it should be used in this way.
    91   ///\note If \c G it a template parameter, it should be used in this way.
    92   ///\code
    92   ///\code
    93   ///  BPUGRAPH_TYPEDEFS(typename G)
    93   ///  BPUGRAPH_TYPEDEFS(typename G);
    94   ///\endcode
    94   ///\endcode
    95   ///
    95   ///
    96   ///\warning There are no typedefs for the graph maps because of the lack of
    96   ///\warning There are no typedefs for the graph maps because of the lack of
    97   ///template typedefs in C++.
    97   ///template typedefs in C++.
    98 #define BPUGRAPH_TYPEDEFS(Graph)            \
    98 #define BPUGRAPH_TYPEDEFS(Graph)            \
    99   UGRAPH_TYPEDEFS(Graph)                    \
    99   UGRAPH_TYPEDEFS(Graph);		    \
   100     typedef Graph::ANode ANode;             \
   100     typedef Graph::ANode ANode;             \
   101     typedef Graph::BNode BNode;             \
   101     typedef Graph::BNode BNode;             \
   102     typedef Graph::ANodeIt ANodeIt;	    \
   102     typedef Graph::ANodeIt ANodeIt;	    \
   103     typedef Graph::BNodeIt BNodeIt;
   103     typedef Graph::BNodeIt BNodeIt
   104 
   104 
   105   /// \brief Function to count the items in the graph.
   105   /// \brief Function to count the items in the graph.
   106   ///
   106   ///
   107   /// This function counts the items (nodes, edges etc) in the graph.
   107   /// This function counts the items (nodes, edges etc) in the graph.
   108   /// The complexity of the function is O(n) because
   108   /// The complexity of the function is O(n) because
  2490   ///\sa AllEdgeLookUp  
  2490   ///\sa AllEdgeLookUp  
  2491   template<class G>
  2491   template<class G>
  2492   class EdgeLookUp 
  2492   class EdgeLookUp 
  2493   {
  2493   {
  2494   public:
  2494   public:
  2495     GRAPH_TYPEDEFS(typename G)
  2495     GRAPH_TYPEDEFS(typename G);
  2496     typedef G Graph;
  2496     typedef G Graph;
  2497 
  2497 
  2498   protected:
  2498   protected:
  2499     const Graph &_g;
  2499     const Graph &_g;
  2500     typename Graph::template NodeMap<Edge> _head;
  2500     typename Graph::template NodeMap<Edge> _head;
  2606     using EdgeLookUp<G>::_g;
  2606     using EdgeLookUp<G>::_g;
  2607     using EdgeLookUp<G>::_right;
  2607     using EdgeLookUp<G>::_right;
  2608     using EdgeLookUp<G>::_left;
  2608     using EdgeLookUp<G>::_left;
  2609     using EdgeLookUp<G>::_head;
  2609     using EdgeLookUp<G>::_head;
  2610 
  2610 
  2611     GRAPH_TYPEDEFS(typename G)
  2611     GRAPH_TYPEDEFS(typename G);
  2612     typedef G Graph;
  2612     typedef G Graph;
  2613     
  2613     
  2614     typename Graph::template EdgeMap<Edge> _next;
  2614     typename Graph::template EdgeMap<Edge> _next;
  2615     
  2615     
  2616     Edge refreshNext(Edge head,Edge next=INVALID)
  2616     Edge refreshNext(Edge head,Edge next=INVALID)