gravatar
alpar (Alpar Juttner)
alpar@cs.elte.hu
Merge
0 2 0
merge default
0 files changed with 4 insertions and 3 deletions:
↑ Collapse diff ↑
Ignore white space 6 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 26
/// \ingroup nauty_group
27 27
/// \file
28 28
/// \brief Nauty file reader.
29 29

	
30 30
namespace lemon {
31 31

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

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

	
71 71
      int n;
72 72

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

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

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

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

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

	
Ignore white space 96 line context
... ...
@@ -45,51 +45,52 @@
45 45
        -e "s/Edge/_Ar_c_label_/g"\
46 46
        -e "s/edge/_ar_c_label_/g"\
47 47
        -e "s/A[Nn]ode/_Re_d_label_/g"\
48 48
        -e "s/B[Nn]ode/_Blu_e_label_/g"\
49 49
        -e "s/A-[Nn]ode/_Re_d_label_/g"\
50 50
        -e "s/B-[Nn]ode/_Blu_e_label_/g"\
51 51
        -e "s/a[Nn]ode/_re_d_label_/g"\
52 52
        -e "s/b[Nn]ode/_blu_e_label_/g"\
53 53
        -e "s/\<UGRAPH_TYPEDEFS\([ \t]*([ \t]*\)typename[ \t]/TEMPLATE__GR_APH_TY_PEDE_FS_label_\1/g"\
54 54
        -e "s/\<GRAPH_TYPEDEFS\([ \t]*([ \t]*\)typename[ \t]/TEMPLATE__DIGR_APH_TY_PEDE_FS_label_\1/g"\
55 55
        -e "s/\<UGRAPH_TYPEDEFS\>/_GR_APH_TY_PEDE_FS_label_/g"\
56 56
        -e "s/\<GRAPH_TYPEDEFS\>/_DIGR_APH_TY_PEDE_FS_label_/g"\
57 57
        -e "s/_Digr_aph_label_/Digraph/g"\
58 58
        -e "s/_digr_aph_label_/digraph/g"\
59 59
        -e "s/_Gr_aph_label_/Graph/g"\
60 60
        -e "s/_gr_aph_label_/graph/g"\
61 61
        -e "s/_Ar_c_label_/Arc/g"\
62 62
        -e "s/_ar_c_label_/arc/g"\
63 63
        -e "s/_Ed_ge_label_/Edge/g"\
64 64
        -e "s/_ed_ge_label_/edge/g"\
65 65
        -e "s/_In_cEd_geIt_label_/IncEdgeIt/g"\
66 66
        -e "s/_Re_d_label_/Red/g"\
67 67
        -e "s/_Blu_e_label_/Blue/g"\
68 68
        -e "s/_re_d_label_/red/g"\
69 69
        -e "s/_blu_e_label_/blue/g"\
70 70
        -e "s/_GR_APH_TY_PEDE_FS_label_/GRAPH_TYPEDEFS/g"\
71 71
        -e "s/_DIGR_APH_TY_PEDE_FS_label_/DIGRAPH_TYPEDEFS/g"\
72 72
        -e "s/DigraphToEps/GraphToEps/g"\
73 73
        -e "s/digraphToEps/graphToEps/g"\
74 74
        -e "s/\<DefPredMap\>/SetPredMap/g"\
75 75
        -e "s/\<DefDistMap\>/SetDistMap/g"\
76 76
        -e "s/\<DefReachedMap\>/SetReachedMap/g"\
77 77
        -e "s/\<DefProcessedMap\>/SetProcessedMap/g"\
78 78
        -e "s/\<DefHeap\>/SetHeap/g"\
79 79
        -e "s/\<DefStandardHeap\>/SetStandradHeap/g"\
80 80
        -e "s/\<DefOperationTraits\>/SetOperationTraits/g"\
81 81
        -e "s/\<DefProcessedMapToBeDefaultMap\>/SetStandardProcessedMap/g"\
82 82
        -e "s/\<copyGraph\>/graphCopy/g"\
83 83
        -e "s/\<copyDigraph\>/digraphCopy/g"\
84 84
        -e "s/\<IntegerMap\>/RangeMap/g"\
85 85
        -e "s/\<integerMap\>/rangeMap/g"\
86 86
        -e "s/\<\([sS]\)tdMap\>/\1parseMap/g"\
87 87
        -e "s/\<\([Ff]\)unctorMap\>/\1unctorToMap/g"\
88 88
        -e "s/\<\([Mm]\)apFunctor\>/\1apToFunctor/g"\
89 89
        -e "s/\<\([Ff]\)orkWriteMap\>/\1orkMap/g"\
90 90
        -e "s/\<StoreBoolMap\>/LoggerBoolMap/g"\
91 91
        -e "s/\<storeBoolMap\>/loggerBoolMap/g"\
92 92
        -e "s/\<BoundingBox\>/Box/g"\
93
        -e "s/\<readNauty\>/readNautyGraph/g"\
93 94
    <$i > $TMP
94 95
    mv $TMP $i
95 96
done
0 comments (0 inline)