Skip to content

Commit

Permalink
Merge pull request #80 from stdgraph/el_rng
Browse files Browse the repository at this point in the history
El rng
  • Loading branch information
pratzl committed Dec 1, 2023
2 parents c48865c + 546d11f commit b735e7a
Show file tree
Hide file tree
Showing 3 changed files with 527 additions and 76 deletions.
14 changes: 12 additions & 2 deletions include/graph/graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* @ingroup general_concepts
*/

#define ENABLE_EDGELIST_RANGE

#include <ranges>
#include <concepts>
#include <type_traits>
Expand All @@ -41,16 +43,16 @@
// VR Vertex Range
// VI ui,vi Vertex Iterator
// VVF Vertex Value Function: vvf(u) -> value
// VVP vvp Vertex Value Projection function vvp(x) --> vertex_descriptor<>
//
// E Edge type
// uv,vw Edge reference
// EV Edge Value (user-defined or void)
// ER Edge Range
// EI uvi,vwi Edge iterator
// EVF evf Edge Value Function: evf(uv) -> value
// EVP evp Edge Value Production function: evp(y) -> edge_descriptor<>
//
// ELR elr Edge List Range; an arbitrary range where its values can be projected to be an edge_descriptor.
// Proj proj Projection function: proj(y) -> edge_descriptor<...>, where y is the value type of an ELR

#ifndef GRAPH_HPP
# define GRAPH_HPP
Expand Down Expand Up @@ -203,6 +205,14 @@ template <class G>
concept sourced_adjacency_list =
adjacency_list<G> && sourced_edge<G, edge_t<G>> && requires(G&& g, edge_reference_t<G> uv) { edge_id(g, uv); };


# ifdef ENABLE_EDGELIST_RANGE
template <class ELR>
concept basic_edgelist_range = ranges::forward_range<ELR> && negation_v<index_adjacency_list<ELR>>;
template <class ELR>
concept edgelist_range = ranges::forward_range<ELR> && negation_v<adjacency_list<ELR>>;
# endif

//
// property concepts
//
Expand Down
40 changes: 40 additions & 0 deletions include/graph/graph_descriptors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ using copyable_vertex_t = vertex_descriptor<VId, void, VV>; // {id, value}
//
template <class VId, bool Sourced, class E, class EV>
struct edge_descriptor {
using source_id_type = VId;
using target_id_type = VId;
using edge_type = E;
using value_type = EV;

VId source_id;
VId target_id;
E edge;
Expand All @@ -49,41 +54,76 @@ struct edge_descriptor {

template <class VId, class E>
struct edge_descriptor<VId, true, E, void> {
using source_id_type = VId;
using target_id_type = VId;
using edge_type = E;
using value_type = void;

VId source_id;
VId target_id;
E edge;
};
template <class VId>
struct edge_descriptor<VId, true, void, void> {
using source_id_type = VId;
using target_id_type = VId;
using edge_type = void;
using value_type = void;

VId source_id;
VId target_id;
};
template <class VId, class EV>
struct edge_descriptor<VId, true, void, EV> {
using source_id_type = VId;
using target_id_type = VId;
using edge_type = void;
using value_type = EV;

VId source_id;
VId target_id;
EV value;
};

template <class VId, class E, class EV>
struct edge_descriptor<VId, false, E, EV> {
using source_id_type = void;
using target_id_type = VId;
using edge_type = void;
using value_type = EV;

VId target_id;
E edge;
EV value;
};
template <class VId, class E>
struct edge_descriptor<VId, false, E, void> {
using source_id_type = void;
using target_id_type = VId;
using edge_type = E;
using value_type = void;

VId target_id;
E edge;
};

template <class VId, class EV>
struct edge_descriptor<VId, false, void, EV> {
using source_id_type = void;
using target_id_type = VId;
using edge_type = void;
using value_type = EV;

VId target_id;
EV value;
};
template <class VId>
struct edge_descriptor<VId, false, void, void> {
using source_id_type = void;
using target_id_type = VId;
using edge_type = void;
using value_type = void;

VId target_id;
};

Expand Down
Loading

0 comments on commit b735e7a

Please sign in to comment.