@@ -761,7 +761,7 @@ class hypergraph final {
761761 struct hyperedge_formatter {
762762 public:
763763 const hypergraph& hg;
764- const hyperedge_type& hyperedge;
764+ const hyperedge_type hyperedge;
765765
766766 friend std::ostream& operator <<(std::ostream& os, const hyperedge_formatter& proxy)
767767 requires std::same_as<directional_tag, undirected_t >
@@ -946,10 +946,18 @@ class hypergraph final {
946946 for (const auto & vertex : this ->vertices ())
947947 os << " - " << vertex << ' \n ' ;
948948 }
949+ else {
950+ this ->_write_implicit_vset (os) << ' \n ' ;
951+ }
949952
950- os << " hyperedges:\n " ;
951- for (const auto & edge : this ->hyperedges ())
952- os << " - " << this ->display (edge) << ' \n ' ;
953+ if (this ->size () == 0uz) {
954+ os << " hyperedges: {}" ;
955+ }
956+ else {
957+ os << " hyperedges:\n " ;
958+ for (const auto & edge : this ->hyperedges ())
959+ os << " - " << this ->display (edge) << ' \n ' ;
960+ }
953961
954962 return os;
955963 }
@@ -960,22 +968,38 @@ class hypergraph final {
960968 const bool with_v_props =
961969 io::is_option_set (os, with_vertex_properties)
962970 and traits::c_writable<vertex_properties_type>;
963- if (with_v_props) {
964- os << " V :" ;
965- for (const auto & vertex : this ->vertices ())
966- os << " " << vertex;
971+ if (with_v_props)
972+ os << " V = " << io::multiline_set_formatter (this ->vertices ()) << ' \n ' ;
973+ else
974+ this ->_write_implicit_vset (os) << ' \n ' ;
975+
976+ if (this ->size () == 0uz) {
977+ os << " E = {}\n " ;
967978 }
968979 else {
969- os << " |V| = " << this ->order ();
970- }
980+ auto hyperedges = std::views::transform (this ->hyperedges (), [this ](auto hyperedge) {
981+ return this ->display (hyperedge);
982+ });
971983
972- os << " \n E: \n " ;
973- for ( const auto & edge : this -> hyperedges ())
974- os << this -> display (edge) << ' \n ' ;
984+ // TODO: set/multiline_set
985+ os << " E = " << io::multiline_set_formatter (hyperedges) << ' \n ' ;
986+ }
975987
976988 return os;
977989 }
978990
991+ std::ostream& _write_implicit_vset (std::ostream& os) const {
992+ const auto n = this ->order ();
993+ if (n == 0uz)
994+ return os << " V = {}" ;
995+ if (n == 1uz)
996+ return os << " V = {0}" ;
997+ if (n == 2uz)
998+ return os << " V = {0, 1}" ;
999+
1000+ return os << " V = {0, ..., " << n - 1 << ' }' ;
1001+ }
1002+
9791003 // --- data members ---
9801004
9811005 size_type _n_vertices = 0uz;
0 commit comments