Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

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 
43 namespace ogdf {
44 class GraphAttributes;
45 
46 class DLParser {
47 private:
48  std::istream& m_istream;
50 
51  int m_nodes;
53  bool m_embedded;
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 
73  bool readMatrix(Graph& G, GraphAttributes* GA);
74  bool readEdgeList(Graph& G, GraphAttributes* GA);
75  bool readNodeList(Graph& G);
79 
80  bool readAssignment(Graph& G, const std::string& lhs, const std::string& rhs);
81 
82  bool readData(Graph& G, GraphAttributes* GA);
83  bool readWithLabels(Graph& G, GraphAttributes* GA);
84  bool readStatements(Graph& G, GraphAttributes* GA);
85  bool readGraph(Graph& G, GraphAttributes* GA);
86 
87 public:
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 }
ogdf::DLParser::init
void init()
ogdf::DLParser::m_nodes
int m_nodes
Definition: DLParser.h:51
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::DLParser::readEmbeddedMatrix
bool readEmbeddedMatrix(Graph &G, GraphAttributes *GA)
ogdf::GraphAttributes
Stores additional attributes of a graph (like layout information).
Definition: GraphAttributes.h:72
ogdf::DLParser::readEdgeList
bool readEdgeList(Graph &G, GraphAttributes *GA)
Graph.h
Includes declaration of graph class.
ogdf::DLParser::readEmbeddedNodeList
bool readEmbeddedNodeList(Graph &G, GraphAttributes *GA)
ogdf::DLParser::m_istream
std::istream & m_istream
Definition: DLParser.h:48
ogdf::DLParser::m_initialized
bool m_initialized
Definition: DLParser.h:49
ogdf::DLParser::fineId
bool fineId(int vid)
Definition: DLParser.h:66
ogdf::DLParser::m_nodeLabel
std::map< std::string, node > m_nodeLabel
Definition: DLParser.h:56
ogdf::DLParser::readNodeList
bool readNodeList(Graph &G)
ogdf::DLParser::readWithLabels
bool readWithLabels(Graph &G, GraphAttributes *GA)
ogdf::DLParser::Format::EdgeList
@ EdgeList
ogdf::DLParser::readData
bool readData(Graph &G, GraphAttributes *GA)
ogdf::DLParser::m_embedded
bool m_embedded
Definition: DLParser.h:53
ogdf::DLParser::m_format
enum ogdf::DLParser::Format m_format
ogdf::DLParser::readEmbeddedEdgeList
bool readEmbeddedEdgeList(Graph &G, GraphAttributes *GA)
ogdf::DLParser::readAssignment
bool readAssignment(Graph &G, const std::string &lhs, const std::string &rhs)
ogdf::DLParser::initGraph
bool initGraph(Graph &G)
ogdf::DLParser::readMatrix
bool readMatrix(Graph &G, GraphAttributes *GA)
ogdf::DLParser::Format
Format
Definition: DLParser.h:52
ogdf::DLParser::DLParser
DLParser(std::istream &is)
ogdf::DLParser::Format::NodeList
@ NodeList
ogdf::DLParser::readStatements
bool readStatements(Graph &G, GraphAttributes *GA)
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:869
ogdf::DLParser
Definition: DLParser.h:46
ogdf::DLParser::read
bool read(Graph &G)
Definition: DLParser.h:90
ogdf::DLParser::m_nodeId
std::vector< node > m_nodeId
Definition: DLParser.h:55
ogdf::DLParser::requestLabel
node requestLabel(GraphAttributes *GA, node &nextFree, const std::string &label)
ogdf::DLParser::toUpper
static void toUpper(std::string &str)
Definition: DLParser.h:58
ogdf::DLParser::Format::FullMatrix
@ FullMatrix
ogdf::DLParser::readGraph
bool readGraph(Graph &G, GraphAttributes *GA)
ogdf::DLParser::read
bool read(Graph &G, GraphAttributes &GA)
Definition: DLParser.h:92
ogdf::DLParser::toLower
static void toLower(std::string &str)
Definition: DLParser.h:62
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240