Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

GdfParser.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <ogdf/basic/Graph.h>
35 #include <ogdf/basic/HashArray.h>
36 
37 #include <cstddef>
38 #include <istream>
39 #include <string>
40 #include <vector>
41 
42 namespace ogdf::gdf {
43 enum class EdgeAttribute;
44 enum class NodeAttribute;
45 } // namespace ogdf::gdf
46 
47 namespace ogdf {
48 class GraphAttributes;
49 
50 namespace gdf {
51 
52 
53 class Parser {
54 private:
55  std::istream& m_istream;
57  std::vector<NodeAttribute> m_nodeAttrs;
58  std::vector<EdgeAttribute> m_edgeAttrs;
59 
60  bool readAttributes(GraphAttributes& GA, node v, const std::vector<std::string>& values);
61  bool readAttributes(GraphAttributes& GA, edge e, const std::vector<std::string>& values);
62 
63  bool readNodeDef(const std::string& str);
64  bool readEdgeDef(const std::string& str);
65 
66  bool readNodeStmt(Graph& G, GraphAttributes* GA, const std::string& str, size_t line);
67  bool readEdgeStmt(Graph& G, GraphAttributes* GA, const std::string& str, size_t line);
68 
69  bool readGraph(Graph& G, GraphAttributes* GA);
70 
71 public:
72  explicit Parser(std::istream& is);
73 
74  bool read(Graph& G) { return readGraph(G, nullptr); }
75 
76  bool read(Graph& G, GraphAttributes& GA) { return readGraph(G, &GA); }
77 };
78 
79 }
80 }
HashArray.h
Declaration and implementation of HashArray class.
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::GraphAttributes
Stores additional attributes of a graph (like layout information).
Definition: GraphAttributes.h:72
Graph.h
Includes declaration of graph class.
ogdf::gdf::Parser::readAttributes
bool readAttributes(GraphAttributes &GA, node v, const std::vector< std::string > &values)
ogdf::gdf::Parser::readGraph
bool readGraph(Graph &G, GraphAttributes *GA)
ogdf::gdf::Parser::readEdgeStmt
bool readEdgeStmt(Graph &G, GraphAttributes *GA, const std::string &str, size_t line)
ogdf::gdf::Parser::m_nodeId
HashArray< std::string, node > m_nodeId
Definition: GdfParser.h:56
ogdf::gdf::Parser::m_edgeAttrs
std::vector< EdgeAttribute > m_edgeAttrs
Definition: GdfParser.h:58
ogdf::gdf::Parser::m_istream
std::istream & m_istream
Definition: GdfParser.h:55
ogdf::HashArray
Indexed arrays using hashing for element access.
Definition: HashArray.h:93
ogdf::gdf::NodeAttribute
NodeAttribute
Definition: GDF.h:43
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:869
ogdf::gdf::Parser::m_nodeAttrs
std::vector< NodeAttribute > m_nodeAttrs
Definition: GdfParser.h:57
ogdf::gdf::Parser::Parser
Parser(std::istream &is)
ogdf::gdf::Parser::read
bool read(Graph &G, GraphAttributes &GA)
Definition: GdfParser.h:76
ogdf::gdf::EdgeAttribute
EdgeAttribute
Definition: GDF.h:67
ogdf::gdf::Parser::readNodeDef
bool readNodeDef(const std::string &str)
ogdf::gdf::Parser::readEdgeDef
bool readEdgeDef(const std::string &str)
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:363
ogdf::gdf::Parser::read
bool read(Graph &G)
Definition: GdfParser.h:74
ogdf::gdf::Parser
Definition: GdfParser.h:53
ogdf::gdf
Definition: GDF.h:40
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
ogdf::gdf::Parser::readNodeStmt
bool readNodeStmt(Graph &G, GraphAttributes *GA, const std::string &str, size_t line)