diff --git a/src/GraphMLWriter.hpp b/src/GraphMLWriter.hpp index 4179f219d169ca33f90b861f10d2e81bc926c1fd..02046c9e2251a99917926da3d429aa002ec4ed75 100644 --- a/src/GraphMLWriter.hpp +++ b/src/GraphMLWriter.hpp @@ -6,14 +6,37 @@ #include <boost/fusion/include/mpl.hpp> #include <boost/fusion/include/for_each.hpp> #include <fstream> +#include "common.hpp" -namespace std -{ - // We need the definition of std::to_string that work on string - std::string to_string(std::string s) +/*! \brief Create properties name starting from a type T + * + * if T has defined some properties name that name are used otherwise + * default name are created + * + * \tparam T vertex type + * + */ + +template <typename T> +void create_prop(std::string * str) +{ + // if T has attributes defined + if (has_attributes<T>::value ) { - return s; + // Create properties names based on the attributes name defined + for (int i = 0 ; i < T::max_prop ; i++) + { + str[i] = std::string(T::attributes::name[i]); + } + } + else + { + // Create default properties name + for (int i = 0 ; i < T::max_prop ; i++) + { + str[i] = "attr" + std::to_string(i); + } } } @@ -50,6 +73,7 @@ struct vertex_prop * constructor is selected over the other one * */ + vertex_prop(std::string & v_prop, typename G::V_type::attributes & a_name) :v_prop(v_prop),attributes_names(a_name.name) { @@ -68,6 +92,14 @@ struct vertex_prop vertex_prop(std::string & v_prop) :v_prop(v_prop),attributes_names(NULL) { + // Calculate the number of attributes + n_attr = G::V_type::max_prop; + + // Create default property names + attributes_names = new std::string[G::V_type::max_prop]; + + // Create default property names + create_prop<typename G::V_type>(attributes_names); }; //! It call the functor for each member @@ -84,17 +116,17 @@ struct vertex_prop // Create a property string based on the type of the property if (typeid(T) == typeid(float)) - v_prop += "<key id=\"v" + std::to_string(cnt) + "\" for=\"node\" attr.name=" + attributes_names[cnt] + " attr.type=\"float\"/>"; + v_prop += "<key id=\"vk" + std::to_string(cnt) + "\" for=\"node\" attr.name=\"" + attributes_names[cnt] + "\" attr.type=\"float\"/>\n"; else if (typeid(T) == typeid(double)) - v_prop += "<key id=\"v" + std::to_string(cnt) + "\" for=\"node\" attr.name=" + attributes_names[cnt] + " attr.type=\"double\"/>"; + v_prop += "<key id=\"vk" + std::to_string(cnt) + "\" for=\"node\" attr.name=\"" + attributes_names[cnt] + "\" attr.type=\"double\"/>\n"; else if (typeid(T) == typeid(int)) - v_prop += "<key id=\"v" + std::to_string(cnt) + "\" for=\"node\" attr.name=" + attributes_names[cnt] + " attr.type=\"int\"/>"; + v_prop += "<key id=\"vk" + std::to_string(cnt) + "\" for=\"node\" attr.name=\"" + attributes_names[cnt] + "\" attr.type=\"int\"/>\n"; else if (typeid(T) == typeid(long int)) - v_prop += "<key id=\"v" + std::to_string(cnt) + "\" for=\"node\" attr.name=" + attributes_names[cnt] + " attr.type=\"long\"/>"; + v_prop += "<key id=\"vk" + std::to_string(cnt) + "\" for=\"node\" attr.name=\"" + attributes_names[cnt] + "\" attr.type=\"long\"/>\n"; else if (typeid(T) == typeid(bool)) - v_prop += "<key id=\"v" + std::to_string(cnt) + "\" for=\"node\" attr.name=" + attributes_names[cnt] + " attr.type=\"boolean\"/>"; + v_prop += "<key id=\"vk" + std::to_string(cnt) + "\" for=\"node\" attr.name=\"" + attributes_names[cnt] + "\" attr.type=\"boolean\"/>\n"; else if (typeid(T) == typeid(std::string)) - v_prop += "<key id=\"v" + std::to_string(cnt) + "\" for=\"node\" attr.name=" + attributes_names[cnt] + " attr.type=\"string\"/>"; + v_prop += "<key id=\"vk" + std::to_string(cnt) + "\" for=\"node\" attr.name=\"" + attributes_names[cnt] + "\" attr.type=\"string\"/>\n"; } cnt++; @@ -119,18 +151,9 @@ struct vertex_node // Properties counter int cnt = 0; - // vertex counter - size_t v_c = 0; - // vertex node string std::string & v_node; - // vertex yFile geometry extension - std::string yFile_geometry_ext; - - // vertex yFile shape extension - std::string yFile_shape_ext; - // Attribute names std::string * attributes_names; @@ -158,14 +181,21 @@ struct vertex_node * * Create a vertex properties list * - * \param v_prop std::string that is filled with the graph properties in the GraphML format + * \param v_node std::string that is filled with the graph properties in the GraphML format * \param n_obj object container to access its properties for example encapc<...> - * \param n_prop number of properties * */ vertex_node(std::string & v_node, const typename G::V_container & n_obj) :vo(n_obj),v_node(v_node),attributes_names(NULL) { + // Calculate the number of attributes + n_attr = G::V_type::max_prop; + + // Create default property names + attributes_names = new std::string[G::V_type::max_prop]; + + // Create default property names + create_prop<typename G::V_type>(attributes_names); }; /*! \brief Create a new node @@ -173,19 +203,13 @@ struct vertex_node * Create a new node * */ - void new_node() + void new_node(size_t v_c) { // start a new node - v_node += "<node id=\"n"+ std::to_string(v_c) + "\">"; + v_node += "<node id=\"n"+ std::to_string(v_c) + "\">\n"; // reset the counter properties cnt = 0; - - // reset the yFile geometry extension node - yFile_geometry_ext.clear(); - - // reset the yFile shape extension node - yFile_shape_ext.clear(); } /*! \brief Close a node @@ -196,7 +220,7 @@ struct vertex_node void end_node() { // close a node - v_node += "</node>"; + v_node += "</node>\n"; } //! It call the functor for each member @@ -206,31 +230,19 @@ struct vertex_node //! Create an entry for the attribute if (T::value < n_attr) { - // if it is a yFile extension property name process as yFile extension - if (attributes_names[T::value] == "x") - {yFile_geometry_ext += " x=" + std::to_string(vo.template get<T::value>());} - else if (attributes_names[T::value] == "y") - {yFile_geometry_ext += " x=" + std::to_string(vo.template get<T::value>());} - else if (attributes_names[T::value] == "z") - {yFile_geometry_ext += " z=" + std::to_string(vo.template get<T::value>());} - else if (attributes_names[T::value] == "shape" ) - {yFile_shape_ext += " shape=" + std::to_string(vo.template get<T::value>());} - else - { - // Create a property string based on the type of the property - if (typeid(decltype(vo.template get<T::value>())) == typeid(float)) - v_node += "<data key=\"key" + std::to_string(cnt) + "\">" + std::to_string(vo.template get<T::value>()) + "</>"; - else if (typeid(decltype(vo.template get<T::value>())) == typeid(double)) - v_node += "<data key=\"key" + std::to_string(cnt) + "\">" + std::to_string(vo.template get<T::value>()) + "</>"; - else if (typeid(decltype(vo.template get<T::value>())) == typeid(int)) - v_node += "<data key=\"key" + std::to_string(cnt) + "\">" + std::to_string(vo.template get<T::value>()) + "</>"; - else if (typeid(decltype(vo.template get<T::value>())) == typeid(long int)) - v_node += "<data key=\"key" + std::to_string(cnt) + "\">" + std::to_string(vo.template get<T::value>()) + "</>"; - else if (typeid(decltype(vo.template get<T::value>())) == typeid(bool)) - v_node += "<data key=\"key" + std::to_string(cnt) + "\">" + std::to_string(vo.template get<T::value>()) + "</>"; - else if (typeid(decltype(vo.template get<T::value>())) == typeid(std::string)) - v_node += "<data key=\"key" + std::to_string(cnt) + "\">" + std::to_string(vo.template get<T::value>()) + "</>"; - } + // Create a property string based on the type of the property + if (typeid(decltype(vo.template get<T::value>())) == typeid(float)) + v_node += " <data key=\"vk" + std::to_string(cnt) + "\">" + std::to_string(vo.template get<T::value>()) + "</data>\n"; + else if (typeid(decltype(vo.template get<T::value>())) == typeid(double)) + v_node += " <data key=\"vk" + std::to_string(cnt) + "\">" + std::to_string(vo.template get<T::value>()) + "</data>\n"; + else if (typeid(decltype(vo.template get<T::value>())) == typeid(int)) + v_node += " <data key=\"vk" + std::to_string(cnt) + "\">" + std::to_string(vo.template get<T::value>()) + "</data>\n"; + else if (typeid(decltype(vo.template get<T::value>())) == typeid(long int)) + v_node += " <data key=\"vk" + std::to_string(cnt) + "\">" + std::to_string(vo.template get<T::value>()) + "</data>\n"; + else if (typeid(decltype(vo.template get<T::value>())) == typeid(bool)) + v_node += " <data key=\"vk" + std::to_string(cnt) + "\">" + std::to_string(vo.template get<T::value>()) + "</data>\n"; + else if (typeid(decltype(vo.template get<T::value>())) == typeid(std::string)) + v_node += " <data key=\"vk" + std::to_string(cnt) + "\">" + std::to_string(vo.template get<T::value>()) + "</data>\n"; } cnt++; @@ -288,6 +300,14 @@ struct edge_prop edge_prop(std::string & e_prop) :e_prop(e_prop),attributes_names(NULL) { + // Calculate the number of attributes + n_attr = G::E_type::max_prop; + + // Create default property names + attributes_names = new std::string[G::E_type::max_prop]; + + // Create default property names + create_prop<typename G::E_type>(attributes_names); }; //! It call the functor for each member @@ -297,24 +317,19 @@ struct edge_prop //! Create an entry for the attribute if (cnt < n_attr) { - // if it is a yFile extension property name, does not process it - if (attributes_names[cnt] == "x" || attributes_names[cnt] == "y" - || attributes_names[cnt] == "z" || attributes_names[cnt] == "shape" ) - {cnt++; return ;} - // Create a property string based on the type of the property if (typeid(T) == typeid(float)) - e_prop += "<key id=\"v" + std::to_string(cnt) + "\" for=\"node\" attr.name=" + attributes_names[cnt] + " attr.type=\"float\"/>"; + e_prop += "<key id=\"ek" + std::to_string(cnt) + "\" for=\"edge\" attr.name=\"" + attributes_names[cnt] + "\" attr.type=\"float\"/>\n"; else if (typeid(T) == typeid(double)) - e_prop += "<key id=\"v" + std::to_string(cnt) + "\" for=\"node\" attr.name=" + attributes_names[cnt] + " attr.type=\"double\"/>"; + e_prop += "<key id=\"ek" + std::to_string(cnt) + "\" for=\"edge\" attr.name=\"" + attributes_names[cnt] + "\" attr.type=\"double\"/>\n"; else if (typeid(T) == typeid(int)) - e_prop += "<key id=\"v" + std::to_string(cnt) + "\" for=\"node\" attr.name=" + attributes_names[cnt] + " attr.type=\"int\"/>"; + e_prop += "<key id=\"ek" + std::to_string(cnt) + "\" for=\"edge\" attr.name=\"" + attributes_names[cnt] + "\" attr.type=\"int\"/>\n"; else if (typeid(T) == typeid(long int)) - e_prop += "<key id=\"v" + std::to_string(cnt) + "\" for=\"node\" attr.name=" + attributes_names[cnt] + " attr.type=\"long\"/>"; + e_prop += "<key id=\"ek" + std::to_string(cnt) + "\" for=\"edge\" attr.name=\"" + attributes_names[cnt] + "\" attr.type=\"long\"/>\n"; else if (typeid(T) == typeid(bool)) - e_prop += "<key id=\"v" + std::to_string(cnt) + "\" for=\"node\" attr.name=" + attributes_names[cnt] + " attr.type=\"boolean\"/>"; + e_prop += "<key id=\"ek" + std::to_string(cnt) + "\" for=\"edge\" attr.name=\"" + attributes_names[cnt] + "\" attr.type=\"boolean\"/>\n"; else if (typeid(T) == typeid(std::string)) - e_prop += "<key id=\"v" + std::to_string(cnt) + "\" for=\"node\" attr.name=" + attributes_names[cnt] + " attr.type=\"string\"/>"; + e_prop += "<key id=\"ek" + std::to_string(cnt) + "\" for=\"edge\" attr.name=\"" + attributes_names[cnt] + "\" attr.type=\"string\"/>\n"; } cnt++; @@ -334,23 +349,14 @@ template<typename G> struct edge_node { // Vertex object container - const typename G::E_container & vo; + typename G::E_container & vo; // Properties counter int cnt = 0; - // vertex counter - size_t v_c = 0; - // edge node string std::string & e_node; - // edge yFile geometry extension - std::string yFile_geometry_ext; - - // edge yFile shape extension - std::string yFile_shape_ext; - // Attribute names std::string * attributes_names; @@ -367,7 +373,7 @@ struct edge_node * constructor is selected over the other one * */ - edge_node(std::string & e_node, const typename G::E_container & n_obj, typename G::E_type::attributes & a_name) + edge_node(std::string & e_node, typename G::E_container & n_obj, typename G::E_type::attributes & a_name) :vo(n_obj),e_node(e_node),attributes_names(a_name.name) { // Calculate the number of attributes name @@ -383,29 +389,32 @@ struct edge_node * \param n_prop number of properties * */ - edge_node(std::string & v_node, const typename G::E_container & n_obj) + edge_node(std::string & e_node, typename G::E_container & n_obj) :vo(n_obj),e_node(e_node),attributes_names(NULL) { + // Calculate the number of attributes + n_attr = G::E_type::max_prop; + + // Create a number of default properties name + attributes_names = new std::string[G::E_type::max_prop]; + + // Create default property names + create_prop<typename G::E_type>(attributes_names); + }; /*! \brief Create a new node * - * Create a new node + * \param vc node number * */ - void new_node() + void new_node(size_t v_c, size_t s, size_t d) { // start a new node - e_node += "<node id=\"n"+ std::to_string(v_c) + "\">"; + e_node += "<edge id=\"e"+ std::to_string(v_c) + "\" source=\"n" + std::to_string(s) + "\" target=\"n" + std::to_string(d) + "\">\n"; // reset the counter properties cnt = 0; - - // reset the yFile geometry extension node - yFile_geometry_ext.clear(); - - // reset the yFile shape extension node - yFile_shape_ext.clear(); } /*! \brief Close a node @@ -416,7 +425,7 @@ struct edge_node void end_node() { // close a node - e_node += "</node>"; + e_node += "</node>\n"; } //! It call the functor for each member @@ -426,31 +435,19 @@ struct edge_node //! Create an entry for the attribute if (T::value < n_attr) { - // if it is a yFile extension property name process as yFile extension - if (attributes_names[T::value] == "x") - {yFile_geometry_ext += " x=" + std::to_string(vo.template get<T::value>());} - else if (attributes_names[T::value] == "y") - {yFile_geometry_ext += " x=" + std::to_string(vo.template get<T::value>());} - else if (attributes_names[T::value] == "z") - {yFile_geometry_ext += " z=" + std::to_string(vo.template get<T::value>());} - else if (attributes_names[T::value] == "shape" ) - {yFile_shape_ext += " shape=" + std::to_string(vo.template get<T::value>());} - else - { - // Create a property string based on the type of the property - if (typeid(decltype(vo.template get<T::value>())) == typeid(float)) - e_node += "<data key=\"key" + std::to_string(cnt) + "\">" + std::to_string(vo.template get<T::value>()) + "</>"; - else if (typeid(decltype(vo.template get<T::value>())) == typeid(double)) - e_node += "<data key=\"key" + std::to_string(cnt) + "\">" + std::to_string(vo.template get<T::value>()) + "</>"; - else if (typeid(decltype(vo.template get<T::value>())) == typeid(int)) - e_node += "<data key=\"key" + std::to_string(cnt) + "\">" + std::to_string(vo.template get<T::value>()) + "</>"; - else if (typeid(decltype(vo.template get<T::value>())) == typeid(long int)) - e_node += "<data key=\"key" + std::to_string(cnt) + "\">" + std::to_string(vo.template get<T::value>()) + "</>"; - else if (typeid(decltype(vo.template get<T::value>())) == typeid(bool)) - e_node += "<data key=\"key" + std::to_string(cnt) + "\">" + std::to_string(vo.template get<T::value>()) + "</>"; - else if (typeid(decltype(vo.template get<T::value>())) == typeid(std::string)) - e_node += "<data key=\"key" + std::to_string(cnt) + "\">" + std::to_string(vo.template get<T::value>()) + "</>"; - } + // Create a property string based on the type of the property + if (typeid(decltype(vo.template get<T::value>())) == typeid(float)) + e_node += " <data key=\"ek" + std::to_string(cnt) + "\">" + std::to_string(vo.template get<T::value>()) + "</data>\n"; + else if (typeid(decltype(vo.template get<T::value>())) == typeid(double)) + e_node += " <data key=\"ek" + std::to_string(cnt) + "\">" + std::to_string(vo.template get<T::value>()) + "</data>\n"; + else if (typeid(decltype(vo.template get<T::value>())) == typeid(int)) + e_node += " <data key=\"ek" + std::to_string(cnt) + "\">" + std::to_string(vo.template get<T::value>()) + "</data>\n"; + else if (typeid(decltype(vo.template get<T::value>())) == typeid(long int)) + e_node += " <data key=\"ek" + std::to_string(cnt) + "\">" + std::to_string(vo.template get<T::value>()) + "</data>\n"; + else if (typeid(decltype(vo.template get<T::value>())) == typeid(bool)) + e_node += " <data key=\"ek" + std::to_string(cnt) + "\">" + std::to_string(vo.template get<T::value>()) + "</data>\n"; + else if (typeid(decltype(vo.template get<T::value>())) == typeid(std::string)) + e_node += " <data key=\"ek" + std::to_string(cnt) + "\">" + std::to_string(vo.template get<T::value>()) + "</data>\n"; } cnt++; @@ -468,12 +465,10 @@ class GraphMLWriter { Graph & g; - - /*! \brief It get the vertex properties list * * It get the vertex properties list of the vertex defined as a GraphML header - * x y z and shape are reserved properties name for yFile extension, and + * and * define position and shape of the node * * \return a string that define the vertex properties in graphML format @@ -483,7 +478,7 @@ class GraphMLWriter std::string get_vertex_properties_list() { //! vertex property output string - std::string v_out("<key id=\"d0\" for=\"node\" yfiles.type=\"nodegraphics\"/>"); + std::string v_out("<key id=\"d0\" for=\"node\" yfiles.type=\"nodegraphics\"/>\n"); // create a vertex property functor vertex_prop<Graph> vp(v_out); @@ -506,7 +501,7 @@ class GraphMLWriter std::string get_edge_properties_list() { //! edge property output string - std::string e_out(" "); + std::string e_out; // create a vertex property functor edge_prop<Graph> ep(e_out); @@ -520,6 +515,9 @@ class GraphMLWriter std::string get_vertex_list() { + // node counter + size_t nc = 0; + //! vertex node output string std::string v_out; @@ -532,11 +530,18 @@ class GraphMLWriter // create a vertex list functor vertex_node<Graph> vn(v_out,g.vertex(it.get())); + // create new node + vn.new_node(nc); + // Iterate through all the vertex and create the vertex list boost::mpl::for_each< boost::mpl::range_c<int,0,Graph::V_type::max_prop-1> >(vn); - // increment the operator + // end node + vn.end_node(); + + // increment the iterator and counter ++it; + nc++; } // return the vertex list @@ -545,8 +550,11 @@ class GraphMLWriter std::string get_edge_list() { + // node counter + size_t nc = 0; + //! edge node output string - std::string v_out; + std::string e_out; //! Get an edge iterator auto it = g.getEdgeIterator(); @@ -554,18 +562,28 @@ class GraphMLWriter // if there is the next element while (it.isNext()) { + // Get the edge object + auto obj = g.edge(it.get()); + // create an edge list functor - edge_node<Graph> en(v_out,g.edge(it.get())); + edge_node<Graph> en(e_out,obj); + + // create a new node + en.new_node(nc,it.source(),it.target()); // Iterate through all the vertex and create the vertex list boost::mpl::for_each< boost::mpl::range_c<int,0,Graph::V_type::max_prop-1> >(en); + // end new node + en.end_node(); + // increment the operator ++it; + nc++; } // return the edge list - return v_out; + return e_out; } public: @@ -608,16 +626,16 @@ public: std::string edge_prop_header; // GraphML header - gml_header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\ - <graphml xmlns=\"http://graphml.graphdrawing.org/xmlns\"\ - xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\ - xsi:schemaLocation=\"http://graphml.graphdrawing.org/xmlns\ - http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd\">"; + gml_header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\ + <graphml xmlns=\"http://graphml.graphdrawing.org/xmlns\"\n\ + xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n\ + xsi:schemaLocation=\"http://graphml.graphdrawing.org/xmlns\n\ + http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd\">\n"; // Graph header to define an header - graph_header = "<graph id=" + graph_name + " edgedefault=\"directed\">"; + graph_header = "<graph id=\"" + graph_name + "\" edgedefault=\"directed\">\n"; // Graph header end - graph_header_end = "</graph>"; + graph_header_end = "</graph>\n"; // Vertex properties header vertex_prop_header = get_vertex_properties_list(); @@ -639,12 +657,16 @@ public: std::ofstream ofs(file); // Check if the file is open - if (ofs.is_open()) + if (ofs.is_open() == false) {std::cerr << "Error cannot creare the graphML file: " + file;} ofs << gml_header << graph_header << vertex_prop_header << edge_prop_header << vertex_list << edge_list << graph_header_end << gml_header_end; + // Close the file + + ofs.close(); + // Completed succefully return true; } diff --git a/src/GraphMLWriter_unit_tests.hpp b/src/GraphMLWriter_unit_tests.hpp index 726ac527ba4e61f1c81f0878ac54671af2e6216b..1abc9bef29f514507f94ff742a9379bef3331dec 100644 --- a/src/GraphMLWriter_unit_tests.hpp +++ b/src/GraphMLWriter_unit_tests.hpp @@ -8,9 +8,10 @@ #ifndef GRAPHMLWRITER_UNIT_TESTS_HPP_ #define GRAPHMLWRITER_UNIT_TESTS_HPP_ -#define GS_SIZE 128 +#define GS_SIZE 8 #include "GraphMLWriter.hpp" +#include "VTKWriter.hpp" #include "Graph/CartesianGraphFactory.hpp" BOOST_AUTO_TEST_SUITE( graphml_writer_test ) @@ -29,12 +30,6 @@ struct ne_cp typedef typename memory_traits_inte<type>::type memory_int; typedef typename memory_traits_lin<type>::type memory_lin; - //! define attributes names - struct attributes - { - static const std::string name[]; - }; - //! The data type data; @@ -44,25 +39,52 @@ struct ne_cp static const unsigned int y = 1; //! z property id in boost::fusion::vector static const unsigned int z = 2; - //! float_num property id in boost::fusion::vector - static const unsigned int float_num = 3; //! double_num property id in boost::fusion::vector - static const unsigned int double_num = 4; + static const unsigned int double_num = 3; //! long_num property id in boost::fusion::vector - static const unsigned int long_num = 5; + static const unsigned int long_num = 4; //! integer property id in boost::fusion::vector - static const unsigned int integer = 6; + static const unsigned int integer = 5; //! string property id in boost::fusion::vector - static const unsigned int string = 7; + static const unsigned int string = 6; //! total number of properties boost::fusion::vector - static const unsigned int max_prop = 8; + static const unsigned int max_prop = 7; + + //! define attributes names + struct attributes + { + static const std::string name[max_prop]; + }; + + //! type of the spatial information + typedef float s_type; }; // Initialize the attributes strings array -const std::string ne_cp::attributes::name[] = {"x","y","z","float_num","double_num","long_num","integer","string"}; +const std::string ne_cp::attributes::name[] = {"x","y","z","double_num","long_num","integer","string"}; BOOST_AUTO_TEST_CASE( graphml_writer_use) { + Graph_CSR<ne_cp,ne_cp> g_csr2; + + // Add 4 vertex and connect + + struct ne_cp n1; + g_csr2.addVertex(n1); + g_csr2.addVertex(n1); + g_csr2.addVertex(n1); + g_csr2.addVertex(n1); + + g_csr2.addEdge(0,1); + g_csr2.addEdge(2,1); + g_csr2.addEdge(3,1); + g_csr2.addEdge(2,0); + g_csr2.addEdge(3,2); + + VTKWriter<Graph_CSR<ne_cp,ne_cp>> gv2(g_csr2); + + gv2.write("test_graph2.vtk"); + //! Create a graph CartesianGraphFactory<3,Graph_CSR<ne_cp,ne_cp>> g_factory; @@ -76,11 +98,17 @@ BOOST_AUTO_TEST_CASE( graphml_writer_use) // Box Box<3,float> box({0.0,0.0,0.0},{1.0,1.0,1.0}); - Graph_CSR<ne_cp,ne_cp> g_csr = g_factory.construct<5,float,2>(sz,box); + Graph_CSR<ne_cp,ne_cp> g_csr = g_factory.construct<5,float,2,ne_cp::x,ne_cp::y,ne_cp::z>(sz,box); GraphMLWriter<Graph_CSR<ne_cp,ne_cp>> gw(g_csr); +// std::cout << std::is_class<ne_cp::attributes>; + gw.write("test_graph.gml"); + + VTKWriter<Graph_CSR<ne_cp,ne_cp>> gv(g_csr); + + gv.write("test_graph.vtk"); } BOOST_AUTO_TEST_SUITE_END()