Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

GraphMLParser.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <ogdf/basic/HashArray.h>
36 
38 
39 #include <sstream>
40 #include <unordered_map>
41 
42 namespace ogdf {
43 
45 private:
47  pugi::xml_node m_graphTag; // "Almost root" tag.
48 
49  // Maps GraphML node id to Graph node.
50  std::unordered_map<string, node> m_nodeId;
51 
52  // Maps attribute id to its name.
53  std::unordered_map<string, string> m_attrName;
54 
55  bool readData(GraphAttributes& GA, const node& v, const pugi::xml_node nodeData);
56  bool readData(GraphAttributes& GA, const edge& e, const pugi::xml_node edgeData);
57  bool readData(ClusterGraphAttributes& CA, const cluster& c, const pugi::xml_node clusterData);
58 
59  // Finds all data-keys for given element and calls appropiate "readData".
60  template<typename A, typename T>
61  bool readAttributes(A& GA, const T& elem, const pugi::xml_node xmlElem) {
62  for (pugi::xml_node dataTag : xmlElem.children("data")) {
63  const bool result = readData(GA, elem, dataTag);
64  if (!result) {
65  return false;
66  }
67  }
68 
69  return true;
70  }
71 
72  bool readNodes(Graph& G, GraphAttributes* GA, const pugi::xml_node rootTag);
73  bool readEdges(Graph& G, GraphAttributes* GA, const pugi::xml_node rootTag);
75  const cluster& rootCluster, const pugi::xml_node clusterRoot);
76 
77  bool m_error;
78 
79 public:
80  explicit GraphMLParser(std::istream& in);
82 
83  bool read(Graph& G);
84  bool read(Graph& G, GraphAttributes& GA);
85  bool read(Graph& G, ClusterGraph& C);
87 };
88 
89 }
HashArray.h
Declaration and implementation of HashArray class.
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
ogdf::GraphMLParser::readAttributes
bool readAttributes(A &GA, const T &elem, const pugi::xml_node xmlElem)
Definition: GraphMLParser.h:61
ogdf::GraphMLParser::readEdges
bool readEdges(Graph &G, GraphAttributes *GA, const pugi::xml_node rootTag)
pugixml.h
pugi::xml_node::children
xml_object_range< xml_node_iterator > children() const
ogdf::GraphMLParser::GraphMLParser
GraphMLParser(std::istream &in)
ogdf::GraphMLParser::readData
bool readData(GraphAttributes &GA, const node &v, const pugi::xml_node nodeData)
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::GraphMLParser::m_xml
pugi::xml_document m_xml
Definition: GraphMLParser.h:46
ogdf::GraphMLParser::m_error
bool m_error
Definition: GraphMLParser.h:77
ogdf::GraphMLParser::~GraphMLParser
~GraphMLParser()
GraphIO.h
Declares class GraphIO which provides access to all graph read and write functionality.
ogdf::GraphMLParser::m_graphTag
pugi::xml_node m_graphTag
Definition: GraphMLParser.h:47
pugi::xml_node
Definition: pugixml.h:401
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:862
ogdf::GraphMLParser::read
bool read(Graph &G)
ogdf::GraphMLParser::m_nodeId
std::unordered_map< string, node > m_nodeId
Definition: GraphMLParser.h:50
ogdf::GraphMLParser::readNodes
bool readNodes(Graph &G, GraphAttributes *GA, const pugi::xml_node rootTag)
ogdf::GraphMLParser::m_attrName
std::unordered_map< string, string > m_attrName
Definition: GraphMLParser.h:53
pugi::xml_document
Definition: pugixml.h:943
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:356
ogdf::GraphMLParser
Definition: GraphMLParser.h:44
ogdf::GraphMLParser::readClusters
bool readClusters(Graph &G, ClusterGraph &C, ClusterGraphAttributes *CA, const cluster &rootCluster, const pugi::xml_node clusterRoot)
ogdf::ClusterGraph
Representation of clustered graphs.
Definition: ClusterGraph.h:339
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:233