312template <AlephGraph
GT,
407 std::cout <<
"Storing " <<
num_nodes <<
" nodes ... ";
417 auto p = it.get_curr();
420 std::cout << i <<
" ";
429 std::cout <<
" done " << std::endl
430 <<
"Storing " << num_arcs <<
" arcs ... " << std::endl;
432 output.write(
reinterpret_cast<const char*
>(&num_arcs),
sizeof(num_arcs));
436 auto a = it.get_curr();
444 output.write(
reinterpret_cast<const char*
>(&src_idx),
sizeof(
int));
445 output.write(
reinterpret_cast<const char*
>(&
tgt_idx),
sizeof(
int));
448 std::cout <<
" " << src_idx <<
"--" <<
tgt_idx <<
" ";
453 std::cout << std::endl;
457 std::cout <<
" done " << std::endl << std::endl;
475 <<
"Failed to read node count from binary stream";
478 std::cout <<
"Loading " <<
num_nodes <<
" nodes ...";
486 std::unique_ptr<typename GT::Node> p(
new typename GT::Node);
489 std::cout <<
" " << i;
493 <<
"Failed to load node " << i <<
" from binary stream";
500 input.read(
reinterpret_cast<char*
>(&num_arcs),
sizeof(num_arcs));
502 <<
"Failed to read arc count from binary stream";
505 std::cout <<
" done " << std::endl
506 <<
"Loading " << num_arcs <<
" arcs ... " << std::endl;
508 for (
size_t i = 0; i < num_arcs; ++i)
511 input.read(
reinterpret_cast<char*
>(&src_idx),
sizeof(
int));
513 <<
"Failed to read source index for arc " << i;
518 input.read(
reinterpret_cast<char*
>(&
tgt_idx),
sizeof(
int));
520 <<
"Failed to read target index for arc " << i;
526 std::cout <<
" " << src_idx <<
"--" <<
tgt_idx <<
" ";
530 <<
"Failed to load arc " << i <<
" data";
533 std::cout << std::endl;
537 std::cout <<
" done " << std::endl << std::endl;
565 << num_arcs << std::endl;
568 std::cout <<
"Storing " <<
num_nodes <<
" nodes ... ";
576 typename GT::Node * p = it.get_curr();
579 std::cout << i <<
" ";
586 std::cout <<
" done " << std::endl
587 <<
"Storing " << num_arcs <<
" arcs ... " << std::endl;
591 auto a = it.get_curr();
602 std::cout <<
" " << src_idx <<
"--" <<
tgt_idx <<
" ";
607 std::cout << std::endl;
611 std::cout <<
" done " << std::endl << std::endl;
631 <<
"Failed to read node/arc count from text stream";
636 std::cout <<
"Loading " <<
num_nodes <<
" nodes ...";
644 std::unique_ptr<typename GT::Node> p(
new typename GT::Node);
647 std::cout <<
" " << i;
651 <<
"Failed to load node " << i <<
" from text stream";
658 std::cout <<
" done " << std::endl
659 <<
"Loading " << num_arcs <<
" arcs ... " << std::endl;
661 for (
size_t i = 0; i < num_arcs; ++i)
668 <<
"Failed to read arc " << i <<
" indices from text stream";
675 std::cout <<
" " << src_idx <<
"--" <<
tgt_idx <<
" ";
679 <<
"Failed to load arc " << i <<
" data from text stream";
682 std::cout << std::endl;
686 std::cout <<
" done " << std::endl << std::endl;
Exception handling system with formatted messages for Aleph-w.
#define ah_runtime_error_if(C)
Throws std::runtime_error if condition holds.
C++20 concepts for the protocol shared by graph algorithms.
List_Graph< Graph_Node< Node_Info >, Graph_Arc< Arc_Info > > GT
Dynamic map implemented with a treap.
void next_ne() noexcept
Advances the iterator to the next filtered element (noexcept version).
Graph serialization and deserialization class.
void save(std::ofstream &output)
Save graph to binary stream.
void set_store_arc(const Store_Arc &sa)
Set the arc storage functor.
IO_Graph(GT &__g) noexcept
Construct from graph reference.
void save_in_text_mode(std::ostream &output)
Save graph to text stream.
void load_in_text_mode(std::istream &input)
Load graph from text stream.
void load(std::ifstream &input)
Load graph from binary stream.
void set_arc_filter(const AF &af)
Set the arc filter for save operations.
bool is_verbose() const noexcept
Check if verbose mode is enabled.
void set_store_node(const Store_Node &sn)
Set the node storage functor.
void set_load_arc(const Load_Arc &la)
Set the arc loading functor.
IO_Graph(GT *gptr) noexcept
Construct from graph pointer.
void set_verbose(bool v) noexcept
Enable or disable verbose mode.
void set_node_filter(const NF &nf)
Set the node filter for save operations.
void set_load_node(const Load_Node &ln)
Set the node loading functor.
virtual Node * insert_node(Node *node) noexcept
Insertion of a node already allocated.
typename Node::Node_Type Node_Type
The arc class type.
Arc * insert_arc(Node *src_node, Node *tgt_node, void *a)
typename Arc::Arc_Type Arc_Type
The type of data stored in the arc.
Filtered iterator on the nodes of a graph.
ArcInfo & get_info() noexcept
Return a modifiable reference to the arc data.
NodeInfo & get_info() noexcept
Return a modifiable reference to the data contained in the node.
Node * get_src_node(Arc *arc) const noexcept
Return the source node of arc (only for directed graphs)
constexpr size_t get_num_nodes() const noexcept
Return the total of nodes of graph.
constexpr size_t get_num_arcs() const noexcept
Node * get_tgt_node(Arc *arc) const noexcept
Return the target node of arc (only for directed graphs)
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Main namespace for Aleph-w library functions.
Filtered iterator on all the arcs of a graph.
Default arc loading functor for binary and text modes.
void operator()(std::ifstream &input, GT &g, typename GT::Arc *a)
Load arc from binary stream.
void operator()(std::istream &input, GT &g, typename GT::Arc *a)
Load arc from text stream.
Default node loading functor for binary and text modes.
void operator()(std::istream &input, GT &g, typename GT::Node *p)
Load node from text stream.
void operator()(std::ifstream &input, GT &g, typename GT::Node *p)
Load node from binary stream.
Default filter for filtered iterators on arcs.
Default filter for the graph nodes.
Default arc storage functor for binary and text modes.
void operator()(std::ostream &output, GT &g, typename GT::Arc *a)
Store arc to text stream.
void operator()(std::ofstream &output, GT &g, typename GT::Arc *a)
Store arc to binary stream.
Default node storage functor for binary and text modes.
void operator()(std::ofstream &output, GT &g, typename GT::Node *p)
Store node to binary stream.
void operator()(std::ostream &output, GT &g, typename GT::Node *p)
Store node to text stream.
Generic graph and digraph implementations.