Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
DotConverterTreePart.hxx
Go to the documentation of this file.
1
6#pragma once
7
9
11
12namespace convert {
13
15 template < class SymbolType >
16 static unsigned convertRecursive ( const ext::tree < SymbolType > & node, ext::ostream & oss, unsigned & nodeIdCounter );
17
18public:
19 template < class SymbolType >
21};
22
23template < class SymbolType >
25 unsigned nodeIdCounter = 0;
26 convertRecursive ( tree.getContent ( ), oss, nodeIdCounter );
27}
28
29template < class SymbolType >
30unsigned DotConverterTree::convertRecursive ( const ext::tree < SymbolType > & node, ext::ostream & oss, unsigned & nodeIdCounter ) {
31 unsigned id = nodeIdCounter ++;
32
33 oss << id << "[label=\"" + factory::StringDataFactory::toString ( node.getData ( ) ) + "\", shape=plaintext];" << std::endl;
34
35 for ( const ext::tree < SymbolType > & child : node.getChildren ( ) ) {
36 size_t childId = convertRecursive ( child, oss, nodeIdCounter );
37 oss << id << " -> " << childId << ";" << std::endl;
38 }
39
40 return id;
41}
42
43} /* namespace convert */
44
Definition: DotConverterTreePart.hxx:14
static void convertInternal(ext::ostream &oss, const tree::RankedTree< SymbolType > &tree)
Definition: DotConverterTreePart.hxx:24
Definition: ostream.h:14
Class introducing a tree with interface trying to be close to the interface of standard library conta...
Definition: tree.hpp:52
static std::string toString(const T &data)
Definition: StringDataFactory.hpp:89
Tree structure represented in its natural representation. The representation is so called ranked,...
Definition: RankedTree.h:72
Definition: converterCommon.hpp:8
Definition: Node.cpp:11
Definition: BackwardOccurrenceTest.h:17