src/lemon/map_bits.h
author marci
Fri, 01 Oct 2004 11:31:03 +0000
changeset 933 1b7c88fbb950
parent 919 6153d9cf78c6
child 937 d4e911acef3d
permissions -rw-r--r--
NodeSubGraphWrapper, test, and ducumentation modifications.
alpar@906
     1
/* -*- C++ -*-
alpar@921
     2
 * src/lemon/map_bits.h - Part of LEMON, a generic C++ optimization library
alpar@906
     3
 *
alpar@906
     4
 * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@906
     5
 * (Egervary Combinatorial Optimization Research Group, EGRES).
alpar@906
     6
 *
alpar@906
     7
 * Permission to use, modify and distribute this software is granted
alpar@906
     8
 * provided that this copyright notice appears in all copies. For
alpar@906
     9
 * precise terms see the accompanying LICENSE file.
alpar@906
    10
 *
alpar@906
    11
 * This software is provided "AS IS" with no warranty of any kind,
alpar@906
    12
 * express or implied, and with no claim as to its suitability for any
alpar@906
    13
 * purpose.
alpar@906
    14
 *
alpar@906
    15
 */
alpar@906
    16
alpar@921
    17
#ifndef LEMON_MAP_BITS_H
alpar@921
    18
#define LEMON_MAP_BITS_H
deba@844
    19
deba@844
    20
///\ingroup graphmaps
deba@844
    21
///\file
deba@844
    22
///\brief Some utils to help implement maps.
deba@844
    23
alpar@921
    24
namespace lemon {
deba@844
    25
deba@844
    26
deba@844
    27
  /// \addtogroup graphmaps
deba@844
    28
  /// @{
deba@844
    29
deba@844
    30
  /// Helper class to get information about the key type.
deba@844
    31
  template <typename Graph, typename KeyIt>
deba@844
    32
  struct KeyInfo {};
deba@844
    33
deba@844
    34
  template <typename Graph>
deba@844
    35
  struct KeyInfo<Graph, typename Graph::NodeIt> {
deba@844
    36
    static int maxId(const Graph& graph) {
deba@844
    37
      return graph.maxNodeId();
deba@844
    38
    }
deba@844
    39
    static int id(const Graph& graph, const typename Graph::Node& node) {
deba@844
    40
      return graph.id(node);
deba@844
    41
    }
deba@844
    42
  };
deba@844
    43
deba@844
    44
  template <typename Graph>
deba@844
    45
  struct KeyInfo<Graph, typename Graph::EdgeIt> {
deba@844
    46
    static int maxId(const Graph& graph) {
deba@844
    47
      return graph.maxEdgeId();
deba@844
    48
    }
deba@844
    49
    static int id(const Graph& graph, const typename Graph::Edge& edge) {
deba@844
    50
      return graph.id(edge);
deba@844
    51
    }
deba@844
    52
  };
deba@844
    53
deba@844
    54
  template <typename Graph>
deba@844
    55
  struct KeyInfo<Graph, typename Graph::SymEdgeIt> {
deba@844
    56
    static int maxId(const Graph& graph) {
alpar@919
    57
      return graph.maxEdgeId() >> 1;
deba@844
    58
    }
alpar@919
    59
    static int id(const Graph& graph, const typename Graph::Edge& edge) {
alpar@919
    60
      return graph.id(edge) >> 1;
deba@844
    61
    }
deba@844
    62
  };
deba@844
    63
deba@844
    64
  /// @}
deba@844
    65
}
deba@844
    66
deba@844
    67
#endif