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
|
// ===========================================================================
// SGIP - Solution of Graph Isomorphism Problem
// ===========================================================================
// Copyright (C) 2012 by Jialu Hu
//
// This program 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 3 of the License, or (at your options) any later version.
//
// This program 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 General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// ===========================================================================
// Author: Jialu Hu <Jialu.Hu@fu-berlin.de>
// ===========================================================================
#ifndef APPS_SGIP_SGIP_OUTPUT_H_
#define APPS_SGIP_SGIP_OUTPUT_H_
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <seqan/basic.h>
#include <seqan/sequence.h>
// ============================================================================
// Forward
// ============================================================================
// ============================================================================
// Tags, Classes, Enums
// ============================================================================
struct Matrix_;
typedef seqan::Tag<Matrix_> GMatrix;
struct General_;
typedef seqan::Tag<General_> General;
struct GeneralMap_;
typedef seqan::Tag<GeneralMap_> GeneralMap;
struct DegreeMap_;
typedef seqan::Tag<DegreeMap_> DegreeMap;
struct ParityMap_;
typedef seqan::Tag<ParityMap_> ParityMap;
struct CheckMap_;
typedef seqan::Tag<CheckMap_> CheckMap;
struct FFFF_;
typedef seqan::Tag<FFFF_> FFFF;
// ============================================================================
// Function
// ============================================================================
// --------------------------------------------------------------------------
// Function outputLabel()
// --------------------------------------------------------------------------
template <typename TStr, typename TSpec>
void outputLabel(TStr &, seqan::Tag<TSpec>);
// Function outputLabel for String.
template <typename TStr>
void outputLabel(TStr & str, General const &)
{
using namespace seqan;
typedef typename Iterator<TStr>::Type TIterator;
TIterator it = begin(str,Standard());
TIterator itEnd = end(str,Standard());
std::cout << "String: ";
while (it != itEnd)
{
std::cout << getValue(it) << " ";
goNext(it);
}
std::cout << std::endl;
std::cout << "length: " << length(str) << std::endl;
}
template <typename TValue, typename TSpec, typename TTag>
void outputLabel(seqan::String<TValue, TSpec> &, TTag const &){}
template <typename TValue, typename TSpec>
void outputLabel(seqan::String<TValue, TSpec> & mat, General const &)
{
using namespace seqan;
typedef typename Iterator<seqan::String<TValue, TSpec> >::Type TIterator;
TIterator it = begin(mat);
std::cout << "String: ";
while (!atEnd(it))
{
std::cout << getValue(it) << " ";
goNext(it);
}
std::cout << std::endl;
std::cout << "length: " << length(mat) << std::endl;
}
template <typename TValue, typename TSpec>
void outputLabel(seqan::String<TValue, TSpec> & mat, size_t n)
{
size_t i, j;
for (i = 0; i < n; i++)
{
for (j = i + 1; j < n; j++)
{
if (mat[i + j * n])
std::cout << j << " " << i << std::endl;
if (mat[j + i * n])
std::cout << i << " " << j << std::endl;
}
}
}
template <typename TValue, typename TSpec>
void outputLabel(seqan::String<TValue, TSpec> & mat, FFFF const &)
{
size_t i = 0, j;
size_t len = length(mat);
while (i < len)
{
unsigned num = 0;
for (j = 0; j < 16; j++, i++)
{
if (i < len)
{
if (mat[i])
num = num * 2 + 1;
else
num = num * 2;
}
else
{
break;
}
}
std::cout << std::setbase(16) << num << " ";
}
std::cout << std::setbase(10) << std::endl;
}
// Function outputLabel for StringSet.
template <typename TString>
void outputLabel(seqan::StringSet<TString> & mat, General const &)
{
using namespace seqan;
typedef typename Iterator<StringSet<TString>, Rooted>::Type TIterator;
typedef typename Iterator<TString, Rooted>::Type TStrIterator;
TIterator it = begin(mat);
while (!atEnd(it))
{
TStrIterator ti = begin(value(it));
while (!atEnd(ti))
{
std::cout << getValue(ti) << " ";
goNext(ti);
}
std::cout << std::endl;
goNext(it);
}
}
template <typename TString>
void outputLabel(seqan::StringSet<TString> & mat, size_t n)
{
size_t i, j;
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
std::cout << mat[i][j] << " ";
std::cout << std::endl;
}
}
// --------------------------------------------------------------------------
// Function outputMap()
// --------------------------------------------------------------------------
// Output map structure type.
template <typename TMap>
void outputMap(TMap & map, GeneralMap const &)
{
typedef typename TMap::iterator TIterator;
TIterator it = map.begin();
TIterator itEnd = map.end();
for (; it < itEnd; it++)
std::cout << it->first << " " << it->second << std::endl;
}
template <typename TKey, typename TValue>
void outputMap(std::unordered_map<TKey, TValue> & map, ParityMap const &)
{
using namespace seqan;
typedef typename std::unordered_map<TKey, TValue>::iterator TIterator;
typedef typename Iterator<TValue, Rooted>::Type TStrIterator;
TIterator it = map.begin();
TIterator itEnd = map.end();
for (; it != itEnd; it++)
{
std::cout << it->first << " ";
TValue str = it->second;
TStrIterator ip = begin(str);
TStrIterator ipEnd = end(str);
while (ip != ipEnd)
{
std::cout << getValue(ip) << " ";
goNext(ip);
}
std::cout << std::endl;
}
}
template <typename TKey, typename TValue>
void outputMap(std::unordered_map<TKey, TValue> & map, CheckMap const &)
{
using namespace seqan;
typedef typename std::unordered_map<TKey, TValue>::iterator TIterator;
//typedef typename Iterator<TValue, Rooted>::Type TStrIterator;
TIterator it = map.begin();
TIterator itEnd = map.end();
for (; it != itEnd; it++)
std::cout << it->second << " ";
std::cout << std::endl;
}
template <typename TKey, typename TValue>
void outputMap(std::unordered_map<TKey, TValue> & map, DegreeMap const &)
{
using namespace seqan;
typedef typename std::unordered_map<TKey, TValue>::iterator TIterator;
//typedef typename Iterator<TValue, Rooted>::Type TStrIterator;
TIterator it = map.begin();
TIterator itEnd = map.end();
for (; it != itEnd; it++)
std::cout << it->first << " " << it->second.inDegree << " " << it->second.outDegree << std::endl;
std::cout << std::endl;
}
template <typename TKey, typename TValue, typename TComp>
void outputMap(std::multimap<TKey, TValue, TComp> & degreemap, DegreeMap const &)
{
typedef typename std::multimap<TKey, TValue, TComp>::iterator TIterator;
TIterator it = degreemap.begin();
TIterator itEnd = degreemap.end();
for (; it != itEnd; it++)
std::cout << it->second << " " << it->first.inDegree << " " << it->first.outDegree << std::endl;
}
#endif // #ifndef APPS_SGIP_SGIP_OUTPUT_H_
|