This file is indexed.

/usr/include/claw/impl/graph.tpp is in libclaw-dev 1.7.3-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
/*
  CLAW - a C++ Library Absolutely Wonderful

  CLAW is a free library without any particular aim but being useful to 
  anyone.

  Copyright (C) 2005-2011 Julien Jorge

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

  contact: julien.jorge@gamned.org
*/
/**
 * \file graph.tpp
 * \brief Implementation of the claw::graph class.
 * \author Julien Jorge
 */
#include <cassert>
#include <algorithm>

#include <claw/functional.hpp>

/*---------------------------------------------------------------------------*/
/**
 * \brief Default constructor.
 */
claw::graph_exception::graph_exception() throw()
  : m_msg("No message") 
{

} // graph_exception()

/*---------------------------------------------------------------------------*/
/**
 * \brief Constructor.
 * \param s An explanation of the problem.
 */
claw::graph_exception::graph_exception( const std::string& s) throw()
  : m_msg(s) 
{

} // graph_exception()

/*---------------------------------------------------------------------------*/
/**
 * \brief Destructor.
 */
claw::graph_exception::~graph_exception() throw()
{

} // ~graph_exception()

/*---------------------------------------------------------------------------*/
/**
 * \brief Get an explanation of the problem.
 */
const char* claw::graph_exception::what() const throw()
{
  return m_msg.c_str(); 
} // what()




/*---------------------------------------------------------------------------*/
/**
 * \brief Constructor of the graph_vertex_iterator class.
 */
template <class S, class A, class Comp>
claw::graph<S, A, Comp>::graph_vertex_iterator::graph_vertex_iterator()
{

} // graph_vertex_iterator() [constructor]

/*---------------------------------------------------------------------------*/
/**
 * \brief Preincrement.
 * \pre Iterator is not at the end of the container.
 */
template <class S, class A, class Comp>
typename claw::graph<S, A, Comp>::graph_vertex_iterator&
claw::graph<S, A, Comp>::graph_vertex_iterator::operator++()
{
  ++m_iterator;
  return *this;
} // operator++() [preincrement]

/*---------------------------------------------------------------------------*/
/**
 * \brief Postincrement.
 * \pre Iterator is not at the end of the container.
 */
template <class S, class A, class Comp>
typename claw::graph<S, A, Comp>::graph_vertex_iterator
claw::graph<S, A, Comp>::graph_vertex_iterator::operator++(int)
{
  graph_vertex_iterator it_tmp(*this);
  m_iterator++;
  return *this;
} // operator++() [postincrement]

/*---------------------------------------------------------------------------*/
/**
 * \brief Predecrement.
 * \pre Iterator is not at the begining of the container.
 */
template <class S, class A, class Comp>
typename claw::graph<S, A, Comp>::graph_vertex_iterator&
claw::graph<S, A, Comp>::graph_vertex_iterator::operator--()
{
  --m_iterator;
  return *this;
} // operator--() [predecrement]

/*---------------------------------------------------------------------------*/
/**
 * \brief Postdecrement.
 * \pre Iterator is not at the begining of the container.
 */
template <class S, class A, class Comp>
typename claw::graph<S, A, Comp>::graph_vertex_iterator 
claw::graph<S, A, Comp>::graph_vertex_iterator::operator--(int)
{
  graph_vertex_iterator it_tmp(*this);
  m_iterator--;
  return it_tmp;
} // operator--() [postdecrement]

/*---------------------------------------------------------------------------*/
/**
 * \brief Dereference.
 * \pre Iterator is not at the end of the container.
 */
template <class S, class A, class Comp>
typename claw::graph<S, A, Comp>::graph_vertex_iterator::reference
claw::graph<S, A, Comp>::graph_vertex_iterator::operator*() const
{
  return m_iterator->first;
} // operator*()

/*---------------------------------------------------------------------------*/
/**
 * \brief Reference.
 * \pre Iterator is not at the end of the container.
 */
template <class S, class A, class Comp>
typename claw::graph<S, A, Comp>::graph_vertex_iterator::pointer
claw::graph<S, A, Comp>::graph_vertex_iterator::operator->() const
{
  return &(m_iterator->first);
} // operator->()

