File: DistIO.h

package info (click to toggle)
abyss 2.3.5%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 14,476 kB
  • sloc: cpp: 169,166; ansic: 6,828; java: 2,239; makefile: 2,229; sh: 1,159; perl: 672; haskell: 412; python: 72
file content (42 lines) | stat: -rw-r--r-- 1,108 bytes parent folder | download | duplicates (8)
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
#ifndef DISTIO_H
#define DISTIO_H 1

#include <boost/graph/graph_traits.hpp>
#include <cassert>
#include <ostream>

using boost::graph_traits;

/** Output a distance estimate graph. */
template <typename Graph>
std::ostream& write_dist(std::ostream& out, const Graph& g)
{
	typedef typename graph_traits<Graph>::vertex_descriptor V;
	typedef typename graph_traits<Graph>::vertex_iterator Vit;
	typedef typename graph_traits<Graph>::out_edge_iterator Eit;

	std::pair<Vit, Vit> urange = vertices(g);
	for (Vit uit = urange.first; uit != urange.second; ++uit) {
		V u = *uit;
 		if (get(vertex_removed, g, u)
				|| out_degree(u, g) + in_degree(u, g) == 0)
			continue;
		bool sense = get(vertex_sense, g, u);
		if (!sense)
			out << get(vertex_contig_name, g, u);
		else
			out << " ;";
		std::pair<Eit, Eit> erange = out_edges(u, g);
		for (Eit eit = erange.first; eit != erange.second; ++eit) {
			V v = target(*eit, g) ^ sense;
			assert(!get(vertex_removed, g, v));
			out << ' ' << get(vertex_name, g, v)
				<< ',' << get(edge_bundle, g, eit);
		}
		if (sense)
			out << '\n';
	}
	return out;
}

#endif