0
2
0
325
309
... | ... |
@@ -60,6 +60,6 @@ |
60 | 60 |
|
61 |
/// |
|
61 |
///Create convenient typedefs for the digraph types and iterators |
|
62 | 62 |
|
63 |
///This \c \#define creates convenience typedefs for the following types |
|
64 |
///of \c Digraph: \c Node, \c NodeIt, \c Arc, \c ArcIt, \c InArcIt, |
|
63 |
///This \c \#define creates convenient type definitions for the following |
|
64 |
///types of \c Digraph: \c Node, \c NodeIt, \c Arc, \c ArcIt, \c InArcIt, |
|
65 | 65 |
///\c OutArcIt, \c BoolNodeMap, \c IntNodeMap, \c DoubleNodeMap, |
... | ... |
@@ -82,5 +82,5 @@ |
82 | 82 |
typedef Digraph::ArcMap<int> IntArcMap; \ |
83 |
typedef Digraph::ArcMap<double> DoubleArcMap |
|
83 |
typedef Digraph::ArcMap<double> DoubleArcMap; |
|
84 | 84 |
|
85 |
/// |
|
85 |
///Create convenient typedefs for the digraph types and iterators |
|
86 | 86 |
|
... | ... |
@@ -102,7 +102,7 @@ |
102 | 102 |
typedef typename Digraph::template ArcMap<int> IntArcMap; \ |
103 |
typedef typename Digraph::template ArcMap<double> DoubleArcMap |
|
103 |
typedef typename Digraph::template ArcMap<double> DoubleArcMap; |
|
104 | 104 |
|
105 |
/// |
|
105 |
///Create convenient typedefs for the graph types and iterators |
|
106 | 106 |
|
107 |
///This \c \#define creates the same |
|
107 |
///This \c \#define creates the same convenient type definitions as defined |
|
108 | 108 |
///by \ref DIGRAPH_TYPEDEFS(Graph) and six more, namely it creates |
... | ... |
@@ -112,3 +112,3 @@ |
112 | 112 |
///\note If the graph type is a dependent type, ie. the graph type depend |
113 |
///on a template parameter, then use \c |
|
113 |
///on a template parameter, then use \c TEMPLATE_GRAPH_TYPEDEFS() |
|
114 | 114 |
///macro. |
... | ... |
@@ -121,5 +121,5 @@ |
121 | 121 |
typedef Graph::EdgeMap<int> IntEdgeMap; \ |
122 |
typedef Graph::EdgeMap<double> DoubleEdgeMap |
|
122 |
typedef Graph::EdgeMap<double> DoubleEdgeMap; |
|
123 | 123 |
|
124 |
/// |
|
124 |
///Create convenient typedefs for the graph types and iterators |
|
125 | 125 |
|
... | ... |
@@ -136,8 +136,8 @@ |
136 | 136 |
typedef typename Graph::template EdgeMap<int> IntEdgeMap; \ |
137 |
typedef typename Graph::template EdgeMap<double> DoubleEdgeMap |
|
137 |
typedef typename Graph::template EdgeMap<double> DoubleEdgeMap; |
|
138 | 138 |
|
139 |
/// \brief Function to count the items in |
|
139 |
/// \brief Function to count the items in a graph. |
|
140 | 140 |
/// |
141 |
/// This function counts the items (nodes, arcs etc) in the graph. |
|
142 |
/// The complexity of the function is O(n) because |
|
141 |
/// This function counts the items (nodes, arcs etc.) in a graph. |
|
142 |
/// The complexity of the function is linear because |
|
143 | 143 |
/// it iterates on all of the items. |
... | ... |
@@ -178,7 +178,7 @@ |
178 | 178 |
/// This function counts the nodes in the graph. |
179 |
/// The complexity of the function is O(n) but for some |
|
180 |
/// graph structures it is specialized to run in O(1). |
|
179 |
/// The complexity of the function is <em>O</em>(<em>n</em>), but for some |
|
180 |
/// graph structures it is specialized to run in <em>O</em>(1). |
|
181 | 181 |
/// |
182 |
/// If the graph contains a \e nodeNum() member function and a |
|
183 |
/// \e NodeNumTag tag then this function calls directly the member |
|
182 |
/// \note If the graph contains a \c nodeNum() member function and a |
|
183 |
/// \c NodeNumTag tag then this function calls directly the member |
|
184 | 184 |
/// function to query the cardinality of the node set. |
... | ... |
@@ -214,7 +214,7 @@ |
214 | 214 |
/// This function counts the arcs in the graph. |
215 |
/// The complexity of the function is O(e) but for some |
|
216 |
/// graph structures it is specialized to run in O(1). |
|
215 |
/// The complexity of the function is <em>O</em>(<em>m</em>), but for some |
|
216 |
/// graph structures it is specialized to run in <em>O</em>(1). |
|
217 | 217 |
/// |
218 |
/// If the graph contains a \e arcNum() member function and a |
|
219 |
/// \e EdgeNumTag tag then this function calls directly the member |
|
218 |
/// \note If the graph contains a \c arcNum() member function and a |
|
219 |
/// \c ArcNumTag tag then this function calls directly the member |
|
220 | 220 |
/// function to query the cardinality of the arc set. |
... | ... |
@@ -226,2 +226,3 @@ |
226 | 226 |
// Edge counting: |
227 |
|
|
227 | 228 |
namespace _core_bits { |
... | ... |
@@ -249,7 +250,7 @@ |
249 | 250 |
/// This function counts the edges in the graph. |
250 |
/// The complexity of the function is O(m) but for some |
|
251 |
/// graph structures it is specialized to run in O(1). |
|
251 |
/// The complexity of the function is <em>O</em>(<em>m</em>), but for some |
|
252 |
/// graph structures it is specialized to run in <em>O</em>(1). |
|
252 | 253 |
/// |
253 |
/// If the graph contains a \e edgeNum() member function and a |
|
254 |
/// \e EdgeNumTag tag then this function calls directly the member |
|
254 |
/// \note If the graph contains a \c edgeNum() member function and a |
|
255 |
/// \c EdgeNumTag tag then this function calls directly the member |
|
255 | 256 |
/// function to query the cardinality of the edge set. |
... | ... |
@@ -274,6 +275,6 @@ |
274 | 275 |
/// This function counts the number of the out-arcs from node \c n |
275 |
/// in the graph. |
|
276 |
/// in the graph \c g. |
|
276 | 277 |
template <typename Graph> |
277 |
inline int countOutArcs(const Graph& _g, const typename Graph::Node& _n) { |
|
278 |
return countNodeDegree<Graph, typename Graph::OutArcIt>(_g, _n); |
|
278 |
inline int countOutArcs(const Graph& g, const typename Graph::Node& n) { |
|
279 |
return countNodeDegree<Graph, typename Graph::OutArcIt>(g, n); |
|
279 | 280 |
} |
... | ... |
@@ -283,6 +284,6 @@ |
283 | 284 |
/// This function counts the number of the in-arcs to node \c n |
284 |
/// in the graph. |
|
285 |
/// in the graph \c g. |
|
285 | 286 |
template <typename Graph> |
286 |
inline int countInArcs(const Graph& _g, const typename Graph::Node& _n) { |
|
287 |
return countNodeDegree<Graph, typename Graph::InArcIt>(_g, _n); |
|
287 |
inline int countInArcs(const Graph& g, const typename Graph::Node& n) { |
|
288 |
return countNodeDegree<Graph, typename Graph::InArcIt>(g, n); |
|
288 | 289 |
} |
... | ... |
@@ -292,6 +293,6 @@ |
292 | 293 |
/// This function counts the number of the inc-edges to node \c n |
293 |
/// in the graph. |
|
294 |
/// in the undirected graph \c g. |
|
294 | 295 |
template <typename Graph> |
295 |
inline int countIncEdges(const Graph& _g, const typename Graph::Node& _n) { |
|
296 |
return countNodeDegree<Graph, typename Graph::IncEdgeIt>(_g, _n); |
|
296 |
inline int countIncEdges(const Graph& g, const typename Graph::Node& n) { |
|
297 |
return countNodeDegree<Graph, typename Graph::IncEdgeIt>(g, n); |
|
297 | 298 |
} |
... | ... |
@@ -309,3 +310,3 @@ |
309 | 310 |
template <typename Digraph, typename Item, typename RefMap, |
310 |
typename |
|
311 |
typename FromMap, typename ToMap> |
|
311 | 312 |
class MapCopy : public MapCopyBase<Digraph, Item, RefMap> { |
... | ... |
@@ -313,4 +314,4 @@ |
313 | 314 |
|
314 |
MapCopy(ToMap& tmap, const FromMap& map) |
|
315 |
: _tmap(tmap), _map(map) {} |
|
315 |
MapCopy(const FromMap& map, ToMap& tmap) |
|
316 |
: _map(map), _tmap(tmap) {} |
|
316 | 317 |
|
... | ... |
@@ -324,4 +325,4 @@ |
324 | 325 |
private: |
326 |
const FromMap& _map; |
|
325 | 327 |
ToMap& _tmap; |
326 |
const FromMap& _map; |
|
327 | 328 |
}; |
... | ... |
@@ -332,3 +333,3 @@ |
332 | 333 |
|
333 |
ItemCopy( |
|
334 |
ItemCopy(const Item& item, It& it) : _item(item), _it(it) {} |
|
334 | 335 |
|
... | ... |
@@ -339,4 +340,4 @@ |
339 | 340 |
private: |
341 |
Item _item; |
|
340 | 342 |
It& _it; |
341 |
Item _item; |
|
342 | 343 |
}; |
... | ... |
@@ -381,3 +382,3 @@ |
381 | 382 |
template <typename From, typename NodeRefMap, typename ArcRefMap> |
382 |
static void copy( |
|
383 |
static void copy(const From& from, Digraph &to, |
|
383 | 384 |
NodeRefMap& nodeRefMap, ArcRefMap& arcRefMap) { |
... | ... |
@@ -399,3 +400,3 @@ |
399 | 400 |
template <typename From, typename NodeRefMap, typename ArcRefMap> |
400 |
static void copy( |
|
401 |
static void copy(const From& from, Digraph &to, |
|
401 | 402 |
NodeRefMap& nodeRefMap, ArcRefMap& arcRefMap) { |
... | ... |
@@ -408,3 +409,3 @@ |
408 | 409 |
template <typename From, typename NodeRefMap, typename EdgeRefMap> |
409 |
static void copy( |
|
410 |
static void copy(const From& from, Graph &to, |
|
410 | 411 |
NodeRefMap& nodeRefMap, EdgeRefMap& edgeRefMap) { |
... | ... |
@@ -426,3 +427,3 @@ |
426 | 427 |
template <typename From, typename NodeRefMap, typename EdgeRefMap> |
427 |
static void copy( |
|
428 |
static void copy(const From& from, Graph &to, |
|
428 | 429 |
NodeRefMap& nodeRefMap, EdgeRefMap& edgeRefMap) { |
... | ... |
@@ -437,11 +438,11 @@ |
437 | 438 |
/// Class to copy a digraph to another digraph (duplicate a digraph). The |
438 |
/// simplest way of using it is through the \c |
|
439 |
/// simplest way of using it is through the \c digraphCopy() function. |
|
439 | 440 |
/// |
440 |
/// This class not |
|
441 |
/// This class not only make a copy of a digraph, but it can create |
|
441 | 442 |
/// references and cross references between the nodes and arcs of |
442 |
/// the two graphs, it can copy maps for use with the newly created |
|
443 |
/// graph and copy nodes and arcs. |
|
443 |
/// the two digraphs, and it can copy maps to use with the newly created |
|
444 |
/// digraph. |
|
444 | 445 |
/// |
445 |
/// To make a copy from a graph, first an instance of DigraphCopy |
|
446 |
/// should be created, then the data belongs to the graph should |
|
446 |
/// To make a copy from a digraph, first an instance of DigraphCopy |
|
447 |
/// should be created, then the data belongs to the digraph should |
|
447 | 448 |
/// assigned to copy. In the end, the \c run() member should be |
... | ... |
@@ -449,23 +450,23 @@ |
449 | 450 |
/// |
450 |
/// The next code copies a |
|
451 |
/// The next code copies a digraph with several data: |
|
451 | 452 |
///\code |
452 |
/// DigraphCopy<NewGraph, OrigGraph> dc(new_graph, orig_graph); |
|
453 |
/// // create a reference for the nodes |
|
453 |
/// DigraphCopy<OrigGraph, NewGraph> cg(orig_graph, new_graph); |
|
454 |
/// // Create references for the nodes |
|
454 | 455 |
/// OrigGraph::NodeMap<NewGraph::Node> nr(orig_graph); |
455 |
/// dc.nodeRef(nr); |
|
456 |
/// // create a cross reference (inverse) for the arcs |
|
456 |
/// cg.nodeRef(nr); |
|
457 |
/// // Create cross references (inverse) for the arcs |
|
457 | 458 |
/// NewGraph::ArcMap<OrigGraph::Arc> acr(new_graph); |
458 |
/// dc.arcCrossRef(acr); |
|
459 |
/// // copy an arc map |
|
459 |
/// cg.arcCrossRef(acr); |
|
460 |
/// // Copy an arc map |
|
460 | 461 |
/// OrigGraph::ArcMap<double> oamap(orig_graph); |
461 | 462 |
/// NewGraph::ArcMap<double> namap(new_graph); |
462 |
/// dc.arcMap(namap, oamap); |
|
463 |
/// // copy a node |
|
463 |
/// cg.arcMap(oamap, namap); |
|
464 |
/// // Copy a node |
|
464 | 465 |
/// OrigGraph::Node on; |
465 | 466 |
/// NewGraph::Node nn; |
466 |
/// dc.node(nn, on); |
|
467 |
/// // Executions of copy |
|
468 |
/// |
|
467 |
/// cg.node(on, nn); |
|
468 |
/// // Execute copying |
|
469 |
/// cg.run(); |
|
469 | 470 |
///\endcode |
470 |
template <typename |
|
471 |
template <typename From, typename To> |
|
471 | 472 |
class DigraphCopy { |
... | ... |
@@ -484,16 +485,14 @@ |
484 | 485 |
|
485 |
|
|
486 | 486 |
public: |
487 | 487 |
|
488 |
|
|
489 |
/// \brief Constructor for the DigraphCopy. |
|
488 |
/// \brief Constructor of DigraphCopy. |
|
490 | 489 |
/// |
491 |
/// It copies the content of the \c _from digraph into the |
|
492 |
/// \c _to digraph. |
|
493 |
|
|
490 |
/// Constructor of DigraphCopy for copying the content of the |
|
491 |
/// \c from digraph into the \c to digraph. |
|
492 |
DigraphCopy(const From& from, To& to) |
|
494 | 493 |
: _from(from), _to(to) {} |
495 | 494 |
|
496 |
/// \brief Destructor of |
|
495 |
/// \brief Destructor of DigraphCopy |
|
497 | 496 |
/// |
498 |
/// Destructor of |
|
497 |
/// Destructor of DigraphCopy. |
|
499 | 498 |
~DigraphCopy() { |
... | ... |
@@ -508,8 +507,8 @@ |
508 | 507 |
|
509 |
/// \brief |
|
508 |
/// \brief Copy the node references into the given map. |
|
510 | 509 |
/// |
511 |
/// Copies the node references into the given map. The parameter |
|
512 |
/// should be a map, which key type is the Node type of the source |
|
513 |
/// graph, while the value type is the Node type of the |
|
514 |
/// destination graph. |
|
510 |
/// This function copies the node references into the given map. |
|
511 |
/// The parameter should be a map, whose key type is the Node type of |
|
512 |
/// the source digraph, while the value type is the Node type of the |
|
513 |
/// destination digraph. |
|
515 | 514 |
template <typename NodeRef> |
... | ... |
@@ -521,8 +520,8 @@ |
521 | 520 |
|
522 |
/// \brief |
|
521 |
/// \brief Copy the node cross references into the given map. |
|
523 | 522 |
/// |
524 |
/// Copies the node cross references (reverse references) into |
|
525 |
/// the given map. The parameter should be a map, which key type |
|
526 |
/// is the Node type of the destination graph, while the value type is |
|
527 |
/// the Node type of the source graph. |
|
523 |
/// This function copies the node cross references (reverse references) |
|
524 |
/// into the given map. The parameter should be a map, whose key type |
|
525 |
/// is the Node type of the destination digraph, while the value type is |
|
526 |
/// the Node type of the source digraph. |
|
528 | 527 |
template <typename NodeCrossRef> |
... | ... |
@@ -534,11 +533,13 @@ |
534 | 533 |
|
535 |
/// \brief Make copy of the given map. |
|
534 |
/// \brief Make a copy of the given node map. |
|
536 | 535 |
/// |
537 |
/// Makes copy of the given map for the newly created digraph. |
|
538 |
/// The new map's key type is the destination graph's node type, |
|
539 |
/// and the copied map's key type is the source graph's node type. |
|
540 |
template <typename ToMap, typename FromMap> |
|
541 |
|
|
536 |
/// This function makes a copy of the given node map for the newly |
|
537 |
/// created digraph. |
|
538 |
/// The key type of the new map \c tmap should be the Node type of the |
|
539 |
/// destination digraph, and the key type of the original map \c map |
|
540 |
/// should be the Node type of the source digraph. |
|
541 |
template <typename FromMap, typename ToMap> |
|
542 |
DigraphCopy& nodeMap(const FromMap& map, ToMap& tmap) { |
|
542 | 543 |
_node_maps.push_back(new _core_bits::MapCopy<From, Node, |
543 |
NodeRefMap, |
|
544 |
NodeRefMap, FromMap, ToMap>(map, tmap)); |
|
544 | 545 |
return *this; |
... | ... |
@@ -548,6 +549,6 @@ |
548 | 549 |
/// |
549 |
/// Make a copy of the given node. |
|
550 |
DigraphCopy& node(TNode& tnode, const Node& snode) { |
|
550 |
/// This function makes a copy of the given node. |
|
551 |
DigraphCopy& node(const Node& node, TNode& tnode) { |
|
551 | 552 |
_node_maps.push_back(new _core_bits::ItemCopy<From, Node, |
552 |
NodeRefMap, TNode>( |
|
553 |
NodeRefMap, TNode>(node, tnode)); |
|
553 | 554 |
return *this; |
... | ... |
@@ -555,5 +556,8 @@ |
555 | 556 |
|
556 |
/// \brief |
|
557 |
/// \brief Copy the arc references into the given map. |
|
557 | 558 |
/// |
558 |
/// |
|
559 |
/// This function copies the arc references into the given map. |
|
560 |
/// The parameter should be a map, whose key type is the Arc type of |
|
561 |
/// the source digraph, while the value type is the Arc type of the |
|
562 |
/// destination digraph. |
|
559 | 563 |
template <typename ArcRef> |
... | ... |
@@ -565,6 +569,8 @@ |
565 | 569 |
|
566 |
/// \brief |
|
570 |
/// \brief Copy the arc cross references into the given map. |
|
567 | 571 |
/// |
568 |
/// Copies the arc cross references (reverse references) into |
|
569 |
/// the given map. |
|
572 |
/// This function copies the arc cross references (reverse references) |
|
573 |
/// into the given map. The parameter should be a map, whose key type |
|
574 |
/// is the Arc type of the destination digraph, while the value type is |
|
575 |
/// the Arc type of the source digraph. |
|
570 | 576 |
template <typename ArcCrossRef> |
... | ... |
@@ -576,12 +582,13 @@ |
576 | 582 |
|
577 |
/// \brief Make copy of the given map. |
|
583 |
/// \brief Make a copy of the given arc map. |
|
578 | 584 |
/// |
579 |
/// Makes copy of the given map for the newly created digraph. |
|
580 |
/// The new map's key type is the to digraph's arc type, |
|
581 |
/// and the copied map's key type is the from digraph's arc |
|
582 |
/// type. |
|
583 |
template <typename ToMap, typename FromMap> |
|
584 |
DigraphCopy& arcMap(ToMap& tmap, const FromMap& map) { |
|
585 |
/// This function makes a copy of the given arc map for the newly |
|
586 |
/// created digraph. |
|
587 |
/// The key type of the new map \c tmap should be the Arc type of the |
|
588 |
/// destination digraph, and the key type of the original map \c map |
|
589 |
/// should be the Arc type of the source digraph. |
|
590 |
template <typename FromMap, typename ToMap> |
|
591 |
DigraphCopy& arcMap(const FromMap& map, ToMap& tmap) { |
|
585 | 592 |
_arc_maps.push_back(new _core_bits::MapCopy<From, Arc, |
586 |
ArcRefMap, |
|
593 |
ArcRefMap, FromMap, ToMap>(map, tmap)); |
|
587 | 594 |
return *this; |
... | ... |
@@ -591,6 +598,6 @@ |
591 | 598 |
/// |
592 |
/// Make a copy of the given arc. |
|
593 |
DigraphCopy& arc(TArc& tarc, const Arc& sarc) { |
|
599 |
/// This function makes a copy of the given arc. |
|
600 |
DigraphCopy& arc(const Arc& arc, TArc& tarc) { |
|
594 | 601 |
_arc_maps.push_back(new _core_bits::ItemCopy<From, Arc, |
595 |
ArcRefMap, TArc>( |
|
602 |
ArcRefMap, TArc>(arc, tarc)); |
|
596 | 603 |
return *this; |
... | ... |
@@ -598,5 +605,6 @@ |
598 | 605 |
|
599 |
/// \brief |
|
606 |
/// \brief Execute copying. |
|
600 | 607 |
/// |
601 |
/// |
|
608 |
/// This function executes the copying of the digraph along with the |
|
609 |
/// copying of the assigned data. |
|
602 | 610 |
void run() { |
... | ... |
@@ -605,3 +613,3 @@ |
605 | 613 |
_core_bits::DigraphCopySelector<To>:: |
606 |
copy( |
|
614 |
copy(_from, _to, nodeRefMap, arcRefMap); |
|
607 | 615 |
for (int i = 0; i < int(_node_maps.size()); ++i) { |
... | ... |
@@ -616,3 +624,2 @@ |
616 | 624 |
|
617 |
|
|
618 | 625 |
const From& _from; |
... | ... |
@@ -621,6 +628,6 @@ |
621 | 628 |
std::vector<_core_bits::MapCopyBase<From, Node, NodeRefMap>* > |
622 |
_node_maps; |
|
629 |
_node_maps; |
|
623 | 630 |
|
624 | 631 |
std::vector<_core_bits::MapCopyBase<From, Arc, ArcRefMap>* > |
625 |
_arc_maps; |
|
632 |
_arc_maps; |
|
626 | 633 |
|
... | ... |
@@ -630,7 +637,7 @@ |
630 | 637 |
/// |
631 |
/// Copy a digraph to another digraph. The complete usage of the |
|
632 |
/// function is detailed in the DigraphCopy class, but a short |
|
633 |
/// |
|
638 |
/// This function copies a digraph to another digraph. |
|
639 |
/// The complete usage of it is detailed in the DigraphCopy class, but |
|
640 |
/// a short example shows a basic work: |
|
634 | 641 |
///\code |
635 |
/// |
|
642 |
/// digraphCopy(src, trg).nodeRef(nr).arcCrossRef(acr).run(); |
|
636 | 643 |
///\endcode |
... | ... |
@@ -639,3 +646,3 @@ |
639 | 646 |
/// nodes of the \c from digraph to the nodes of the \c to digraph and |
640 |
/// \c |
|
647 |
/// \c acr will contain the mapping from the arcs of the \c to digraph |
|
641 | 648 |
/// to the arcs of the \c from digraph. |
... | ... |
@@ -643,5 +650,5 @@ |
643 | 650 |
/// \see DigraphCopy |
644 |
template <typename To, typename From> |
|
645 |
DigraphCopy<To, From> copyDigraph(To& to, const From& from) { |
|
646 |
|
|
651 |
template <typename From, typename To> |
|
652 |
DigraphCopy<From, To> digraphCopy(const From& from, To& to) { |
|
653 |
return DigraphCopy<From, To>(from, to); |
|
647 | 654 |
} |
... | ... |
@@ -651,8 +658,8 @@ |
651 | 658 |
/// Class to copy a graph to another graph (duplicate a graph). The |
652 |
/// simplest way of using it is through the \c |
|
659 |
/// simplest way of using it is through the \c graphCopy() function. |
|
653 | 660 |
/// |
654 |
/// This class not |
|
661 |
/// This class not only make a copy of a graph, but it can create |
|
655 | 662 |
/// references and cross references between the nodes, edges and arcs of |
656 |
/// the two graphs, it can copy maps for use with the newly created |
|
657 |
/// graph and copy nodes, edges and arcs. |
|
663 |
/// the two graphs, and it can copy maps for using with the newly created |
|
664 |
/// graph. |
|
658 | 665 |
/// |
... | ... |
@@ -665,21 +672,21 @@ |
665 | 672 |
///\code |
666 |
/// GraphCopy<NewGraph, OrigGraph> dc(new_graph, orig_graph); |
|
667 |
/// // create a reference for the nodes |
|
673 |
/// GraphCopy<OrigGraph, NewGraph> cg(orig_graph, new_graph); |
|
674 |
/// // Create references for the nodes |
|
668 | 675 |
/// OrigGraph::NodeMap<NewGraph::Node> nr(orig_graph); |
669 |
/// dc.nodeRef(nr); |
|
670 |
/// // create a cross reference (inverse) for the edges |
|
671 |
/// NewGraph::EdgeMap<OrigGraph::Arc> ecr(new_graph); |
|
672 |
/// dc.edgeCrossRef(ecr); |
|
673 |
/// // copy an arc map |
|
674 |
/// OrigGraph::ArcMap<double> oamap(orig_graph); |
|
675 |
/// NewGraph::ArcMap<double> namap(new_graph); |
|
676 |
/// dc.arcMap(namap, oamap); |
|
677 |
/// |
|
676 |
/// cg.nodeRef(nr); |
|
677 |
/// // Create cross references (inverse) for the edges |
|
678 |
/// NewGraph::EdgeMap<OrigGraph::Edge> ecr(new_graph); |
|
679 |
/// cg.edgeCrossRef(ecr); |
|
680 |
/// // Copy an edge map |
|
681 |
/// OrigGraph::EdgeMap<double> oemap(orig_graph); |
|
682 |
/// NewGraph::EdgeMap<double> nemap(new_graph); |
|
683 |
/// cg.edgeMap(oemap, nemap); |
|
684 |
/// // Copy a node |
|
678 | 685 |
/// OrigGraph::Node on; |
679 | 686 |
/// NewGraph::Node nn; |
680 |
/// dc.node(nn, on); |
|
681 |
/// // Executions of copy |
|
682 |
/// |
|
687 |
/// cg.node(on, nn); |
|
688 |
/// // Execute copying |
|
689 |
/// cg.run(); |
|
683 | 690 |
///\endcode |
684 |
template <typename |
|
691 |
template <typename From, typename To> |
|
685 | 692 |
class GraphCopy { |
... | ... |
@@ -702,5 +709,5 @@ |
702 | 709 |
struct ArcRefMap { |
703 |
ArcRefMap(const To& to, |
|
710 |
ArcRefMap(const From& from, const To& to, |
|
704 | 711 |
const EdgeRefMap& edge_ref, const NodeRefMap& node_ref) |
705 |
: _to(to), |
|
712 |
: _from(from), _to(to), |
|
706 | 713 |
_edge_ref(edge_ref), _node_ref(node_ref) {} |
... | ... |
@@ -718,4 +725,4 @@ |
718 | 725 |
|
726 |
const From& _from; |
|
719 | 727 |
const To& _to; |
720 |
const From& _from; |
|
721 | 728 |
const EdgeRefMap& _edge_ref; |
... | ... |
@@ -724,16 +731,14 @@ |
724 | 731 |
|
725 |
|
|
726 | 732 |
public: |
727 | 733 |
|
728 |
|
|
729 |
/// \brief Constructor for the GraphCopy. |
|
734 |
/// \brief Constructor of GraphCopy. |
|
730 | 735 |
/// |
731 |
/// It copies the content of the \c _from graph into the |
|
732 |
/// \c _to graph. |
|
733 |
|
|
736 |
/// Constructor of GraphCopy for copying the content of the |
|
737 |
/// \c from graph into the \c to graph. |
|
738 |
GraphCopy(const From& from, To& to) |
|
734 | 739 |
: _from(from), _to(to) {} |
735 | 740 |
|
736 |
/// \brief Destructor of |
|
741 |
/// \brief Destructor of GraphCopy |
|
737 | 742 |
/// |
738 |
/// Destructor of |
|
743 |
/// Destructor of GraphCopy. |
|
739 | 744 |
~GraphCopy() { |
... | ... |
@@ -748,8 +753,10 @@ |
748 | 753 |
} |
749 |
|
|
750 | 754 |
} |
751 | 755 |
|
752 |
/// \brief |
|
756 |
/// \brief Copy the node references into the given map. |
|
753 | 757 |
/// |
754 |
/// |
|
758 |
/// This function copies the node references into the given map. |
|
759 |
/// The parameter should be a map, whose key type is the Node type of |
|
760 |
/// the source graph, while the value type is the Node type of the |
|
761 |
/// destination graph. |
|
755 | 762 |
template <typename NodeRef> |
... | ... |
@@ -761,6 +768,8 @@ |
761 | 768 |
|
762 |
/// \brief |
|
769 |
/// \brief Copy the node cross references into the given map. |
|
763 | 770 |
/// |
764 |
/// Copies the node cross references (reverse references) into |
|
765 |
/// the given map. |
|
771 |
/// This function copies the node cross references (reverse references) |
|
772 |
/// into the given map. The parameter should be a map, whose key type |
|
773 |
/// is the Node type of the destination graph, while the value type is |
|
774 |
/// the Node type of the source graph. |
|
766 | 775 |
template <typename NodeCrossRef> |
... | ... |
@@ -772,12 +781,13 @@ |
772 | 781 |
|
773 |
/// \brief Make copy of the given map. |
|
782 |
/// \brief Make a copy of the given node map. |
|
774 | 783 |
/// |
775 |
/// Makes copy of the given map for the newly created graph. |
|
776 |
/// The new map's key type is the to graph's node type, |
|
777 |
/// and the copied map's key type is the from graph's node |
|
778 |
/// type. |
|
779 |
template <typename ToMap, typename FromMap> |
|
780 |
GraphCopy& nodeMap(ToMap& tmap, const FromMap& map) { |
|
784 |
/// This function makes a copy of the given node map for the newly |
|
785 |
/// created graph. |
|
786 |
/// The key type of the new map \c tmap should be the Node type of the |
|
787 |
/// destination graph, and the key type of the original map \c map |
|
788 |
/// should be the Node type of the source graph. |
|
789 |
template <typename FromMap, typename ToMap> |
|
790 |
GraphCopy& nodeMap(const FromMap& map, ToMap& tmap) { |
|
781 | 791 |
_node_maps.push_back(new _core_bits::MapCopy<From, Node, |
782 |
NodeRefMap, |
|
792 |
NodeRefMap, FromMap, ToMap>(map, tmap)); |
|
783 | 793 |
return *this; |
... | ... |
@@ -787,6 +797,6 @@ |
787 | 797 |
/// |
788 |
/// Make a copy of the given node. |
|
789 |
GraphCopy& node(TNode& tnode, const Node& snode) { |
|
798 |
/// This function makes a copy of the given node. |
|
799 |
GraphCopy& node(const Node& node, TNode& tnode) { |
|
790 | 800 |
_node_maps.push_back(new _core_bits::ItemCopy<From, Node, |
791 |
NodeRefMap, TNode>( |
|
801 |
NodeRefMap, TNode>(node, tnode)); |
|
792 | 802 |
return *this; |
... | ... |
@@ -794,5 +804,8 @@ |
794 | 804 |
|
795 |
/// \brief |
|
805 |
/// \brief Copy the arc references into the given map. |
|
796 | 806 |
/// |
797 |
/// |
|
807 |
/// This function copies the arc references into the given map. |
|
808 |
/// The parameter should be a map, whose key type is the Arc type of |
|
809 |
/// the source graph, while the value type is the Arc type of the |
|
810 |
/// destination graph. |
|
798 | 811 |
template <typename ArcRef> |
... | ... |
@@ -804,6 +817,8 @@ |
804 | 817 |
|
805 |
/// \brief |
|
818 |
/// \brief Copy the arc cross references into the given map. |
|
806 | 819 |
/// |
807 |
/// Copies the arc cross references (reverse references) into |
|
808 |
/// the given map. |
|
820 |
/// This function copies the arc cross references (reverse references) |
|
821 |
/// into the given map. The parameter should be a map, whose key type |
|
822 |
/// is the Arc type of the destination graph, while the value type is |
|
823 |
/// the Arc type of the source graph. |
|
809 | 824 |
template <typename ArcCrossRef> |
... | ... |
@@ -815,12 +830,13 @@ |
815 | 830 |
|
816 |
/// \brief Make copy of the given map. |
|
831 |
/// \brief Make a copy of the given arc map. |
|
817 | 832 |
/// |
818 |
/// Makes copy of the given map for the newly created graph. |
|
819 |
/// The new map's key type is the to graph's arc type, |
|
820 |
/// and the copied map's key type is the from graph's arc |
|
821 |
/// type. |
|
822 |
template <typename ToMap, typename FromMap> |
|
823 |
GraphCopy& arcMap(ToMap& tmap, const FromMap& map) { |
|
833 |
/// This function makes a copy of the given arc map for the newly |
|
834 |
/// created graph. |
|
835 |
/// The key type of the new map \c tmap should be the Arc type of the |
|
836 |
/// destination graph, and the key type of the original map \c map |
|
837 |
/// should be the Arc type of the source graph. |
|
838 |
template <typename FromMap, typename ToMap> |
|
839 |
GraphCopy& arcMap(const FromMap& map, ToMap& tmap) { |
|
824 | 840 |
_arc_maps.push_back(new _core_bits::MapCopy<From, Arc, |
825 |
ArcRefMap, |
|
841 |
ArcRefMap, FromMap, ToMap>(map, tmap)); |
|
826 | 842 |
return *this; |
... | ... |
@@ -830,6 +846,6 @@ |
830 | 846 |
/// |
831 |
/// Make a copy of the given arc. |
|
832 |
GraphCopy& arc(TArc& tarc, const Arc& sarc) { |
|
847 |
/// This function makes a copy of the given arc. |
|
848 |
GraphCopy& arc(const Arc& arc, TArc& tarc) { |
|
833 | 849 |
_arc_maps.push_back(new _core_bits::ItemCopy<From, Arc, |
834 |
ArcRefMap, TArc>( |
|
850 |
ArcRefMap, TArc>(arc, tarc)); |
|
835 | 851 |
return *this; |
... | ... |
@@ -837,5 +853,8 @@ |
837 | 853 |
|
838 |
/// \brief |
|
854 |
/// \brief Copy the edge references into the given map. |
|
839 | 855 |
/// |
840 |
/// |
|
856 |
/// This function copies the edge references into the given map. |
|
857 |
/// The parameter should be a map, whose key type is the Edge type of |
|
858 |
/// the source graph, while the value type is the Edge type of the |
|
859 |
/// destination graph. |
|
841 | 860 |
template <typename EdgeRef> |
... | ... |
@@ -847,6 +866,8 @@ |
847 | 866 |
|
848 |
/// \brief |
|
867 |
/// \brief Copy the edge cross references into the given map. |
|
849 | 868 |
/// |
850 |
/// Copies the edge cross references (reverse |
|
851 |
/// references) into the given map. |
|
869 |
/// This function copies the edge cross references (reverse references) |
|
870 |
/// into the given map. The parameter should be a map, whose key type |
|
871 |
/// is the Edge type of the destination graph, while the value type is |
|
872 |
/// the Edge type of the source graph. |
|
852 | 873 |
template <typename EdgeCrossRef> |
... | ... |
@@ -858,12 +879,13 @@ |
858 | 879 |
|
859 |
/// \brief Make copy of the given map. |
|
880 |
/// \brief Make a copy of the given edge map. |
|
860 | 881 |
/// |
861 |
/// Makes copy of the given map for the newly created graph. |
|
862 |
/// The new map's key type is the to graph's edge type, |
|
863 |
/// and the copied map's key type is the from graph's edge |
|
864 |
/// type. |
|
865 |
template <typename ToMap, typename FromMap> |
|
866 |
GraphCopy& edgeMap(ToMap& tmap, const FromMap& map) { |
|
882 |
/// This function makes a copy of the given edge map for the newly |
|
883 |
/// created graph. |
|
884 |
/// The key type of the new map \c tmap should be the Edge type of the |
|
885 |
/// destination graph, and the key type of the original map \c map |
|
886 |
/// should be the Edge type of the source graph. |
|
887 |
template <typename FromMap, typename ToMap> |
|
888 |
GraphCopy& edgeMap(const FromMap& map, ToMap& tmap) { |
|
867 | 889 |
_edge_maps.push_back(new _core_bits::MapCopy<From, Edge, |
868 |
EdgeRefMap, |
|
890 |
EdgeRefMap, FromMap, ToMap>(map, tmap)); |
|
869 | 891 |
return *this; |
... | ... |
@@ -873,6 +895,6 @@ |
873 | 895 |
/// |
874 |
/// Make a copy of the given edge. |
|
875 |
GraphCopy& edge(TEdge& tedge, const Edge& sedge) { |
|
896 |
/// This function makes a copy of the given edge. |
|
897 |
GraphCopy& edge(const Edge& edge, TEdge& tedge) { |
|
876 | 898 |
_edge_maps.push_back(new _core_bits::ItemCopy<From, Edge, |
877 |
EdgeRefMap, TEdge>( |
|
899 |
EdgeRefMap, TEdge>(edge, tedge)); |
|
878 | 900 |
return *this; |
... | ... |
@@ -880,5 +902,6 @@ |
880 | 902 |
|
881 |
/// \brief |
|
903 |
/// \brief Execute copying. |
|
882 | 904 |
/// |
883 |
/// |
|
905 |
/// This function executes the copying of the graph along with the |
|
906 |
/// copying of the assigned data. |
|
884 | 907 |
void run() { |
... | ... |
@@ -886,5 +909,5 @@ |
886 | 909 |
EdgeRefMap edgeRefMap(_from); |
887 |
ArcRefMap arcRefMap( |
|
910 |
ArcRefMap arcRefMap(_from, _to, edgeRefMap, nodeRefMap); |
|
888 | 911 |
_core_bits::GraphCopySelector<To>:: |
889 |
copy( |
|
912 |
copy(_from, _to, nodeRefMap, edgeRefMap); |
|
890 | 913 |
for (int i = 0; i < int(_node_maps.size()); ++i) { |
... | ... |
@@ -906,9 +929,9 @@ |
906 | 929 |
std::vector<_core_bits::MapCopyBase<From, Node, NodeRefMap>* > |
907 |
_node_maps; |
|
930 |
_node_maps; |
|
908 | 931 |
|
909 | 932 |
std::vector<_core_bits::MapCopyBase<From, Arc, ArcRefMap>* > |
910 |
_arc_maps; |
|
933 |
_arc_maps; |
|
911 | 934 |
|
912 | 935 |
std::vector<_core_bits::MapCopyBase<From, Edge, EdgeRefMap>* > |
913 |
_edge_maps; |
|
936 |
_edge_maps; |
|
914 | 937 |
|
... | ... |
@@ -918,7 +941,7 @@ |
918 | 941 |
/// |
919 |
/// Copy a graph to another graph. The complete usage of the |
|
920 |
/// function is detailed in the GraphCopy class, but a short |
|
921 |
/// |
|
942 |
/// This function copies a graph to another graph. |
|
943 |
/// The complete usage of it is detailed in the GraphCopy class, |
|
944 |
/// but a short example shows a basic work: |
|
922 | 945 |
///\code |
923 |
/// |
|
946 |
/// graphCopy(src, trg).nodeRef(nr).edgeCrossRef(ecr).run(); |
|
924 | 947 |
///\endcode |
... | ... |
@@ -927,10 +950,10 @@ |
927 | 950 |
/// nodes of the \c from graph to the nodes of the \c to graph and |
928 |
/// \c ecr will contain the mapping from the arcs of the \c to graph |
|
929 |
/// to the arcs of the \c from graph. |
|
951 |
/// \c ecr will contain the mapping from the edges of the \c to graph |
|
952 |
/// to the edges of the \c from graph. |
|
930 | 953 |
/// |
931 | 954 |
/// \see GraphCopy |
932 |
template <typename To, typename From> |
|
933 |
GraphCopy<To, From> |
|
934 |
copyGraph(To& to, const From& from) { |
|
935 |
return GraphCopy<To, From>(to, from); |
|
955 |
template <typename From, typename To> |
|
956 |
GraphCopy<From, To> |
|
957 |
graphCopy(const From& from, To& to) { |
|
958 |
return GraphCopy<From, To>(from, to); |
|
936 | 959 |
} |
... | ... |
@@ -959,3 +982,3 @@ |
959 | 982 |
Graph, |
960 |
typename enable_if<typename Graph:: |
|
983 |
typename enable_if<typename Graph::FindArcTag, void>::type> |
|
961 | 984 |
{ |
... | ... |
@@ -969,5 +992,6 @@ |
969 | 992 |
|
970 |
/// \brief |
|
993 |
/// \brief Find an arc between two nodes of a digraph. |
|
971 | 994 |
/// |
972 |
/// |
|
995 |
/// This function finds an arc from node \c u to node \c v in the |
|
996 |
/// digraph \c g. |
|
973 | 997 |
/// |
... | ... |
@@ -980,3 +1004,3 @@ |
980 | 1004 |
///\code |
981 |
/// for(Arc e=findArc(g,u,v);e!=INVALID;e=findArc(g,u,v,e)) { |
|
1005 |
/// for(Arc e = findArc(g,u,v); e != INVALID; e = findArc(g,u,v,e)) { |
|
982 | 1006 |
/// ... |
... | ... |
@@ -985,6 +1009,7 @@ |
985 | 1009 |
/// |
986 |
///\sa ArcLookUp |
|
987 |
///\sa AllArcLookUp |
|
988 |
///\ |
|
1010 |
/// \note \ref ConArcIt provides iterator interface for the same |
|
1011 |
/// functionality. |
|
1012 |
/// |
|
989 | 1013 |
///\sa ConArcIt |
1014 |
///\sa ArcLookUp, AllArcLookUp, DynArcLookUp |
|
990 | 1015 |
template <typename Graph> |
... | ... |
@@ -996,6 +1021,6 @@ |
996 | 1021 |
|
997 |
/// \brief Iterator for iterating on arcs |
|
1022 |
/// \brief Iterator for iterating on parallel arcs connecting the same nodes. |
|
998 | 1023 |
/// |
999 |
/// Iterator for iterating on arcs connected the same nodes. It is |
|
1000 |
/// higher level interface for the findArc() function. You can |
|
1024 |
/// Iterator for iterating on parallel arcs connecting the same nodes. It is |
|
1025 |
/// a higher level interface for the \ref findArc() function. You can |
|
1001 | 1026 |
/// use it the following way: |
... | ... |
@@ -1008,5 +1033,3 @@ |
1008 | 1033 |
///\sa findArc() |
1009 |
///\sa ArcLookUp |
|
1010 |
///\sa AllArcLookUp |
|
1011 |
///\sa DynArcLookUp |
|
1034 |
///\sa ArcLookUp, AllArcLookUp, DynArcLookUp |
|
1012 | 1035 |
template <typename _Graph> |
... | ... |
@@ -1023,4 +1046,4 @@ |
1023 | 1046 |
/// |
1024 |
/// Construct a new ConArcIt iterating on the arcs which |
|
1025 |
/// connects the \c u and \c v node. |
|
1047 |
/// Construct a new ConArcIt iterating on the arcs that |
|
1048 |
/// connects nodes \c u and \c v. |
|
1026 | 1049 |
ConArcIt(const Graph& g, Node u, Node v) : _graph(g) { |
... | ... |
@@ -1031,4 +1054,3 @@ |
1031 | 1054 |
/// |
1032 |
/// Construct a new ConArcIt which continues the iterating from |
|
1033 |
/// the \c e arc. |
|
1055 |
/// Construct a new ConArcIt that continues the iterating from arc \c a. |
|
1034 | 1056 |
ConArcIt(const Graph& g, Arc a) : Parent(a), _graph(g) {} |
... | ... |
@@ -1093,6 +1115,6 @@ |
1093 | 1115 |
|
1094 |
/// \brief |
|
1116 |
/// \brief Find an edge between two nodes of a graph. |
|
1095 | 1117 |
/// |
1096 |
/// Finds an edge from node \c u to node \c v in graph \c g. |
|
1097 |
/// If the node \c u and node \c v is equal then each loop edge |
|
1118 |
/// This function finds an edge from node \c u to node \c v in graph \c g. |
|
1119 |
/// If node \c u and node \c v is equal then each loop edge |
|
1098 | 1120 |
/// will be enumerated once. |
... | ... |
@@ -1100,10 +1122,10 @@ |
1100 | 1122 |
/// If \c prev is \ref INVALID (this is the default value), then |
1101 |
/// it finds the first arc from \c u to \c v. Otherwise it looks for |
|
1102 |
/// the next arc from \c u to \c v after \c prev. |
|
1103 |
/// |
|
1123 |
/// it finds the first edge from \c u to \c v. Otherwise it looks for |
|
1124 |
/// the next edge from \c u to \c v after \c prev. |
|
1125 |
/// \return The found edge or \ref INVALID if there is no such an edge. |
|
1104 | 1126 |
/// |
1105 |
/// Thus you can iterate through each |
|
1127 |
/// Thus you can iterate through each edge between \c u and \c v |
|
1128 |
/// as it follows. |
|
1106 | 1129 |
///\code |
1107 |
/// for(Edge e = findEdge(g,u,v); e != INVALID; |
|
1108 |
/// e = findEdge(g,u,v,e)) { |
|
1130 |
/// for(Edge e = findEdge(g,u,v); e != INVALID; e = findEdge(g,u,v,e)) { |
|
1109 | 1131 |
/// ... |
... | ... |
@@ -1112,4 +1134,6 @@ |
1112 | 1134 |
/// |
1135 |
/// \note \ref ConEdgeIt provides iterator interface for the same |
|
1136 |
/// functionality. |
|
1137 |
/// |
|
1113 | 1138 |
///\sa ConEdgeIt |
1114 |
|
|
1115 | 1139 |
template <typename Graph> |
... | ... |
@@ -1121,9 +1145,9 @@ |
1121 | 1145 |
|
1122 |
/// \brief Iterator for iterating on edges |
|
1146 |
/// \brief Iterator for iterating on parallel edges connecting the same nodes. |
|
1123 | 1147 |
/// |
1124 |
/// Iterator for iterating on edges connected the same nodes. It is |
|
1125 |
/// higher level interface for the findEdge() function. You can |
|
1148 |
/// Iterator for iterating on parallel edges connecting the same nodes. |
|
1149 |
/// It is a higher level interface for the findEdge() function. You can |
|
1126 | 1150 |
/// use it the following way: |
1127 | 1151 |
///\code |
1128 |
/// for (ConEdgeIt<Graph> it(g, |
|
1152 |
/// for (ConEdgeIt<Graph> it(g, u, v); it != INVALID; ++it) { |
|
1129 | 1153 |
/// ... |
... | ... |
@@ -1145,4 +1169,4 @@ |
1145 | 1169 |
/// |
1146 |
/// Construct a new ConEdgeIt iterating on the edges which |
|
1147 |
/// connects the \c u and \c v node. |
|
1170 |
/// Construct a new ConEdgeIt iterating on the edges that |
|
1171 |
/// connects nodes \c u and \c v. |
|
1148 | 1172 |
ConEdgeIt(const Graph& g, Node u, Node v) : _graph(g) { |
... | ... |
@@ -1153,4 +1177,3 @@ |
1153 | 1177 |
/// |
1154 |
/// Construct a new ConEdgeIt which continues the iterating from |
|
1155 |
/// the \c e edge. |
|
1178 |
/// Construct a new ConEdgeIt that continues iterating from edge \c e. |
|
1156 | 1179 |
ConEdgeIt(const Graph& g, Edge e) : Parent(e), _graph(g) {} |
... | ... |
@@ -1170,6 +1193,6 @@ |
1170 | 1193 |
|
1171 |
///Dynamic arc look |
|
1194 |
///Dynamic arc look-up between given endpoints. |
|
1172 | 1195 |
|
1173 | 1196 |
///Using this class, you can find an arc in a digraph from a given |
1174 |
///source to a given target in amortized time <em>O |
|
1197 |
///source to a given target in amortized time <em>O</em>(log<em>d</em>), |
|
1175 | 1198 |
///where <em>d</em> is the out-degree of the source node. |
... | ... |
@@ -1179,8 +1202,8 @@ |
1179 | 1202 |
/// |
1180 |
///See the \ref ArcLookUp and \ref AllArcLookUp classes if your |
|
1181 |
///digraph is not changed so frequently. |
|
1203 |
///This is a dynamic data structure. Consider to use \ref ArcLookUp or |
|
1204 |
///\ref AllArcLookUp if your digraph is not changed so frequently. |
|
1182 | 1205 |
/// |
1183 |
///This class uses a self-adjusting binary search tree, Sleator's |
|
1184 |
///and Tarjan's Splay tree for guarantee the logarithmic amortized |
|
1185 |
/// |
|
1206 |
///This class uses a self-adjusting binary search tree, the Splay tree |
|
1207 |
///of Sleator and Tarjan to guarantee the logarithmic amortized |
|
1208 |
///time bound for arc look-ups. This class also guarantees the |
|
1186 | 1209 |
///optimal time bound in a constant factor for any distribution of |
... | ... |
@@ -1509,4 +1532,4 @@ |
1509 | 1532 |
///Find an arc between two nodes. |
1510 |
///\param s The source node |
|
1511 |
///\param t The target node |
|
1533 |
///\param s The source node. |
|
1534 |
///\param t The target node. |
|
1512 | 1535 |
///\param p The previous arc between \c s and \c t. It it is INVALID or |
... | ... |
@@ -1521,7 +1544,7 @@ |
1521 | 1544 |
///... |
1522 |
///int n=0; |
|
1523 |
///for(Arc e=ae(u,v);e!=INVALID;e=ae(u,v,e)) n++; |
|
1545 |
///int n = 0; |
|
1546 |
///for(Arc a = ae(u,v); a != INVALID; a = ae(u,v,a)) n++; |
|
1524 | 1547 |
///\endcode |
1525 | 1548 |
/// |
1526 |
///Finding the arcs take at most <em>O |
|
1549 |
///Finding the arcs take at most <em>O</em>(log<em>d</em>) |
|
1527 | 1550 |
///amortized time, specifically, the time complexity of the lookups |
... | ... |
@@ -1531,7 +1554,6 @@ |
1531 | 1554 |
///\note This is a dynamic data structure, therefore the data |
1532 |
///structure is updated after each graph alteration. However, |
|
1533 |
///theoretically this data structure is faster than \c ArcLookUp |
|
1534 |
/// |
|
1555 |
///structure is updated after each graph alteration. Thus although |
|
1556 |
///this data structure is theoretically faster than \ref ArcLookUp |
|
1557 |
///and \ref AllArcLookup, it often provides worse performance than |
|
1535 | 1558 |
///them. |
1536 |
/// |
|
1537 | 1559 |
Arc operator()(Node s, Node t, Arc p = INVALID) const { |
... | ... |
@@ -1587,6 +1609,6 @@ |
1587 | 1609 |
|
1588 |
///Fast arc look |
|
1610 |
///Fast arc look-up between given endpoints. |
|
1589 | 1611 |
|
1590 | 1612 |
///Using this class, you can find an arc in a digraph from a given |
1591 |
///source to a given target in time <em>O(log |
|
1613 |
///source to a given target in time <em>O</em>(log<em>d</em>), |
|
1592 | 1614 |
///where <em>d</em> is the out-degree of the source node. |
... | ... |
@@ -1596,6 +1618,6 @@ |
1596 | 1618 |
/// |
1597 |
///\warning This class is static, so you should refresh() (or at least |
|
1598 |
///refresh(Node)) this data structure |
|
1599 |
///whenever the digraph changes. This is a time consuming (superlinearly |
|
1600 |
///proportional (<em>O(m</em>log<em>m)</em>) to the number of arcs). |
|
1619 |
///\warning This class is static, so you should call refresh() (or at |
|
1620 |
///least refresh(Node)) to refresh this data structure whenever the |
|
1621 |
///digraph changes. This is a time consuming (superlinearly proportional |
|
1622 |
///(<em>O</em>(<em>m</em> log<em>m</em>)) to the number of arcs). |
|
1601 | 1623 |
/// |
... | ... |
@@ -1648,3 +1670,3 @@ |
1648 | 1670 |
public: |
1649 |
///Refresh the data structure at a node. |
|
1671 |
///Refresh the search data structure at a node. |
|
1650 | 1672 |
|
... | ... |
@@ -1652,4 +1674,4 @@ |
1652 | 1674 |
/// |
1653 |
///It runs in time <em>O(d</em>log<em>d)</em>, where <em>d</em> is |
|
1654 |
///the number of the outgoing arcs of \c n. |
|
1675 |
///It runs in time <em>O</em>(<em>d</em> log<em>d</em>), where <em>d</em> |
|
1676 |
///is the number of the outgoing arcs of \c n. |
|
1655 | 1677 |
void refresh(Node n) |
... | ... |
@@ -1669,6 +1691,5 @@ |
1669 | 1691 |
/// |
1670 |
///It runs in time <em>O(m</em>log<em>D)</em>, where <em>m</em> is |
|
1671 |
///the number of the arcs of \c n and <em>D</em> is the maximum |
|
1692 |
///It runs in time <em>O</em>(<em>m</em> log<em>D</em>), where <em>m</em> is |
|
1693 |
///the number of the arcs in the digraph and <em>D</em> is the maximum |
|
1672 | 1694 |
///out-degree of the digraph. |
1673 |
|
|
1674 | 1695 |
void refresh() |
... | ... |
@@ -1680,6 +1701,6 @@ |
1680 | 1701 |
|
1681 |
///Find an arc between two nodes in time <em>O(</em>log<em>d)</em>, where |
|
1682 |
/// <em>d</em> is the number of outgoing arcs of \c s. |
|
1683 |
///\param s The source node |
|
1684 |
///\param t The target node |
|
1702 |
///Find an arc between two nodes in time <em>O</em>(log<em>d</em>), where |
|
1703 |
///<em>d</em> is the number of outgoing arcs of \c s. |
|
1704 |
///\param s The source node. |
|
1705 |
///\param t The target node. |
|
1685 | 1706 |
///\return An arc from \c s to \c t if there exists, |
... | ... |
@@ -1689,5 +1710,3 @@ |
1689 | 1710 |
///this operator. If you change the outgoing arcs of |
1690 |
///a single node \c n, then |
|
1691 |
///\ref refresh(Node) "refresh(n)" is enough. |
|
1692 |
/// |
|
1711 |
///a single node \c n, then \ref refresh(Node) "refresh(n)" is enough. |
|
1693 | 1712 |
Arc operator()(Node s, Node t) const |
... | ... |
@@ -1703,11 +1722,12 @@ |
1703 | 1722 |
|
1704 |
///Fast look |
|
1723 |
///Fast look-up of all arcs between given endpoints. |
|
1705 | 1724 |
|
1706 | 1725 |
///This class is the same as \ref ArcLookUp, with the addition |
1707 |
///that it makes it possible to find all arcs between given |
|
1726 |
///that it makes it possible to find all parallel arcs between given |
|
1727 |
///endpoints. |
|
1708 | 1728 |
/// |
1709 |
///\warning This class is static, so you should refresh() (or at least |
|
1710 |
///refresh(Node)) this data structure |
|
1711 |
///whenever the digraph changes. This is a time consuming (superlinearly |
|
1712 |
///proportional (<em>O(m</em>log<em>m)</em>) to the number of arcs). |
|
1729 |
///\warning This class is static, so you should call refresh() (or at |
|
1730 |
///least refresh(Node)) to refresh this data structure whenever the |
|
1731 |
///digraph changes. This is a time consuming (superlinearly proportional |
|
1732 |
///(<em>O</em>(<em>m</em> log<em>m</em>)) to the number of arcs). |
|
1713 | 1733 |
/// |
... | ... |
@@ -1735,3 +1755,2 @@ |
1735 | 1755 |
next=refreshNext(_right[head],next); |
1736 |
// _next[head]=next; |
|
1737 | 1756 |
_next[head]=( next!=INVALID && _g.target(next)==_g.target(head)) |
... | ... |
@@ -1760,5 +1779,4 @@ |
1760 | 1779 |
/// |
1761 |
///It runs in time <em>O(d</em>log<em>d |
|
1780 |
///It runs in time <em>O</em>(<em>d</em> log<em>d</em>), where <em>d</em> is |
|
1762 | 1781 |
///the number of the outgoing arcs of \c n. |
1763 |
|
|
1764 | 1782 |
void refresh(Node n) |
... | ... |
@@ -1774,6 +1792,5 @@ |
1774 | 1792 |
/// |
1775 |
///It runs in time <em>O(m</em>log<em>D)</em>, where <em>m</em> is |
|
1776 |
///the number of the arcs of \c n and <em>D</em> is the maximum |
|
1793 |
///It runs in time <em>O</em>(<em>m</em> log<em>D</em>), where <em>m</em> is |
|
1794 |
///the number of the arcs in the digraph and <em>D</em> is the maximum |
|
1777 | 1795 |
///out-degree of the digraph. |
1778 |
|
|
1779 | 1796 |
void refresh() |
... | ... |
@@ -1786,4 +1803,4 @@ |
1786 | 1803 |
///Find an arc between two nodes. |
1787 |
///\param s The source node |
|
1788 |
///\param t The target node |
|
1804 |
///\param s The source node. |
|
1805 |
///\param t The target node. |
|
1789 | 1806 |
///\param prev The previous arc between \c s and \c t. It it is INVALID or |
... | ... |
@@ -1798,8 +1815,8 @@ |
1798 | 1815 |
///... |
1799 |
///int n=0; |
|
1800 |
///for(Arc e=ae(u,v);e!=INVALID;e=ae(u,v,e)) n++; |
|
1816 |
///int n = 0; |
|
1817 |
///for(Arc a = ae(u,v); a != INVALID; a=ae(u,v,a)) n++; |
|
1801 | 1818 |
///\endcode |
1802 | 1819 |
/// |
1803 |
///Finding the first arc take <em>O(</em>log<em>d)</em> time, where |
|
1804 |
/// <em>d</em> is the number of outgoing arcs of \c s. Then, the |
|
1820 |
///Finding the first arc take <em>O</em>(log<em>d</em>) time, where |
|
1821 |
///<em>d</em> is the number of outgoing arcs of \c s. Then, the |
|
1805 | 1822 |
///consecutive arcs are found in constant time. |
... | ... |
@@ -1808,4 +1825,3 @@ |
1808 | 1825 |
///this operator. If you change the outgoing arcs of |
1809 |
///a single node \c n, then |
|
1810 |
///\ref refresh(Node) "refresh(n)" is enough. |
|
1826 |
///a single node \c n, then \ref refresh(Node) "refresh(n)" is enough. |
|
1811 | 1827 |
/// |
... | ... |
@@ -65,7 +65,7 @@ |
65 | 65 |
|
66 |
DigraphCopy<ListDigraph, SmartDigraph>(to, from). |
|
67 |
nodeMap(tnm, fnm).arcMap(tam, fam). |
|
66 |
digraphCopy(from, to). |
|
67 |
nodeMap(fnm, tnm).arcMap(fam, tam). |
|
68 | 68 |
nodeRef(nr).arcRef(er). |
69 | 69 |
nodeCrossRef(ncr).arcCrossRef(ecr). |
70 |
node( |
|
70 |
node(fn, tn).arc(fa, ta).run(); |
|
71 | 71 |
|
... | ... |
@@ -140,7 +140,7 @@ |
140 | 140 |
|
141 |
GraphCopy<ListGraph, SmartGraph>(to, from). |
|
142 |
nodeMap(tnm, fnm).arcMap(tam, fam).edgeMap(tem, fem). |
|
141 |
graphCopy(from, to). |
|
142 |
nodeMap(fnm, tnm).arcMap(fam, tam).edgeMap(fem, tem). |
|
143 | 143 |
nodeRef(nr).arcRef(ar).edgeRef(er). |
144 | 144 |
nodeCrossRef(ncr).arcCrossRef(acr).edgeCrossRef(ecr). |
145 |
node( |
|
145 |
node(fn, tn).arc(fa, ta).edge(fe, te).run(); |
|
146 | 146 |
|
0 comments (0 inline)