/*---------------------------------------------------------------------------*/
/**
 * \brief Equality.
 * \param it Iterator to compare to.
 * \pre Iterator and it are not at the end of their respective  containers.
 */
template <class S, class A, class Comp>
bool claw::graph<S, A, Comp>::graph_vertex_iterator::operator==
(const graph_vertex_iterator& it) const
{
  return m_iterator == it.m_iterator;
} // operator==()

/*---------------------------------------------------------------------------*/
/**
 * \brief Difference.
 * \param it Iterator to compare to.
 * \pre Iterator and it are not at the end of their respective  containers.
 */
template <class S, class A, class Comp>
bool claw::graph<S, A, Comp>::graph_vertex_iterator::operator!=
(const graph_vertex_iterator& it) const
{
  return m_iterator != it.m_iterator;
} // operator!=()

/*---------------------------------------------------------------------------*/
/**
 * \brief Constructor with an iterator on graph class data.
 * \param it Iterator where scan starts.
 */
template <class S, class A, class Comp>
claw::graph<S, A, Comp>::graph_vertex_iterator::graph_vertex_iterator
(typename graph_content::const_iterator it)
  : m_iterator(it)
{
  
} // graph_vertex_iterator() [constructor on an iterator]




/*---------------------------------------------------------------------------*/
/**
 * \brief Constructor.
 */
template <class S, class A, class Comp>
claw::graph<S, A, Comp>::graph_edge_iterator::edge::edge()
  : m_label(NULL), m_source(NULL), m_target(NULL)
{

} // edge::edge [constructor]

/*---------------------------------------------------------------------------*/
/**
 * \brief Gets edge's label.
 */
template <class S, class A, class Comp>
const typename claw::graph<S, A, Comp>::edge_type& 
claw::graph<S, A, Comp>::graph_edge_iterator::edge::label() const
{
  assert(m_label != NULL);
  return *m_label;
} // edge::label()

/*---------------------------------------------------------------------------*/
/**
 * \brief Gets edge's source.
 */
template <class S, class A, class Comp>
const typename claw::graph<S, A, Comp>::vertex_type& 
claw::graph<S, A, Comp>::graph_edge_iterator::edge::source() const
{
  assert(m_source != NULL);
  return *m_source;
} // edge::source()

/*---------------------------------------------------------------------------*/
/**
 * \brief Gets edge's target.
 */
template <class S, class A, class Comp>
const typename claw::graph<S, A, Comp>::vertex_type&
claw::graph<S, A, Comp>::graph_edge_iterator::edge::target() const
{
  assert(m_target != NULL);
  return *m_target;
} // edge::target()

/*---------------------------------------------------------------------------*/
/**
 * \brief Sets label, source and taget.
 */
template <class S, class A, class Comp>
void claw::graph<S, A, Comp>::graph_edge_iterator::edge::
set( const edge_type& l, const vertex_type& s, const vertex_type& t )
{
  m_label = &l;
  m_source = &s;
  m_target = &t;
} // edge::set()




/*---------------------------------------------------------------------------*/
/**
 * \brief Constructor of the graph_edge_iterator class.
 */
template <class S, class A, class Comp>
claw::graph<S, A, Comp>::graph_edge_iterator::graph_edge_iterator()
{

} // graph_edge_iterator() [constructor]

/*---------------------------------------------------------------------------*/
/**
 * \brief Preincrement.
 * \pre Iterator is not at the end of the container.
 */
template <class S, class A, class Comp>
typename claw::graph<S, A, Comp>::graph_edge_iterator&
claw::graph<S, A, Comp>::graph_edge_iterator::operator++()
{
  bool ok = true;
  ++m_neighbours_iterator;

  // end of a neighbourhood
  if ( m_neighbours_iterator == m_vertex_iterator->second.end() )
    {
      // find next edge or end.
      ok = false;
      ++m_vertex_iterator;

      while ( (m_vertex_iterator != m_vertex_end) && !ok )
        if ( !m_vertex_iterator->second.empty() )
          {
            ok = true;
            m_neighbours_iterator = m_vertex_iterator->second.begin();
          }
        else
          ++m_vertex_iterator;
    }

  if (ok)
    m_edge.set( m_neighbours_iterator->second, m_vertex_iterator->first,
                m_neighbours_iterator->first );

  return *this;
} // operator++() [preincrement]

