Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

GexfParser.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <ogdf/basic/Graph.h>
38 
40 
41 #include <memory>
42 #include <sstream>
43 #include <unordered_map>
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(Graph& G, ClusterGraph& C, ClusterGraphAttributes* CA, cluster rootCluster,
66  const pugi::xml_node rootTag);
67  bool readAttributes(GraphAttributes& GA, node v, const pugi::xml_node nodeTag);
68  bool readAttributes(GraphAttributes& GA, edge e, const pugi::xml_node edgeTag);
69 
70  static void error(const pugi::xml_node tag, const std::string& msg);
71 
72 public:
73  explicit Parser(std::istream& is);
74 
75  bool read(Graph& G);
76  bool read(Graph& G, GraphAttributes& GA);
77  bool read(Graph& G, ClusterGraph& C);
79 };
80 
81 }
82 }
ogdf::gexf::Parser::readAttributes
bool readAttributes(GraphAttributes &GA, node v, const pugi::xml_node nodeTag)
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::GraphAttributes
Stores additional attributes of a graph (like layout information).
Definition: GraphAttributes.h:66
GraphAttributes.h
Declaration of class GraphAttributes which extends a Graph by additional attributes.
ogdf::gexf::Parser
Definition: GexfParser.h:50
ogdf::gexf::Parser::init
bool init()
Graph.h
Includes declaration of graph class.
ogdf::gexf::Parser::m_graphTag
pugi::xml_node m_graphTag
Definition: GexfParser.h:55
ogdf::gexf::Parser::read
bool read(Graph &G)
pugixml.h
ogdf::gexf::Parser::m_nodeId
std::unordered_map< std::string, node > m_nodeId
Definition: GexfParser.h:57
ogdf::gexf::Parser::readCluster
bool readCluster(Graph &G, ClusterGraph &C, ClusterGraphAttributes *CA, cluster rootCluster, const pugi::xml_node rootTag)
ogdf::gexf::Parser::m_nodeAttr
std::unordered_map< std::string, std::string > m_nodeAttr
Definition: GexfParser.h:60
ogdf::gexf::Parser::readNodes
bool readNodes(Graph &G, GraphAttributes *GA)
ogdf::ClusterElement
Representation of clusters in a clustered graph.
Definition: ClusterGraph.h:55
ogdf::ClusterGraphAttributes
Stores additional attributes of a clustered graph (like layout information).
Definition: ClusterGraphAttributes.h:46
ogdf::gexf::Parser::m_edgesTag
pugi::xml_node m_edgesTag
Definition: GexfParser.h:55
ogdf::gexf::Parser::m_edgeAttr
std::unordered_map< std::string, std::string > m_edgeAttr
Definition: GexfParser.h:60
pugi::xml_node
Definition: pugixml.h:401
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:862
ogdf::gexf::Parser::m_clusterId
std::unordered_map< std::string, cluster > m_clusterId
Definition: GexfParser.h:58
ogdf::gexf::Parser::readEdges
bool readEdges(Graph &G, ClusterGraph *C, GraphAttributes *GA)
ogdf::gexf::Parser::Parser
Parser(std::istream &is)
ogdf::gexf::Parser::error
static void error(const pugi::xml_node tag, const std::string &msg)
ogdf::gexf::Parser::m_nodesTag
pugi::xml_node m_nodesTag
Definition: GexfParser.h:55
pugi::xml_document
Definition: pugixml.h:943
ClusterGraphAttributes.h
Declares ClusterGraphAttributes, an extension of class GraphAttributes, to store clustergraph layout ...
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:356
ClusterGraph.h
Derived class of GraphObserver providing additional functionality to handle clustered graphs.
ogdf::gexf::Parser::m_is
std::istream & m_is
Definition: GexfParser.h:52
ogdf::gexf::Parser::m_xml
pugi::xml_document m_xml
Definition: GexfParser.h:54
ogdf::ClusterGraph
Representation of clustered graphs.
Definition: ClusterGraph.h:339
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:233