gravatar
alpar (Alpar Juttner)
alpar@cs.elte.hu
Merge
0 2 0
merge default
0 files changed with 16 insertions and 16 deletions:
↑ Collapse diff ↑
Ignore white space 6 line context
... ...
@@ -371,180 +371,187 @@
371 371
@defgroup approx Approximation Algorithms
372 372
@ingroup algs
373 373
\brief Approximation algorithms.
374 374

	
375 375
This group describes the approximation and heuristic algorithms
376 376
implemented in LEMON.
377 377
*/
378 378

	
379 379
/**
380 380
@defgroup gen_opt_group General Optimization Tools
381 381
\brief This group describes some general optimization frameworks
382 382
implemented in LEMON.
383 383

	
384 384
This group describes some general optimization frameworks
385 385
implemented in LEMON.
386 386
*/
387 387

	
388 388
/**
389 389
@defgroup lp_group Lp and Mip Solvers
390 390
@ingroup gen_opt_group
391 391
\brief Lp and Mip solver interfaces for LEMON.
392 392

	
393 393
This group describes Lp and Mip solver interfaces for LEMON. The
394 394
various LP solvers could be used in the same manner with this
395 395
interface.
396 396
*/
397 397

	
398 398
/**
399 399
@defgroup lp_utils Tools for Lp and Mip Solvers
400 400
@ingroup lp_group
401 401
\brief Helper tools to the Lp and Mip solvers.
402 402

	
403 403
This group adds some helper tools to general optimization framework
404 404
implemented in LEMON.
405 405
*/
406 406

	
407 407
/**
408 408
@defgroup metah Metaheuristics
409 409
@ingroup gen_opt_group
410 410
\brief Metaheuristics for LEMON library.
411 411

	
412 412
This group describes some metaheuristic optimization tools.
413 413
*/
414 414

	
415 415
/**
416 416
@defgroup utils Tools and Utilities
417 417
\brief Tools and utilities for programming in LEMON
418 418

	
419 419
Tools and utilities for programming in LEMON.
420 420
*/
421 421

	
422 422
/**
423 423
@defgroup gutils Basic Graph Utilities
424 424
@ingroup utils
425 425
\brief Simple basic graph utilities.
426 426

	
427 427
This group describes some simple basic graph utilities.
428 428
*/
429 429

	
430 430
/**
431 431
@defgroup misc Miscellaneous Tools
432 432
@ingroup utils
433 433
\brief Tools for development, debugging and testing.
434 434

	
435 435
This group describes several useful tools for development,
436 436
debugging and testing.
437 437
*/
438 438

	
439 439
/**
440 440
@defgroup timecount Time Measuring and Counting
441 441
@ingroup misc
442 442
\brief Simple tools for measuring the performance of algorithms.
443 443

	
444 444
This group describes simple tools for measuring the performance
445 445
of algorithms.
446 446
*/
447 447

	
448 448
/**
449 449
@defgroup exceptions Exceptions
450 450
@ingroup utils
451 451
\brief Exceptions defined in LEMON.
452 452

	
453 453
This group describes the exceptions defined in LEMON.
454 454
*/
455 455

	
456 456
/**
457 457
@defgroup io_group Input-Output
458 458
\brief Graph Input-Output methods
459 459

	
460 460
This group describes the tools for importing and exporting graphs
461 461
and graph related data. Now it supports the \ref lgf-format
462 462
"LEMON Graph Format", the \c DIMACS format and the encapsulated
463 463
postscript (EPS) format.
464 464
*/
465 465

	
466 466
/**
467
@defgroup lemon_io LEMON Input-Output
467
@defgroup lemon_io LEMON Graph Format
468 468
@ingroup io_group
469 469
\brief Reading and writing LEMON Graph Format.
470 470

	
471 471
This group describes methods for reading and writing
472 472
\ref lgf-format "LEMON Graph Format".
473 473
*/
474 474

	
475 475
/**
476 476
@defgroup eps_io Postscript Exporting
477 477
@ingroup io_group
478 478
\brief General \c EPS drawer and graph exporter
479 479

	
480 480
This group describes general \c EPS drawing methods and special
481 481
graph exporting tools.
482 482
*/
483 483

	
484 484
/**
485
@defgroup nauty_group NAUTY Format
486
@ingroup io_group
487
\brief Read \e Nauty format
488
Tool to read graphs from \e Nauty format data.
489
*/
490

	
491
/**
485 492
@defgroup concept Concepts
486 493
\brief Skeleton classes and concept checking classes
487 494

	
488 495
This group describes the data/algorithm skeletons and concept checking
489 496
classes implemented in LEMON.
490 497

	
491 498
The purpose of the classes in this group is fourfold.
492 499

	
493 500
- These classes contain the documentations of the %concepts. In order
494 501
  to avoid document multiplications, an implementation of a concept
495 502
  simply refers to the corresponding concept class.
496 503

	
497 504
- These classes declare every functions, <tt>typedef</tt>s etc. an
498 505
  implementation of the %concepts should provide, however completely
499 506
  without implementations and real data structures behind the
500 507
  interface. On the other hand they should provide nothing else. All
501 508
  the algorithms working on a data structure meeting a certain concept
502 509
  should compile with these classes. (Though it will not run properly,
503 510
  of course.) In this way it is easily to check if an algorithm
504 511
  doesn't use any extra feature of a certain implementation.
505 512

	
506 513
- The concept descriptor classes also provide a <em>checker class</em>
507 514
  that makes it possible to check whether a certain implementation of a
508 515
  concept indeed provides all the required features.
509 516

	
510 517
- Finally, They can serve as a skeleton of a new implementation of a concept.
511 518
*/
512 519

	
513 520
/**
514 521
@defgroup graph_concepts Graph Structure Concepts
515 522
@ingroup concept
516 523
\brief Skeleton and concept checking classes for graph structures
517 524

	
518 525
This group describes the skeletons and concept checking classes of LEMON's
519 526
graph structures and helper classes used to implement these.
520 527
*/
521 528

	
522 529
/**
523 530
@defgroup map_concepts Map Concepts
524 531
@ingroup concept
525 532
\brief Skeleton and concept checking classes for maps
526 533

	
527 534
This group describes the skeletons and concept checking classes of maps.
528 535
*/
529 536

	
530 537
/**
531 538
\anchor demoprograms
532 539

	
533 540
@defgroup demos Demo programs
534 541

	
535 542
Some demo programs are listed here. Their full source codes can be found in
536 543
the \c demo subdirectory of the source tree.
537 544

	
538 545
It order to compile them, use <tt>--enable-demo</tt> configure option when
539 546
build the library.
540 547
*/
541 548

	
542 549
/**
543 550
@defgroup tools Standalone utility applications
544 551

	
545 552
Some utility applications are listed here.
546 553

	
547 554
The standard compilation procedure (<tt>./configure;make</tt>) will compile
548 555
them, as well.
549 556
*/
550 557

	
Ignore white space 192 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5 5
 * Copyright (C) 2003-2008
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
#ifndef LEMON_NAUTY_READER_H
20 20
#define LEMON_NAUTY_READER_H
21 21

	
22 22
#include <vector>
23 23
#include <iostream>
24 24
#include <string>
25 25

	
26
/// \ingroup io_group
27
///
28
/// @defgroup nauty_group NAUTY format
29
///
30
/// \brief Read \e Nauty format
31
///
32
/// Tool to read graphs from \e Nauty format data
33

	
34 26
/// \ingroup nauty_group
35 27
/// \file
36 28
/// \brief Nauty file reader.
29

	
37 30
namespace lemon {
38 31

	
39 32
  /// \ingroup nauty_group
40 33
  ///
41 34
  /// \brief Nauty file reader
42 35
  ///
43 36
  /// The \e geng program is in the \e gtools suite of the nauty
44 37
  /// package. This tool can generate all non-isomorphic undirected
45
  /// graphs with given node number from several classes (for example,
38
  /// graphs of several classes with given node number (e.g.
46 39
  /// general, connected, biconnected, triangle-free, 4-cycle-free,
47 40
  /// bipartite and graphs with given edge number and degree
48
  /// constraints). This function reads a \e nauty \e graph6 \e format
41
  /// constraints). This function reads a \e nauty \e graph \e format
49 42
  /// line from the given stream and builds it in the given graph.
50 43
  ///
51 44
  /// The site of nauty package: http://cs.anu.edu.au/~bdm/nauty/
52 45
  ///
53
  /// For example, the number of all non-isomorphic connected graphs
54
  /// can be computed with following code.
46
  /// For example, the number of all non-isomorphic planar graphs
47
  /// can be computed with the following code.
55 48
  ///\code
56 49
  /// int num = 0;
57 50
  /// SmartGraph graph;
58 51
  /// while (readNauty(graph, std::cin)) {
59 52
  ///   PlanarityChecking<SmartGraph> pc(graph);
60 53
  ///   if (pc.run()) ++num;
61 54
  /// }
62 55
  /// std::cout << "Number of planar graphs: " << num << std::endl;
63 56
  ///\endcode
64 57
  ///
65 58
  /// The nauty files are quite huge, therefore instead of the direct
66
  /// file generation the pipelining is recommended.
59
  /// file generation pipelining is recommended. For example,
67 60
  ///\code
68
  /// ./geng -c 10 | ./num_of_pg
61
  /// ./geng -c 10 | ./num_of_planar_graphs
69 62
  ///\endcode
70 63
  template <typename Graph>
71
  std::istream& readNauty(Graph& graph, std::istream& is) {
64
  std::istream& readNauty(Graph& graph, std::istream& is = std::cin) {
72 65
    graph.clear();
73 66

	
74 67
    std::string line;
75 68
    if (getline(is, line)) {
76 69
      int index = 0;
77 70

	
78 71
      int n;
79 72

	
80 73
      if (line[index] == '>') {
81 74
        index += 10;
82 75
      }
83 76

	
84 77
      char c = line[index++]; c -= 63;
85 78
      if (c != 63) {
86 79
        n = int(c);
87 80
      } else {
88 81
        c = line[index++]; c -= 63;
89 82
        n = (int(c) << 12);
90 83
        c = line[index++]; c -= 63;
91 84
        n |= (int(c) << 6);
92 85
        c = line[index++]; c -= 63;
93 86
        n |= int(c);
94 87
      }
95 88

	
96 89
      std::vector<typename Graph::Node> nodes;
97 90
      for (int i = 0; i < n; ++i) {
98 91
        nodes.push_back(graph.addNode());
99 92
      }
100 93

	
101 94
      int bit = -1;
102 95
      for (int j = 0; j < n; ++j) {
103 96
        for (int i = 0; i < j; ++i) {
104 97
          if (bit == -1) {
105 98
            c = line[index++]; c -= 63;
106 99
            bit = 5;
107 100
          }
108 101
          bool b = (c & (1 << (bit--))) != 0;
109 102

	
110 103
          if (b) {
111 104
            graph.addEdge(nodes[i], nodes[j]);
112 105
          }
113 106
        }
114 107
      }
115 108
    }
116 109
    return is;
117 110
  }
118 111
}
119 112

	
120 113
#endif
0 comments (0 inline)