/*---------------------------------------------------------------------------*/
/**
 * \brief Postincrement.
 * \pre Iterator is not at the end of the container.
 */
template <class S, class A, class Comp>
typename claw::graph<S, A, Comp>::graph_edge_iterator
claw::graph<S, A, Comp>::graph_edge_iterator::operator++(int)
{
  graph_edge_iterator it_tmp(*this);
  ++(*this);
  return it_tmp;
} // operator++() [postincrement]

/*---------------------------------------------------------------------------*/
/**
 * \brief Predecrement.
 * \pre Iterator is not at the begining of the container.
 */
template <class S, class A, class Comp>
typename claw::graph<S, A, Comp>::graph_edge_iterator&
claw::graph<S, A, Comp>::graph_edge_iterator::operator--()
{
  bool ok = true;

  if (m_vertex_iterator == m_vertex_end)
    {
      --m_vertex_iterator;
      m_neighbours_iterator = m_vertex_iterator->second.end();
    }

  // begining of a neighbourhood
  if ( m_neighbours_iterator == m_vertex_iterator->second.begin() )
    {
      ok = false;
      // find previous edge or begining.
      while ( (m_vertex_iterator != m_vertex_begin) && !ok )
        {
          --m_vertex_iterator;
          if ( !m_vertex_iterator->second.empty() )
            {
              ok = true;
              m_neighbours_iterator = --m_vertex_iterator->second.end();
            }
        }
    }
  else
    --m_neighbours_iterator;

  if (!ok)
    m_vertex_iterator == m_vertex_end;
  else
    m_edge.set( m_neighbours_iterator->second, m_vertex_iterator->first,
                m_neighbours_iterator->first );

  return *this;
} // operator--() [predecrement]

/*---------------------------------------------------------------------------*/
/**
 * \brief postdecrement.
 * \pre Iterator is not at the begining of the container.
 */
template <class S, class A, class Comp>
typename claw::graph<S, A, Comp>::graph_edge_iterator 
claw::graph<S, A, Comp>::graph_edge_iterator::operator--(int)
{
  graph_edge_iterator it_tmp(*this);
  --(*this);
  return it_tmp;
} // operator--() [postdecrement]

/*---------------------------------------------------------------------------*/
/**
 * \brief Reference.
 * \pre Iterator is not at the end of the container.
 */
template <class S, class A, class Comp>
typename claw::graph<S, A, Comp>::graph_edge_iterator::reference
claw::graph<S, A, Comp>::graph_edge_iterator::operator*() const
{
  return m_edge;
} // operator*()

/*---------------------------------------------------------------------------*/
/**
 * \brief Pointer.
 * \pre Iterator is not at the end of the container.
 */
template <class S, class A, class Comp>
typename claw::graph<S, A, Comp>::graph_edge_iterator::pointer
claw::graph<S, A, Comp>::graph_edge_iterator::operator->() const
{
  return &m_edge;
} // operator->()

/*---------------------------------------------------------------------------*/
/**
 * \brief Equality.
 * \param it Iterator to compare to.
 * \pre Iterator and it are not at the end of their respective  containers.
 */
template <class S, class A, class Comp>
bool claw::graph<S, A, Comp>::graph_edge_iterator::operator==
(const graph_edge_iterator& it) const
{
  // both are empty
  if ( m_vertex_begin == m_vertex_end )
    return (it.m_vertex_begin == it.m_vertex_end) 
      && (m_vertex_begin == it.m_vertex_begin);
  else
    if ( it.m_vertex_begin == it.m_vertex_end ) // -it- is empty
      return false;
    else
      // none is empty, perheaps at the end ?
      if (m_vertex_iterator == m_vertex_end)
        return (it.m_vertex_iterator == it.m_vertex_end)
          && (m_vertex_begin == it.m_vertex_begin);
      else
        if (it.m_vertex_iterator == it.m_vertex_end)
          return false;
        else
          return m_neighbours_iterator == it.m_neighbours_iterator;
} // operator==()

/*---------------------------------------------------------------------------*/
/**
 * \brief Difference.
 * \param it Iterator to compare to.
 * \pre Iterator and it are not at the end of their respective  containers.
 */
