Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
DLParser.h
Go to the documentation of this file.
1
32#pragma once
33
34#include <ogdf/basic/Graph.h>
36
37#include <algorithm>
38#include <iostream>
39#include <map>
40#include <sstream>
41#include <string>
42#include <vector>
43
44namespace ogdf {
45
46
47class DLParser {
48private:
49 std::istream& m_istream;
51
55
56 std::vector<node> m_nodeId; // For constant-time index to node mapping.
57 std::map<std::string, node> m_nodeLabel; // For embedded label mode.
58
59 static inline void toUpper(std::string& str) {
60 std::transform(str.begin(), str.end(), str.begin(), toupper);
61 }
62
63 static inline void toLower(std::string& str) {
64 std::transform(str.begin(), str.end(), str.begin(), tolower);
65 }
66
67 inline bool fineId(int vid) { return 0 < vid && vid <= static_cast<int>(m_nodeId.size()); }
68
69 inline node requestLabel(GraphAttributes* GA, node& nextFree, const std::string& label);
70
71 void init();
72 bool initGraph(Graph& G);
73
80
81 bool readAssignment(Graph& G, const std::string& lhs, const std::string& rhs);
82
87
88public:
89 explicit DLParser(std::istream& is);
90
91 bool read(Graph& G) { return readGraph(G, nullptr); }
92
93 bool read(Graph& G, GraphAttributes& GA) { return readGraph(G, &GA); }
94};
95
96}
Includes declaration of graph class.
Declaration of class GraphAttributes which extends a Graph by additional attributes.
bool readData(Graph &G, GraphAttributes *GA)
bool readWithLabels(Graph &G, GraphAttributes *GA)
std::map< std::string, node > m_nodeLabel
Definition DLParser.h:57
bool readGraph(Graph &G, GraphAttributes *GA)
bool readEmbeddedNodeList(Graph &G, GraphAttributes *GA)
static void toLower(std::string &str)
Definition DLParser.h:63
DLParser(std::istream &is)
std::vector< node > m_nodeId
Definition DLParser.h:56
bool m_embedded
Definition DLParser.h:54
enum ogdf::DLParser::Format m_format
bool initGraph(Graph &G)
node requestLabel(GraphAttributes *GA, node &nextFree, const std::string &label)
bool fineId(int vid)
Definition DLParser.h:67
bool readMatrix(Graph &G, GraphAttributes *GA)
bool readStatements(Graph &G, GraphAttributes *GA)
bool readEdgeList(Graph &G, GraphAttributes *GA)
bool read(Graph &G)
Definition DLParser.h:91
bool readNodeList(Graph &G)
bool readEmbeddedEdgeList(Graph &G, GraphAttributes *GA)
std::istream & m_istream
Definition DLParser.h:49
bool readAssignment(Graph &G, const std::string &lhs, const std::string &rhs)
bool m_initialized
Definition DLParser.h:50
bool read(Graph &G, GraphAttributes &GA)
Definition DLParser.h:93
static void toUpper(std::string &str)
Definition DLParser.h:59
bool readEmbeddedMatrix(Graph &G, GraphAttributes *GA)
Stores additional attributes of a graph (like layout information).
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:521
Class for the representation of nodes.
Definition Graph_d.h:177
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.