50# include <libxml++/libxml++.h>
51# include <libxml++/parsers/textreader.h>
52# include <libxml++/nodes/node.h>
53# include <libxml++/document.h>
153 reader.move_to_first_attribute();
163 while (
reader.move_to_next_attribute());
173 reader.move_to_first_attribute();
174 size_t src = std::atol(
reader.get_value().c_str());
177 size_t tgt = std::atol(
reader.get_value().c_str());
196 while (
reader.move_to_next_attribute());
208 xmlpp::TextReader
reader(file_name);
222 for (
typename GT::Node_Iterator it(g); it.has_curr(); it.next_ne(), ++i)
224 typename GT::Node * p = it.get_curr();
234 for (
size_t i = 0; i < attrs.
size(); ++i)
237 node->set_attribute(
attr.name,
attr.value);
241 xmlpp::Element *
arcs =
element->add_child(
"arcs");
243 for (
typename GT::Arc_Iterator it(g); it.has_curr(); it.next_ne(), ++i)
245 typename GT::Arc * a = it.get_curr();
250 arc->set_attribute(
"src", std::to_string(src));
253 arc->set_attribute(
"tgt", std::to_string(tgt));
259 for (
size_t i = 0; i < attrs.
size(); ++i)
262 arc->set_attribute(
attr.name,
attr.value);
267 void write(
GT & g,
const std::string & file_name)
271 doc.write_to_file_formatted(file_name,
"UTF-8");
327 return read(file_name);
size_t size() const noexcept
Return the current dimension of array.
T & access(const size_t i) const noexcept
Fast access without checking allocation and bound_min_clock checking.
T & append()
Allocate a new entry to the end of array.
Pair * insert(const Key &key, const Data &data)
Insert a key-value pair.
Data & find(const Key &key)
Find the value associated with key.
virtual Node * insert_node(Node *node) noexcept
Insertion of a node already allocated.
Arc * insert_arc(Node *src_node, Node *tgt_node, void *a)
Clase que escribe y lee un grafo (de forma muy elemental) en XML.
void write_graph(GT &g, xmlpp::Document &doc)
const std::string & get_arc_name() const
const std::string & get_node_name() const
Xml_Graph(Node_Reader &&_node_reader=Node_Reader(), Arc_Reader &&_arc_reader=Arc_Reader(), Node_Writer &&_node_writer=Node_Writer(), Arc_Writer &&_arc_writer=Arc_Writer())
Xml_Graph(Node_Reader &_node_reader, Arc_Reader &_arc_reader, Node_Writer &_node_writer, Arc_Writer &_arc_writer)
GT read_graph(xmlpp::TextReader &reader)
const std::string & get_graph_name() const
void set_graph_name(const std::string &_graph_name)
void set_node_name(const std::string &_node_name)
Node_Writer & node_writer
void write(GT &g, const std::string &file_name)
GT read(const std::string &file_name)
GT operator()(const std::string &file_name)
void set_arc_name(const std::string &_arc_name)
Node_Reader & node_reader
Node * get_src_node(Arc *arc) const noexcept
Return the source node of arc (only for directed graphs)
Node * get_tgt_node(Arc *arc) const noexcept
Return the target node of arc (only for directed graphs)
List_Graph< Graph_Node< int >, Graph_Arc< int > > GT
DynArray< Graph::Node * > nodes
DynArray< Graph::Arc * > arcs
Main namespace for Aleph-w library functions.
DynList< T > maps(const C &c, Op op)
Classic map operation.
void operator()(GT &, typename GT::Arc *, DynArray< Attr > &)
void operator()(GT &, typename GT::Arc *, DynArray< Attr > &)
void operator()(GT &, typename GT::Node *, DynArray< Attr > &)
void operator()(GT &, typename GT::Node *, DynArray< Attr > &)
Arc of graph implemented with double-linked adjacency lists.
void test(unsigned long n, gsl_rng *r)
Lazy and scalable dynamic array implementation.
Dynamic key-value map based on balanced binary search trees.
Generic graph and digraph implementations.