graph_analysis
YamlReader.hpp
Go to the documentation of this file.
1 #ifndef GRAPH_ANALYSIS_IO_YAML_READER_HPP
2 #define GRAPH_ANALYSIS_IO_YAML_READER_HPP
3 
4 #include <map>
5 #include <string>
6 #include <fstream>
7 #include <sstream>
8 #include <exception>
9 #include "../GraphIO.hpp"
10 #include "../Vertex.hpp"
11 #include "../Edge.hpp"
12 
13 namespace graph_analysis {
14 namespace io {
15 
23 class YamlReader : public Reader
24 {
25  typedef std::map < std::string, Vertex::Ptr > VertexMap;
26 private:
33  void parseNodes(std::stringstream& nodeStream, const BaseGraph::Ptr& graph, VertexMap& vMap) const;
40  void parseEdges(std::stringstream& edgeStream, const BaseGraph::Ptr& graph, VertexMap& vMap) const;
48  std::string nextToken(const std::string& keyword, std::stringstream& stream) const;
50  void die(const std::string& keyword, const std::string& word) const;
52  void die(const std::string& msg) const;
53 public:
59  void read(const std::string& filename, BaseGraph::Ptr graph);
60 };
61 
62 } // end namespace io
63 } // end namespace graph_analysis
64 #endif // GRAPH_ANALYSIS_IO_YAML_READER_HPP
Parses an inputfile with custom YAML/yml format to requested graph.
Definition: YamlReader.hpp:23
Interface for Reader implementation that perform custom graph deserialization.
Definition: GraphIO.hpp:56
Main namespace of the graph analysis library.
Definition: BFS.cpp:3
shared_ptr< BaseGraph > Ptr
Definition: BaseGraph.hpp:34
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: YamlReader.cpp:8