Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
GraphMLParser.h
Go to the documentation of this file.
1
32#pragma once
33
34#include <ogdf/basic/Graph.h>
35#include <ogdf/basic/basic.h>
37
39
40#include <sstream>
41#include <string>
42#include <unordered_map>
43
44namespace ogdf {
45class ClusterGraphAttributes;
46class GraphAttributes;
47
49private:
51 pugi::xml_node m_graphTag; // "Almost root" tag.
52
53 // Maps GraphML node id to Graph node.
54 std::unordered_map<string, node> m_nodeId;
55
56 // Maps attribute id to its name.
57 std::unordered_map<string, string> m_attrName;
58
59 bool readData(GraphAttributes& GA, const node& v, const pugi::xml_node nodeData);
60 bool readData(GraphAttributes& GA, const edge& e, const pugi::xml_node edgeData);
61 bool readData(ClusterGraphAttributes& CA, const cluster& c, const pugi::xml_node clusterData);
62
63 // Finds all data-keys for given element and calls appropiate "readData".
64 template<typename A, typename T>
65 bool readAttributes(A& GA, const T& elem, const pugi::xml_node xmlElem) {
66 for (pugi::xml_node dataTag : xmlElem.children("data")) {
67 const bool result = readData(GA, elem, dataTag);
68 if (!result) {
69 return false;
70 }
71 }
72
73 return true;
74 }
75
76 bool readNodes(Graph& G, GraphAttributes* GA, const pugi::xml_node rootTag);
77 bool readEdges(Graph& G, GraphAttributes* GA, const pugi::xml_node rootTag);
79 const cluster& rootCluster, const pugi::xml_node clusterRoot);
80
81 bool m_error;
82
83public:
84 explicit GraphMLParser(std::istream& in);
86
87 bool read(Graph& G);
88 bool read(Graph& G, GraphAttributes& GA);
89 bool read(Graph& G, ClusterGraph& C);
91};
92
93}
Derived class of GraphObserver providing additional functionality to handle clustered graphs.
Includes declaration of graph class.
Basic declarations, included by all source files.
Representation of clusters in a clustered graph.
Stores additional attributes of a clustered graph (like layout information).
Representation of clustered graphs.
Class for the representation of edges.
Definition Graph_d.h:364
Stores additional attributes of a graph (like layout information).
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:866
std::unordered_map< string, node > m_nodeId
bool read(Graph &G, ClusterGraph &C, ClusterGraphAttributes &CA)
bool readNodes(Graph &G, GraphAttributes *GA, const pugi::xml_node rootTag)
bool read(Graph &G, ClusterGraph &C)
bool readData(ClusterGraphAttributes &CA, const cluster &c, const pugi::xml_node clusterData)
pugi::xml_document m_xml
GraphMLParser(std::istream &in)
std::unordered_map< string, string > m_attrName
bool readAttributes(A &GA, const T &elem, const pugi::xml_node xmlElem)
pugi::xml_node m_graphTag
bool read(Graph &G)
bool readEdges(Graph &G, GraphAttributes *GA, const pugi::xml_node rootTag)
bool read(Graph &G, GraphAttributes &GA)
bool readClusters(Graph &G, ClusterGraph &C, ClusterGraphAttributes *CA, const cluster &rootCluster, const pugi::xml_node clusterRoot)
bool readData(GraphAttributes &GA, const edge &e, const pugi::xml_node edgeData)
bool readData(GraphAttributes &GA, const node &v, const pugi::xml_node nodeData)
Class for the representation of nodes.
Definition Graph_d.h:241
xml_object_range< xml_node_iterator > children() const
The namespace for all OGDF objects.