template <class S, class A, class Comp>
bool claw::graph<S, A, Comp>::graph_edge_iterator::operator!=
(const graph_edge_iterator& it) const
{
  return !(*this == it);
} // operator!=()

/*---------------------------------------------------------------------------*/
/**
 * \brief Constructor with an iterator on graph class data.
 * \param it_begin Iterator on the first node.
 * \param it_end Iterator on the last node.
 * \param it_s Iterator on current edge's source.
 * \param it_d Iterator where scan starts.
 */
template <class S, class A, class Comp>
claw::graph<S, A, Comp>::graph_edge_iterator::graph_edge_iterator
( typename graph_content::const_iterator it_begin,
  typename graph_content::const_iterator it_end,
  typename graph_content::const_iterator it_s,
  typename neighbours_list::const_iterator it_d)
  : m_vertex_begin(it_begin), m_vertex_end(it_end), 
    m_vertex_iterator(it_s), m_neighbours_iterator(it_d)
{
  if (m_vertex_begin != m_vertex_end)
    m_edge.set( m_neighbours_iterator->second, m_vertex_iterator->first,
                m_neighbours_iterator->first );
} // graph_edge_iterator() [constructor on an iterator]




/*---------------------------------------------------------------------------*/
/**
 * \brief Constructor.
 */
template <class S, class A, class Comp>
claw::graph<S, A, Comp>::graph()
  : m_edges_count(0)
{

} // graph::graph() [constructor]

/*---------------------------------------------------------------------------*/
/**
 * \brief Add an edge in the graph.
 * \param s1 Tail of the edge.
 * \param s2 Head of the edgre.
 * \param e The label on the edge.
 */
template <class S, class A, class Comp>
void claw::graph<S, A, Comp>::add_edge
( const vertex_type& s1, const vertex_type& s2, const edge_type& e )
{
  if ( !edge_exists(s1, s2) )
    {
      // s2 is not a neighbor of s1
      ++m_edges_count;

      add_vertex(s1);
      add_vertex(s2); 

      // in all cases, s2 as one more inner edge
      ++m_inner_degrees[s2]; 
    }

  m_edges[s1][s2] = e;
} // graph::add_edge()

/*---------------------------------------------------------------------------*/
/**
 * \brief Add a vertex.
 * \param s The vertex to add.
 */
template <class S, class A, class Comp>
void claw::graph<S, A, Comp>::add_vertex( const vertex_type& s )
{
  std::pair<S, neighbours_list> p;

  if (m_edges.find(s) == m_edges.end())
    {
      // Add the vertex in the adjacency list.
      p.first = s;
      m_edges.insert(p);
      m_inner_degrees[s] = 0;
    }
} // graph::add_vertex()

/*---------------------------------------------------------------------------*/
/**
 * \brief Check if there is an edge linking to vertices.
 * \param s Vertex at the tail of the edge.
 * \param r Vertex at the head of the edge.
 */
template <class S, class A, class Comp>
bool claw::graph<S, A, Comp>::edge_exists
( const vertex_type& s, const vertex_type& r ) const 
{ 
  typename graph_content::const_iterator it = m_edges.find(s);

  if ( it == m_edges.end() )
    return false;
  else
    return it->second.find(r) != it->second.end(); 
} // graph::edge_exists()

/*---------------------------------------------------------------------------*/
/**
 * \brief Get the neighbors of a vertex.
 * \param s The vertex.
 * \param v (out) The neighbors.
 */
template <class S, class A, class Comp>
void claw::graph<S, A, Comp>::neighbours
(const vertex_type& s, std::vector<vertex_type>& v) const 
{ 
  typename graph_content::const_iterator it_s = m_edges.find(s);
  v.clear();

  if ( it_s != m_edges.end() )
    {
      v.resize( it_s->second.size() );
      std::transform( it_s->second.begin(), it_s->second.end(), v.begin(),
                      const_first<S,A>() );
    }
} // graph::neighbours()

/*---------------------------------------------------------------------------*/
/**
 * \brief Get all the vertices.
 * \param v (out) The vertices.
 */
template <class S, class A, class Comp>
void claw::graph<S, A, Comp>::vertices(std::vector<vertex_type>& v) const 
{ 
  v.clear();
  v.resize(m_edges.size());

  std::transform( m_edges.begin(), m_edges.end(), v.begin(), 
                  const_first<S,neighbours_list>() );
} // graph::vertices()

