graph_analysis
GraphMLReader.hpp
Go to the documentation of this file.
1 #ifndef GRAPH_ANALYSIS_IO_GRAPHML_READER_HPP
2 #define GRAPH_ANALYSIS_IO_GRAPHML_READER_HPP
3 
4 #include <map>
5 #include <libxml/parser.h>
6 #include <libxml/xpath.h>
7 #include "../GraphIO.hpp"
8 #include "../Vertex.hpp"
9 #include "../Edge.hpp"
10 
11 namespace graph_analysis {
12 namespace io {
13 
20 class GraphMLReader : public Reader
21 {
22  typedef std::map < std::string, Vertex::Ptr > VertexMap;
23  struct GraphMLNode
24  {
25  Vertex::Ptr vertex;
26  std::string id;
27  };
28  struct GraphMLEdge
29  {
30  Edge::Ptr edge;
31  std::string id;
32  std::string source;
33  std::string target;
34  };
35 
36 public:
42  void read(const std::string& filename, BaseGraph::Ptr graph);
43 
44  GraphMLNode getNode(xmlNodePtr node, xmlXPathContextPtr context) const;
45  GraphMLEdge getEdge(xmlNodePtr node, xmlXPathContextPtr context) const;
46 };
47 
48 } // end namespace io
49 } // end namespace graph_analysis
50 #endif // GRAPH_ANALYSIS_IO_GRAPHML_READER_HPP
graph_analysis::io::GraphMLReader
Imports a base graph from a given GRAPHML file.
Definition: GraphMLReader.hpp:20
graph_analysis::io::GraphMLReader::getNode
GraphMLNode getNode(xmlNodePtr node, xmlXPathContextPtr context) const
Definition: GraphMLReader.cpp:13
graph_analysis
Main namespace of the graph analysis library.
Definition: BFS.cpp:3
graph_analysis::BaseGraph::Ptr
shared_ptr< BaseGraph > Ptr
Definition: BaseGraph.hpp:34
graph_analysis::Edge::Ptr
shared_ptr< Edge > Ptr
Definition: Edge.hpp:21
graph_analysis::Vertex::Ptr
shared_ptr< Vertex > Ptr
Definition: Vertex.hpp:22
graph_analysis::io::GraphMLReader::read
void read(const std::string &filename, BaseGraph::Ptr graph)
reads the graph from the given file and stores it to the provided graph argument
Definition: GraphMLReader.cpp:179
graph_analysis::io::Reader
Interface for Reader implementation that perform custom graph deserialization.
Definition: GraphIO.hpp:56
graph_analysis::io::GraphMLReader::getEdge
GraphMLEdge getEdge(xmlNodePtr node, xmlXPathContextPtr context) const
Definition: GraphMLReader.cpp:93