Loading...
Searching...
No Matches
GraphCopy< From, To > Class Template Reference
Tools and Utilities » Basic Graph Utilities

## Detailed Description

template<typename From, typename To>
class lemon::GraphCopy< From, To >

Class to copy a graph to another graph (duplicate a graph). The simplest way of using it is through the `graphCopy()` function.

This class not only make a copy of a graph, but it can create references and cross references between the nodes, edges and arcs of the two graphs, and it can copy maps for using with the newly created graph.

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

The next code copies a graph with several data:

GraphCopy<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 edges
NewGraph::EdgeMap<OrigGraph::Edge> ecr(new_graph);
cg.edgeCrossRef(ecr);
// Copy an edge map
OrigGraph::EdgeMap<double> oemap(orig_graph);
NewGraph::EdgeMap<double> nemap(new_graph);
cg.edgeMap(oemap, nemap);
// Copy a node
OrigGraph::Node on;
NewGraph::Node nn;
cg.node(on, nn);
// Execute copying
cg.run();
lemon::GraphCopy::GraphCopy
GraphCopy(const From &from, To &to)
Constructor of GraphCopy.
Definition core.h:931

`#include <lemon/core.h>`

## Public Member Functions

| GraphCopy (const From &from, To &to)
| Constructor of GraphCopy.
| ~GraphCopy ()
| Destructor of GraphCopy.
template<typename NodeRef>
GraphCopy & | nodeRef (NodeRef &map)
| Copy the node references into the given map.
template<typename NodeCrossRef>
GraphCopy & | nodeCrossRef (NodeCrossRef &map)
| Copy the node cross references into the given map.
template<typename FromMap, typename ToMap>
GraphCopy & | nodeMap (const FromMap &map, ToMap &tmap)
| Make a copy of the given node map.
GraphCopy & | node (const Node &node, TNode &tnode)
| Make a copy of the given node.
template<typename ArcRef>
GraphCopy & | arcRef (ArcRef &map)
| Copy the arc references into the given map.
template<typename ArcCrossRef>
GraphCopy & | arcCrossRef (ArcCrossRef &map)
| Copy the arc cross references into the given map.
template<typename FromMap, typename ToMap>
GraphCopy & | arcMap (const FromMap &map, ToMap &tmap)
| Make a copy of the given arc map.
GraphCopy & | arc (const Arc &arc, TArc &tarc)
| Make a copy of the given arc.
template<typename EdgeRef>
GraphCopy & | edgeRef (EdgeRef &map)
| Copy the edge references into the given map.
template<typename EdgeCrossRef>
GraphCopy & | edgeCrossRef (EdgeCrossRef &map)
| Copy the edge cross references into the given map.
template<typename FromMap, typename ToMap>
GraphCopy & | edgeMap (const FromMap &map, ToMap &tmap)
| Make a copy of the given edge map.
GraphCopy & | edge (const Edge &edge, TEdge &tedge)
| Make a copy of the given edge.
void | run ()
| Execute copying.

## Constructor & Destructor Documentation

## GraphCopy()

template<typename From, typename To>

GraphCopy | ( | const From & | from,
|  | To & | to )

inline

Constructor of GraphCopy for copying the content of the `from` graph into the `to` graph.

## ~GraphCopy()

template<typename From, typename To>

~GraphCopy | ( |  | ) |

inline

Destructor of GraphCopy.

## Member Function Documentation

## nodeRef()

template<typename From, typename To>
template<typename NodeRef>

GraphCopy & nodeRef | ( | NodeRef & | map | ) |

inline

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 graph, while the value type is the Node type of the destination graph.

## nodeCrossRef()

template<typename From, typename To>
template<typename NodeCrossRef>

GraphCopy & nodeCrossRef | ( | NodeCrossRef & | map | ) |

inline

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 graph, while the value type is the Node type of the source graph.

## nodeMap()

template<typename From, typename To>
template<typename FromMap, typename ToMap>

GraphCopy & nodeMap | ( | const FromMap & | map,
|  | ToMap & | tmap )

inline

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

## node()

template<typename From, typename To>

GraphCopy & node | ( | const Node & | node,
|  | TNode & | tnode )

inline

This function makes a copy of the given node.

## arcRef()

template<typename From, typename To>
template<typename ArcRef>

GraphCopy & arcRef | ( | ArcRef & | map | ) |

inline

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 graph, while the value type is the Arc type of the destination graph.

## arcCrossRef()

template<typename From, typename To>
template<typename ArcCrossRef>

GraphCopy & arcCrossRef | ( | ArcCrossRef & | map | ) |

inline

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 graph, while the value type is the Arc type of the source graph.

## arcMap()

template<typename From, typename To>
template<typename FromMap, typename ToMap>

GraphCopy & arcMap | ( | const FromMap & | map,
|  | ToMap & | tmap )

inline

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

## arc()

template<typename From, typename To>

GraphCopy & arc | ( | const Arc & | arc,
|  | TArc & | tarc )

inline

This function makes a copy of the given arc.

## edgeRef()

template<typename From, typename To>
template<typename EdgeRef>

GraphCopy & edgeRef | ( | EdgeRef & | map | ) |

inline

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

## edgeCrossRef()

template<typename From, typename To>
template<typename EdgeCrossRef>

GraphCopy & edgeCrossRef | ( | EdgeCrossRef & | map | ) |

inline

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

## edgeMap()

template<typename From, typename To>
template<typename FromMap, typename ToMap>

GraphCopy & edgeMap | ( | const FromMap & | map,
|  | ToMap & | tmap )

inline

This function makes a copy of the given edge map for the newly created graph. The key type of the new map `tmap` should be the Edge type of the destination graph, and the key type of the original map `map` should be the Edge type of the source graph.

## edge()

template<typename From, typename To>

GraphCopy & edge | ( | const Edge & | edge,
|  | TEdge & | tedge )

inline

This function makes a copy of the given edge.

## run()

template<typename From, typename To>

void run | ( |  | ) |

inline

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