/*---------------------------------------------------------------------------*/
/**
 * \brief Get a node iterator on the first node.
 * \remark Returns vertex_end() if graph is empty.
 */
template <class S, class A, class Comp>
typename claw::graph<S, A, Comp>::vertex_iterator
claw::graph<S, A, Comp>::vertex_begin() const
{
  return vertex_iterator( m_edges.begin() );
} // graph::vertex_begin()

/*---------------------------------------------------------------------------*/
/**
 * \brief Get a node iterator past the last node.
 */
template <class S, class A, class Comp>
typename claw::graph<S, A, Comp>::vertex_iterator 
claw::graph<S, A, Comp>::vertex_end() const
{
  return vertex_iterator( m_edges.end() );
} // graph::vertex_end()

/*---------------------------------------------------------------------------*/
/**
 * \brief Get a node iterator on a particular node.
 * \remark Returns vertex_end() if S is not found.
 */
template <class S, class A, class Comp>
typename claw::graph<S, A, Comp>::vertex_iterator 
claw::graph<S, A, Comp>::vertex_begin( const vertex_type& s ) const
{
  return vertex_iterator( m_edges.find(s) );
} // graph::vertex_begin()

/*---------------------------------------------------------------------------*/
/**
 * \brief Get a reverse node iterator on the first node.
 * \remark Returns vertex_rend() if graph is empty.
 */
template <class S, class A, class Comp>
typename claw::graph<S, A, Comp>::reverse_vertex_iterator
claw::graph<S, A, Comp>::vertex_rbegin() const
{
  return reverse_vertex_iterator( vertex_end() );
} // graph::vertex_rbegin()

/*---------------------------------------------------------------------------*/
/**
 * \brief Get a reverse node iterator past the last node.
 */
template <class S, class A, class Comp>
typename claw::graph<S, A, Comp>::reverse_vertex_iterator 
claw::graph<S, A, Comp>::vertex_rend() const
{
  return reverse_vertex_iterator( vertex_begin() );
} // graph::vertex_rend()

/*---------------------------------------------------------------------------*/
/**
 * \brief Get a reverse node iterator just after a particular node.
 * \remark Returns vertex_rend() if s is not found.
 */
template <class S, class A, class Comp>
typename claw::graph<S, A, Comp>::reverse_vertex_iterator 
claw::graph<S, A, Comp>::vertex_rbegin( const vertex_type& s ) const
{
  vertex_iterator it = vertex_begin(s);

  if (it != vertex_end())
    ++it;

  return reverse_vertex_iterator( it );
} // graph::vertex_rbegin()

/*---------------------------------------------------------------------------*/
/**
 * \brief Get an edge iterator on the first edge.
 * \remark Returns edge_end() if there's no edge in the graph.
 */
template <class S, class A, class Comp>
typename claw::graph<S, A, Comp>::edge_iterator
claw::graph<S, A, Comp>::edge_begin() const
{
  bool ok = false;
  typename graph_content::const_iterator it_s;
  it_s = m_edges.begin();

  while ( (it_s != m_edges.end()) && !ok )
    if ( it_s->second.empty() )
      ++it_s;
    else
      ok = true;

  if (ok)
    return edge_iterator( m_edges.begin(), m_edges.end(), it_s, 
                          it_s->second.begin() );
  else
    return edge_end();
                                                 
} // graph::edge_begin()

/*---------------------------------------------------------------------------*/
/**
 * \brief Get an edge iterator after the last edge.
 */
template <class S, class A, class Comp>
typename claw::graph<S, A, Comp>::edge_iterator
claw::graph<S, A, Comp>::edge_end() const
{
  return edge_iterator( m_edges.begin(), m_edges.end(), m_edges.end(),
                        typename neighbours_list::const_iterator() );
} // graph::edge_end()

/*---------------------------------------------------------------------------*/
/**
 * \brief Get en iterator on a particular edge .
 * \remark Returns edge_end() if edge (s1,s2) is not found.
 */
