IdMap

Declared in lemon/maps.h, in the group Graph Maps; the same class on the Doxygen site.

template< typename GR , typename K >
class IdMap : public MapBase< K , int >

Provides an immutable and unique id for each item in a graph.

IdMap provides a unique and immutable id for each item of the same type (Node, Arc or Edge) in a graph. This id is

  • unique: different items get different ids,

  • immutable: the id of an item does not change (even if you delete other nodes).

Using this map you get access (i.e. can read) the inner id values of the items stored in the graph, which is returned by the id() function of the graph. This map can be inverted with its member class InverseMap or with the operator()() member.

See also

RangeIdMap

Template Parameters:
  • GR – The graph type.

  • K – The key type of the map (GR::Node, GR::Arc or GR::Edge).

Public Types

typedef GR Graph

The graph type of IdMap.

typedef GR Digraph
typedef K Item

The key type of IdMap (Node, Arc or Edge).

typedef K Key

The key type of IdMap (Node, Arc or Edge).

typedef int Value

The value type of IdMap.

Public Functions

inline explicit IdMap( const Graph & graph )

Constructor.

Constructor of the map.

inline int operator[]( const Item & item ) const

Gives back the id of the item.

Gives back the immutable and unique id of the item.

inline Item operator()( int id ) const

Gives back the item by its id.

inline InverseMap inverse() const

Gives back the inverse of the map.

Gives back the inverse of the IdMap.

class InverseMap

The inverse map type of IdMap. The subscript operator gives back an item by its id. This type conforms to the ReadMap concept.

See also

inverse()

Public Functions

inline explicit InverseMap( const Graph & graph )

Constructor.

Constructor for creating an id-to-item map.

inline explicit InverseMap( const IdMap & map )

Constructor.

Constructor for creating an id-to-item map.

inline Item operator[]( int id ) const

Gives back an item by its id.