Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

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