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>
35
36#include <algorithm>
37#include <cctype>
38#include <iostream>
39#include <map>
40#include <string>
41#include <vector>
42
43namespace ogdf {
44class GraphAttributes;
45
46class DLParser {
47private:
48 std::istream& m_istream;
50
54
55 std::vector<node> m_nodeId; // For constant-time index to node mapping.
56 std::map<std::string, node> m_nodeLabel; // For embedded label mode.
57
58 static inline void toUpper(std::string& str) {
59 std::transform(str.begin(), str.end(), str.begin(), toupper);
60 }
61
62 static inline void toLower(std::string& str) {
63 std::transform(str.begin(), str.end(), str.begin(), tolower);
64 }
65
66 inline bool fineId(int vid) { return 0 < vid && vid <= static_cast<int>(m_nodeId.size()); }
67
68 inline node requestLabel(GraphAttributes* GA, node& nextFree, const std::string& label);
69
70 void init();
71 bool initGraph(Graph& G);
72
79
80 bool readAssignment(Graph& G, const std::string& lhs, const std::string& rhs);
81
86
87public:
88 explicit DLParser(std::istream& is);
89
90 bool read(Graph& G) { return readGraph(G, nullptr); }
91
92 bool read(Graph& G, GraphAttributes& GA) { return readGraph(G, &GA); }
93};
94
95}
Includes declaration of graph class.
bool readData(Graph &G, GraphAttributes *GA)
bool readWithLabels(Graph &G, GraphAttributes *GA)
std::map< std::string, node > m_nodeLabel
Definition DLParser.h:56
bool readGraph(Graph &G, GraphAttributes *GA)
bool readEmbeddedNodeList(Graph &G, GraphAttributes *GA)
static void toLower(std::string &str)
Definition DLParser.h:62
DLParser(std::istream &is)
std::vector< node > m_nodeId
Definition DLParser.h:55
bool m_embedded
Definition DLParser.h:53
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:66
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:90
bool readNodeList(Graph &G)
bool readEmbeddedEdgeList(Graph &G, GraphAttributes *GA)
std::istream & m_istream
Definition DLParser.h:48
bool readAssignment(Graph &G, const std::string &lhs, const std::string &rhs)
bool m_initialized
Definition DLParser.h:49
bool read(Graph &G, GraphAttributes &GA)
Definition DLParser.h:92
static void toUpper(std::string &str)
Definition DLParser.h:58
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:866
Class for the representation of nodes.
Definition Graph_d.h:241
The namespace for all OGDF objects.