22 enum class graph_flavour { undirected, undirected_embedded, directed };
25 constexpr bool is_embedded(
const graph_flavour gf)
noexcept
27 return gf == graph_flavour::undirected_embedded;
31 constexpr bool is_directed(
const graph_flavour gf)
noexcept
33 return gf == graph_flavour::directed;
36 enum class edge_sharing_preference {agnostic, shared_weight, independent};
41 template<
class WeightHandler,
class MetaData, std::
integral IndexType>
48 template<
class WeightHandler,
class MetaData, std::
integral IndexType>
61 inline constexpr bool has_shared_weight_v{
63 typename Edge::weight_handler_type;
64 typename Edge::weight_type;
66 requires std::is_same_v<object::shared<typename Edge::weight_type>,
typename Edge::weight_handler_type>;
71 constexpr std::size_t num_static_edges(
const graph_flavour flavour,
const std::size_t size)
noexcept
73 return (flavour != graph_flavour::directed) ? 2*size : size;
76 template<
bool Shared,
class Weight>
77 using shared_to_handler_t = std::conditional_t<Shared, object::shared<Weight>, object::by_value<Weight>>;
79 template<
class Weight>
81 constexpr bool big_weight() noexcept
83 return sizeof(Weight) > 2*
sizeof(Weight*);
87 template<graph_flavour GraphFlavour,
class Handler,
class MetaData, std::
integral IndexType>
88 requires object::handler<Handler>
94 template<
class Handler,
class MetaData, std::
integral IndexType>
96 struct flavour_to_edge<graph_flavour::undirected_embedded, Handler, MetaData, IndexType>
101 template<graph_flavour GraphFlavour,
class Handler,
class MetaData, std::
integral IndexType>
107 graph_flavour GraphFlavour,
110 std::integral IndexType,
111 class EdgeStorageConfig
115 constexpr static graph_flavour flavour{GraphFlavour};
116 constexpr static edge_sharing_preference sharing_preference{EdgeStorageConfig::edge_sharing};
118 constexpr static bool default_weight_sharing{
119 !is_directed(GraphFlavour)
120 && (big_weight<EdgeWeight>() || !std::is_copy_constructible_v<EdgeWeight>)
123 constexpr static bool shared_weight_v{
124 (sharing_preference == edge_sharing_preference::shared_weight)
125 || ((sharing_preference == edge_sharing_preference::agnostic) && default_weight_sharing)
128 static_assert(!shared_weight_v || (GraphFlavour != graph_flavour::directed));
129 static_assert((GraphFlavour == graph_flavour::directed) || std::is_empty_v<EdgeMetaData> || std::is_empty_v<EdgeWeight> || shared_weight_v);
131 using handler_type = shared_to_handler_t<shared_weight_v, EdgeWeight>;
132 using edge_type = flavour_to_edge_t<GraphFlavour, handler_type, EdgeMetaData, IndexType>;
133 using storage_type = EdgeStorageConfig::template storage_type<edge_type>;
138 graph_flavour GraphFlavour,
141 std::integral IndexType,
142 class EdgeStorageConfig
144 using edge_storage_generator_t =
typename edge_storage_generator<GraphFlavour, EdgeWeight, EdgeMetaData, IndexType, EdgeStorageConfig>::storage_type;
147 inline constexpr bool has_reservable_partitions =
requires(T& t) {
148 t.reserve_partition(0, 0);
Various edge types for use by graphs.
Structs to enable homogenous treatment of data which is/is not handled via shared pointers.
Decoration of a partial_edge to record the location on the target node into which the edge is embedde...
Definition: Edge.hpp:328
A concrete edge containing a target index and, optionally, a weight.
Definition: Edge.hpp:303
Definition: HandlerTraits.hpp:20
Definition: GraphDetails.hpp:39
Definition: GraphDetails.hpp:114
Definition: GraphDetails.hpp:90