template <class S, class A, class Comp>
typename claw::graph<S, A, Comp>::edge_iterator
claw::graph<S, A, Comp>::edge_begin
( const vertex_type& s1, const vertex_type& s2 ) const
{
  if ( edge_exists(s1, s2) )
    {
      typename graph_content::const_iterator it_s1;

      it_s1 = m_edges.find(s1);
      return edge_iterator( m_edges.begin(), m_edges.end(), it_s1, 
                            it_s1->second.find(s2) );
    }
  else
    return edge_end();
} // graph::edge_()

/*---------------------------------------------------------------------------*/
/**
 * \brief Get a reverse edge iterator on the first edge.
 * \remark Returns redge_end() if there's no edge in the graph.
 */
template <class S, class A, class Comp>
typename claw::graph<S, A, Comp>::reverse_edge_iterator
claw::graph<S, A, Comp>::edge_rbegin() const
{
  return reverse_edge_iterator( edge_end() );
} // graph::edge_rbegin()

/*---------------------------------------------------------------------------*/
/**
 * \brief Get a reverse edge iterator after the last edge.
 */
template <class S, class A, class Comp>
typename claw::graph<S, A, Comp>::reverse_edge_iterator 
claw::graph<S, A, Comp>::edge_rend() const
{
  return reverse_edge_iterator( edge_begin() );
} // graph::edge_rend()

/*---------------------------------------------------------------------------*/
/**
 * \brief Get a reverse edge iterator on a particular edge.
 * \remark Returns redge_end() if edge (s1,s2) is not found.
 */
template <class S, class A, class Comp>
typename claw::graph<S, A, Comp>::reverse_edge_iterator 
claw::graph<S, A, Comp>::edge_rbegin
( const vertex_type& s1, const vertex_type& s2 ) const
{
  reverse_edge_iterator it = edge_begin(s1, s2);

  if ( it != edge_end() )
    ++it;

  return reverse_edge_iterator( it );
} // graph::edge_rbegin()

/*---------------------------------------------------------------------------*/
/**
 * \brief Get the label of an edge.
 * \param s The vertex at the tail of the edge.
 * \param r The vertex at the head of the edge.
 */
template <class S, class A, class Comp>
const typename claw::graph<S, A, Comp>::edge_type& 
claw::graph<S, A, Comp>::label
( const vertex_type& s, const vertex_type& r ) const 
{ 
  typename graph_content::const_iterator it_s = m_edges.find(s);

  if ( it_s == m_edges.end() )
    throw graph_exception
      ("claw::graph::label(): unkonwn source vertex.");
  else 
    {
      typename neighbours_list::const_iterator it_r = it_s->second.find(r);

      if ( it_r == it_s->second.end() )
        throw graph_exception
          ("claw::graph::label(): destination is not a neighbor.");
      else
        return it_r->second; 
    }
} // graph::label()

/*---------------------------------------------------------------------------*/
/**
 * \brief Get the outter degree of a vertex.
 * \param s The vertex.
 */
template <class S, class A, class Comp>
std::size_t claw::graph<S, A, Comp>::outer_degree( const vertex_type& s ) const 
{ 
  typename graph_content::const_iterator it = m_edges.find(s);
  
  if (it == m_edges.end())
    throw graph_exception("claw::graph::outer_degree(): unknown vertex.");
  else
    return it->second.size(); 
} // graph::outer_degree()

/*---------------------------------------------------------------------------*/
/**
 * \brief Get the inner degree of a vertex.
 * \param s The vertex
 */
template <class S, class A, class Comp>
std::size_t claw::graph<S, A, Comp>::inner_degree( const vertex_type& s ) const 
{ 
  typename std::map<S, std::size_t, Comp>::const_iterator it;
  it = m_inner_degrees.find(s);
  
  if (it == m_inner_degrees.end())
    throw graph_exception
      ("claw::graph::inner_degree(): unkown vertex.");
  else
    return it->second; 
} // graph::inner_degree()

/*---------------------------------------------------------------------------*/
/**
 * \brief Get the number of vertices. 
 */
template <class S, class A, class Comp>
std::size_t claw::graph<S, A, Comp>::vertices_count() const 
{
  return m_edges.size(); 
} // graph::vertices_count()

/*---------------------------------------------------------------------------*/
/**
 * \brief Get the number of edges. 
 */
template <class S, class A, class Comp>
std::size_t claw::graph<S, A, Comp>::edges_count() const 
{
  return m_edges_count; 
} // graph::edges_count()