1616#include " hgl/util.hpp"
1717
1818#include < algorithm>
19+ #include < initializer_list>
1920#include < memory>
2021#include < set>
2122#include < type_traits>
@@ -320,13 +321,25 @@ class hypergraph final {
320321 return he;
321322 }
322323
324+ gl_attr_force_inline hyperedge_type add_hyperedge (std::initializer_list<id_type> vertex_ids)
325+ requires std::same_as<directional_tag, undirected_t>
326+ {
327+ return this ->add_hyperedge (std::views::all (vertex_ids));
328+ }
329+
323330 gl_attr_force_inline hyperedge_type
324331 add_hyperedge (const traits::c_forward_range_of<vertex_type> auto & vertex_rng)
325332 requires std::same_as<directional_tag, undirected_t >
326333 {
327334 return this ->add_hyperedge (vertex_rng | std::views::transform (&vertex_type::id));
328335 }
329336
337+ gl_attr_force_inline hyperedge_type add_hyperedge (std::initializer_list<vertex_type> vertices)
338+ requires std::same_as<directional_tag, undirected_t>
339+ {
340+ return this ->add_hyperedge (std::views::all (vertices));
341+ }
342+
330343 hyperedge_type add_hyperedge_with (
331344 const traits::c_forward_range_of<id_type> auto & vertex_id_rng,
332345 hyperedge_properties_type properties
@@ -338,6 +351,14 @@ class hypergraph final {
338351 return he;
339352 }
340353
354+ hyperedge_type add_hyperedge_with (
355+ std::initializer_list<id_type> vertex_ids, hyperedge_properties_type properties
356+ )
357+ requires(std::same_as<directional_tag, undirected_t > and traits::c_non_empty_properties<hyperedge_properties_type>)
358+ {
359+ return this ->add_hyperedge_with (std::views::all (vertex_ids), std::move (properties));
360+ }
361+
341362 gl_attr_force_inline hyperedge_type add_hyperedge_with (
342363 const traits::c_forward_range_of<vertex_type> auto & vertex_rng,
343364 hyperedge_properties_type properties
@@ -349,6 +370,14 @@ class hypergraph final {
349370 );
350371 }
351372
373+ hyperedge_type add_hyperedge_with (
374+ std::initializer_list<vertex_type> vertices, hyperedge_properties_type properties
375+ )
376+ requires(std::same_as<directional_tag, undirected_t > and traits::c_non_empty_properties<hyperedge_properties_type>)
377+ {
378+ return this ->add_hyperedge_with (std::views::all (vertices), std::move (properties));
379+ }
380+
352381 hyperedge_type add_hyperedge (
353382 const traits::c_forward_range_of<id_type> auto & tail_id_rng,
354383 const traits::c_forward_range_of<id_type> auto & head_id_rng
@@ -361,6 +390,13 @@ class hypergraph final {
361390 return he;
362391 }
363392
393+ gl_attr_force_inline hyperedge_type
394+ add_hyperedge (std::initializer_list<id_type> tail_ids, std::initializer_list<id_type> head_ids)
395+ requires std::same_as<directional_tag, bf_directed_t >
396+ {
397+ return this ->add_hyperedge (std::views::all (tail_ids), std::views::all (head_ids));
398+ }
399+
364400 gl_attr_force_inline hyperedge_type add_hyperedge (
365401 const traits::c_forward_range_of<vertex_type> auto & tail_rng,
366402 const traits::c_forward_range_of<vertex_type> auto & head_rng
@@ -373,6 +409,15 @@ class hypergraph final {
373409 );
374410 }
375411
412+ gl_attr_force_inline hyperedge_type add_hyperedge (
413+ std::initializer_list<vertex_type> tail_vertices,
414+ std::initializer_list<vertex_type> head_vertices
415+ )
416+ requires std::same_as<directional_tag, bf_directed_t>
417+ {
418+ return this ->add_hyperedge (std::views::all (tail_vertices), std::views::all (head_vertices));
419+ }
420+
376421 hyperedge_type add_hyperedge_with (
377422 const traits::c_forward_range_of<id_type> auto & tail_id_rng,
378423 const traits::c_forward_range_of<id_type> auto & head_id_rng,
@@ -386,6 +431,18 @@ class hypergraph final {
386431 return he;
387432 }
388433
434+ gl_attr_force_inline hyperedge_type add_hyperedge_with (
435+ std::initializer_list<id_type> tail_ids,
436+ std::initializer_list<id_type> head_ids,
437+ hyperedge_properties_type properties
438+ )
439+ requires(std::same_as<directional_tag, bf_directed_t > and traits::c_non_empty_properties<hyperedge_properties_type>)
440+ {
441+ return this ->add_hyperedge_with (
442+ std::views::all (tail_ids), std::views::all (head_ids), std::move (properties)
443+ );
444+ }
445+
389446 gl_attr_force_inline hyperedge_type add_hyperedge_with (
390447 const traits::c_forward_range_of<vertex_type> auto & tail_rng,
391448 const traits::c_forward_range_of<vertex_type> auto & head_rng,
@@ -400,6 +457,18 @@ class hypergraph final {
400457 );
401458 }
402459
460+ gl_attr_force_inline hyperedge_type add_hyperedge_with (
461+ std::initializer_list<vertex_type> tail_verticess,
462+ std::initializer_list<vertex_type> head_verticess,
463+ hyperedge_properties_type properties
464+ )
465+ requires(std::same_as<directional_tag, bf_directed_t > and traits::c_non_empty_properties<hyperedge_properties_type>)
466+ {
467+ return this ->add_hyperedge_with (
468+ std::views::all (tail_verticess), std::views::all (head_verticess), std::move (properties)
469+ );
470+ }
471+
403472 void add_hyperedges (const size_type n) {
404473 this ->_impl .add_hyperedges (n);
405474 this ->_n_hyperedges += n;
@@ -506,6 +575,14 @@ class hypergraph final {
506575 }
507576 }
508577
578+ gl_attr_force_inline void bind (
579+ std::initializer_list<id_type> vertex_ids, const id_type hyperedge_id
580+ )
581+ requires std::same_as<directional_tag, undirected_t>
582+ {
583+ this ->bind (std::views::all (vertex_ids), hyperedge_id);
584+ }
585+
509586 gl_attr_force_inline void bind (
510587 const traits::c_forward_range_of<vertex_type> auto & vertex_rng,
511588 const hyperedge_type& hyperedge
@@ -515,6 +592,14 @@ class hypergraph final {
515592 this ->bind (vertex_rng | std::views::transform (&vertex_type::id), hyperedge.id ());
516593 }
517594
595+ gl_attr_force_inline void bind (
596+ std::initializer_list<vertex_type> vertices, const id_type hyperedge_id
597+ )
598+ requires std::same_as<directional_tag, undirected_t>
599+ {
600+ this ->bind (std::views::all (vertices), hyperedge_id);
601+ }
602+
518603 void bind (
519604 const id_type vertex_id, const traits::c_forward_range_of<id_type> auto & hyperedge_id_rng
520605 )
@@ -527,6 +612,14 @@ class hypergraph final {
527612 }
528613 }
529614
615+ gl_attr_force_inline void bind (
616+ const id_type vertex_id, std::initializer_list<id_type> hyperedge_ids
617+ )
618+ requires std::same_as<directional_tag, undirected_t>
619+ {
620+ this ->bind (vertex_id, std::views::all (hyperedge_ids));
621+ }
622+
530623 gl_attr_force_inline void bind (
531624 const vertex_type& vertex,
532625 const traits::c_forward_range_of<hyperedge_type> auto & hyperedge_rng
@@ -536,6 +629,14 @@ class hypergraph final {
536629 this ->bind (vertex.id (), hyperedge_rng | std::views::transform (&hyperedge_type::id));
537630 }
538631
632+ gl_attr_force_inline void bind (
633+ const id_type vertex_id, std::initializer_list<hyperedge_type> hyperedges
634+ )
635+ requires std::same_as<directional_tag, undirected_t>
636+ {
637+ this ->bind (vertex_id, std::views::all (hyperedges));
638+ }
639+
539640 void bind_tail (const id_type vertex_id, const id_type hyperedge_id)
540641 requires std::same_as<directional_tag, bf_directed_t>
541642 {
@@ -562,6 +663,14 @@ class hypergraph final {
562663 }
563664 }
564665
666+ gl_attr_force_inline void bind_tail (
667+ std::initializer_list<id_type> vertex_ids, const id_type hyperedge_id
668+ )
669+ requires std::same_as<directional_tag, bf_directed_t>
670+ {
671+ this ->bind_tail (std::views::all (vertex_ids), hyperedge_id);
672+ }
673+
565674 gl_attr_force_inline void bind_tail (
566675 const traits::c_forward_range_of<vertex_type> auto & vertex_rng,
567676 const hyperedge_type& hyperedge
@@ -571,6 +680,14 @@ class hypergraph final {
571680 this ->bind_tail (vertex_rng | std::views::transform (&vertex_type::id), hyperedge.id ());
572681 }
573682
683+ gl_attr_force_inline void bind_tail (
684+ std::initializer_list<vertex_type> vertices, const id_type hyperedge_id
685+ )
686+ requires std::same_as<directional_tag, bf_directed_t>
687+ {
688+ this ->bind_tail (std::views::all (vertices), hyperedge_id);
689+ }
690+
574691 void bind_tail (
575692 const id_type vertex_id, const traits::c_forward_range_of<id_type> auto & hyperedge_id_rng
576693 )
@@ -583,6 +700,14 @@ class hypergraph final {
583700 }
584701 }
585702
703+ gl_attr_force_inline void bind_tail (
704+ const id_type vertex_id, std::initializer_list<id_type> hyperedge_ids
705+ )
706+ requires std::same_as<directional_tag, undirected_t>
707+ {
708+ this ->bind_tail (vertex_id, std::views::all (hyperedge_ids));
709+ }
710+
586711 gl_attr_force_inline void bind_tail (
587712 const vertex_type& vertex,
588713 const traits::c_forward_range_of<hyperedge_type> auto & hyperedge_rng
@@ -592,6 +717,14 @@ class hypergraph final {
592717 this ->bind_tail (vertex.id (), hyperedge_rng | std::views::transform (&hyperedge_type::id));
593718 }
594719
720+ gl_attr_force_inline void bind_tail (
721+ const id_type vertex_id, std::initializer_list<hyperedge_type> hyperedges
722+ )
723+ requires std::same_as<directional_tag, undirected_t>
724+ {
725+ this ->bind_tail (vertex_id, std::views::all (hyperedges));
726+ }
727+
595728 void bind_head (const id_type vertex_id, const id_type hyperedge_id)
596729 requires std::same_as<directional_tag, bf_directed_t>
597730 {
@@ -618,6 +751,14 @@ class hypergraph final {
618751 }
619752 }
620753
754+ gl_attr_force_inline void bind_head (
755+ std::initializer_list<id_type> vertex_ids, const id_type hyperedge_id
756+ )
757+ requires std::same_as<directional_tag, bf_directed_t>
758+ {
759+ this ->bind_head (std::views::all (vertex_ids), hyperedge_id);
760+ }
761+
621762 gl_attr_force_inline void bind_head (
622763 const traits::c_forward_range_of<vertex_type> auto & vertex_rng,
623764 const hyperedge_type& hyperedge
@@ -627,6 +768,14 @@ class hypergraph final {
627768 this ->bind_head (vertex_rng | std::views::transform (&vertex_type::id), hyperedge.id ());
628769 }
629770
771+ gl_attr_force_inline void bind_head (
772+ std::initializer_list<vertex_type> vertices, const id_type hyperedge_id
773+ )
774+ requires std::same_as<directional_tag, bf_directed_t>
775+ {
776+ this ->bind_head (std::views::all (vertices), hyperedge_id);
777+ }
778+
630779 void bind_head (
631780 const id_type vertex_id, const traits::c_forward_range_of<id_type> auto & hyperedge_id_rng
632781 )
@@ -639,6 +788,14 @@ class hypergraph final {
639788 }
640789 }
641790
791+ gl_attr_force_inline void bind_head (
792+ const id_type vertex_id, std::initializer_list<id_type> hyperedge_ids
793+ )
794+ requires std::same_as<directional_tag, undirected_t>
795+ {
796+ this ->bind_head (vertex_id, std::views::all (hyperedge_ids));
797+ }
798+
642799 gl_attr_force_inline void bind_head (
643800 const vertex_type& vertex,
644801 const traits::c_forward_range_of<hyperedge_type> auto & hyperedge_rng
@@ -648,6 +805,14 @@ class hypergraph final {
648805 this ->bind_head (vertex.id (), hyperedge_rng | std::views::transform (&hyperedge_type::id));
649806 }
650807
808+ gl_attr_force_inline void bind_head (
809+ const id_type vertex_id, std::initializer_list<hyperedge_type> hyperedges
810+ )
811+ requires std::same_as<directional_tag, undirected_t>
812+ {
813+ this ->bind_head (vertex_id, std::views::all (hyperedges));
814+ }
815+
651816 void unbind (const id_type vertex_id, const id_type hyperedge_id) {
652817 this ->_verify_vertex_id (vertex_id);
653818 this ->_verify_hyperedge_id (hyperedge_id);
@@ -1324,18 +1489,15 @@ class hypergraph final {
13241489 if (with_he_props) {
13251490 hyperedge_properties_type props;
13261491 is >> props;
1327- new_he_id = this ->add_hyperedge_with (std::move (props)).id ();
1492+ new_he_id = this ->add_hyperedge_with (v_ids, std::move (props)).id ();
13281493 }
13291494 else {
1330- new_he_id = this ->add_hyperedge ().id ();
1495+ new_he_id = this ->add_hyperedge (v_ids ).id ();
13311496 }
13321497 }
13331498 else {
1334- new_he_id = this ->add_hyperedge ().id ();
1499+ new_he_id = this ->add_hyperedge (v_ids ).id ();
13351500 }
1336-
1337- for (const auto v_id : v_ids)
1338- this ->bind (v_id, new_he_id);
13391501 }
13401502 }
13411503
@@ -1359,20 +1521,15 @@ class hypergraph final {
13591521 if (with_he_props) {
13601522 hyperedge_properties_type props;
13611523 is >> props;
1362- new_he_id = this ->add_hyperedge_with (std::move (props)).id ();
1524+ new_he_id = this ->add_hyperedge_with (tail_ids, head_ids, std::move (props)).id ();
13631525 }
13641526 else {
1365- new_he_id = this ->add_hyperedge ().id ();
1527+ new_he_id = this ->add_hyperedge (tail_ids, head_ids ).id ();
13661528 }
13671529 }
13681530 else {
1369- new_he_id = this ->add_hyperedge ().id ();
1531+ new_he_id = this ->add_hyperedge (tail_ids, head_ids ).id ();
13701532 }
1371-
1372- for (const auto v_id : tail_ids)
1373- this ->bind_tail (v_id, new_he_id);
1374- for (const auto v_id : head_ids)
1375- this ->bind_head (v_id, new_he_id);
13761533 }
13771534 }
13781535
0 commit comments