Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

GexfParser.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <ogdf/basic/Graph.h>
39 
40 #include <unordered_map>
41 #include <memory>
42 #include <sstream>
43 
44 
45 namespace ogdf {
46 
47 namespace gexf {
48 
49 
50 class Parser {
51 private:
52  std::istream &m_is;
53 
56 
57  std::unordered_map<std::string, node> m_nodeId;
58  std::unordered_map<std::string, cluster> m_clusterId;
59 
60  std::unordered_map<std::string, std::string> m_nodeAttr, m_edgeAttr;
61 
62  bool init();
63  bool readNodes(Graph &G, GraphAttributes *GA);
64  bool readEdges(Graph &G, ClusterGraph *C, GraphAttributes *GA);
65  bool readCluster(
67  cluster rootCluster,
68  const pugi::xml_node rootTag);
69  bool readAttributes(
70  GraphAttributes &GA, node v,
71  const pugi::xml_node nodeTag);
72  bool readAttributes(
73  GraphAttributes &GA, edge e,
74  const pugi::xml_node edgeTag);
75 
76  static void error(const pugi::xml_node tag, const std::string &msg);
77 
78 public:
79  explicit Parser(std::istream &is);
80 
81  bool read(Graph &G);
82  bool read(Graph &G, GraphAttributes &GA);
83  bool read(Graph &G, ClusterGraph &C);
85 };
86 
87 }
88 }
pugi::xml_document m_xml
Definition: GexfParser.h:54
Declaration of class GraphAttributes which extends a Graph by additional attributes.
bool readNodes(Graph &G, GraphAttributes *GA)
Derived class of GraphObserver providing additional functionality to handle clustered graphs...
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:492
pugi::xml_node m_nodesTag
Definition: GexfParser.h:55
std::unordered_map< std::string, std::string > m_nodeAttr
Definition: GexfParser.h:60
std::istream & m_is
Definition: GexfParser.h:52
pugi::xml_node m_edgesTag
Definition: GexfParser.h:55
std::unordered_map< std::string, std::string > m_edgeAttr
Definition: GexfParser.h:60
std::unordered_map< std::string, cluster > m_clusterId
Definition: GexfParser.h:58
Representation of clustered graphs.
Definition: ClusterGraph.h:291
pugi::xml_node m_graphTag
Definition: GexfParser.h:55
std::unordered_map< std::string, node > m_nodeId
Definition: GexfParser.h:57
Stores additional attributes of a graph (like layout information).
Class for the representation of edges.
Definition: Graph_d.h:292
Stores additional attributes of a clustered graph (like layout information).
Parser(std::istream &is)
Class for the representation of nodes.
Definition: Graph_d.h:169
bool readEdges(Graph &G, ClusterGraph *C, GraphAttributes *GA)
Declares ClusterGraphAttributes, an extension of class GraphAttributes, to store clustergraph layout ...
Representation of clusters in a clustered graph.
Definition: ClusterGraph.h:53
Includes declaration of graph class.
bool read(Graph &G)
bool readCluster(Graph &G, ClusterGraph &C, ClusterGraphAttributes *CA, cluster rootCluster, const pugi::xml_node rootTag)
The namespace for all OGDF objects.
static void error(const pugi::xml_node tag, const std::string &msg)
bool readAttributes(GraphAttributes &GA, node v, const pugi::xml_node nodeTag)