DigraphCopy

Declared in lemon/core.h, in the group Basic Graph Utilities; the same class on the Doxygen site.

template< typename From , typename To >
class DigraphCopy

Class to copy a digraph.

Class to copy a digraph to another digraph (duplicate a digraph). The simplest way of using it is through the digraphCopy() function.

This class not only make a copy of a digraph, but it can create references and cross references between the nodes and arcs of the two digraphs, and it can copy maps to use with the newly created digraph.

To make a copy from a digraph, first an instance of DigraphCopy should be created, then the data belongs to the digraph should assigned to copy. In the end, the run() member should be called.

The next code copies a digraph with several data:

DigraphCopy< OrigGraph , NewGraph > cg( orig_graph , new_graph );
// Create references for the nodes
OrigGraph::NodeMap< NewGraph::Node > nr( orig_graph );
cg.nodeRef( nr );
// Create cross references (inverse) for the arcs
NewGraph::ArcMap< OrigGraph::Arc > acr( new_graph );
cg.arcCrossRef( acr );
// Copy an arc map
OrigGraph::ArcMap< double > oamap( orig_graph );
NewGraph::ArcMap< double > namap( new_graph );
cg.arcMap( oamap , namap );
// Copy a node
OrigGraph::Node on;
NewGraph::Node nn;
cg.node( on , nn );
// Execute copying
cg.run();

Public Functions

inline DigraphCopy( const From & from , To & to )

Constructor of DigraphCopy.

Constructor of DigraphCopy for copying the content of the from digraph into the to digraph.

inline DigraphCopy( DigraphCopy && copy )

Move constructor of DigraphCopy.

Move constructor of DigraphCopy, which takes over the maps to be copied, so that digraphCopy() can be returned by value.

DigraphCopy( const DigraphCopy & ) = delete
DigraphCopy & operator=( const DigraphCopy & ) = delete
inline ~DigraphCopy()

Destructor of DigraphCopy.

template< typename NodeRef >
inline DigraphCopy & nodeRef( NodeRef & map )

Copy the node references into the given map.

This function copies the node references into the given map. The parameter should be a map, whose key type is the Node type of the source digraph, while the value type is the Node type of the destination digraph.

template< typename NodeCrossRef >
inline DigraphCopy & nodeCrossRef( NodeCrossRef & map )

Copy the node cross references into the given map.

This function copies the node cross references (reverse references) into the given map. The parameter should be a map, whose key type is the Node type of the destination digraph, while the value type is the Node type of the source digraph.

template< typename FromMap , typename ToMap >
inline DigraphCopy & nodeMap(
const FromMap & map,
ToMap & tmap
)

Make a copy of the given node map.

This function makes a copy of the given node map for the newly created digraph. The key type of the new map tmap should be the Node type of the destination digraph, and the key type of the original map map should be the Node type of the source digraph.

inline DigraphCopy & node( const Node & node , TNode & tnode )

Make a copy of the given node.

This function makes a copy of the given node.

template< typename ArcRef >
inline DigraphCopy & arcRef( ArcRef & map )

Copy the arc references into the given map.

This function copies the arc references into the given map. The parameter should be a map, whose key type is the Arc type of the source digraph, while the value type is the Arc type of the destination digraph.

template< typename ArcCrossRef >
inline DigraphCopy & arcCrossRef( ArcCrossRef & map )

Copy the arc cross references into the given map.

This function copies the arc cross references (reverse references) into the given map. The parameter should be a map, whose key type is the Arc type of the destination digraph, while the value type is the Arc type of the source digraph.

template< typename FromMap , typename ToMap >
inline DigraphCopy & arcMap(
const FromMap & map,
ToMap & tmap
)

Make a copy of the given arc map.

This function makes a copy of the given arc map for the newly created digraph. The key type of the new map tmap should be the Arc type of the destination digraph, and the key type of the original map map should be the Arc type of the source digraph.

inline DigraphCopy & arc( const Arc & arc , TArc & tarc )

Make a copy of the given arc.

This function makes a copy of the given arc.

inline void run()

Execute copying.

This function executes the copying of the digraph along with the copying of the assigned data.

Protected Attributes

const From & _from
To & _to
std::vector< _core_bits::MapCopyBase< From , Node , NodeRefMap >* > _node_maps
std::vector< _core_bits::MapCopyBase< From , Arc , ArcRefMap >* > _arc_maps