You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Specialize to std::true_type for directed edge lists
is_directed_v<EL>
false
Convenience variable template
Usage: During graph construction from an edge list, a constructor may add a
reverse edge (B → A) for each forward edge (A → B) when is_directed_v<EL> is
false, producing an undirected graph.
Functions (CPOs)
Edge list CPOs use the shared graph::source_id, graph::target_id, and
graph::edge_value CPOs (defined in graph::detail), which resolve for both
adjacency list edges and edge list edges.
Function
Return Type
Complexity
Default Implementation
source_id(el, uv)
vertex_id_t<EL>
O(1)
Automatic for tuple and edge_descriptor patterns
target_id(el, uv)
vertex_id_t<EL>
O(1)
Automatic for tuple and edge_descriptor patterns
edge_value(el, uv)
edge_value_t<EL>
O(1)
Automatic for 3+-element tuples and edge_descriptor patterns
num_edges(el)
integral
O(1)
std::ranges::size(el)
has_edges(el)
bool
O(1)
num_edges(el) > 0
contains_edge(el, uid, vid)
bool
O(E)
Linear search for matching source_id/target_id
Pattern Matching for Edge Types
The CPOs automatically recognize these element patterns:
Tuple Patterns
Element Type
source_id
target_id
edge_value
tuple<integral, integral>
get<0>
get<1>
n/a
tuple<integral, integral, T>
get<0>
get<1>
get<2>
edge_descriptor Patterns
Element Type
source_id
target_id
edge_value
edge_descriptor<VId, void>
.source_id
.target_id
n/a
edge_descriptor<VId, EV>
.source_id
.target_id
.value
For other edge types, override the CPOs via ADL in the edge type's namespace.
Edge Descriptor
The library provides graph::edge_descriptor<VId, EV> as a convenient edge
element type:
#include<graph/edge_list/edge_list_descriptor.hpp>namespacegraph {
template <classVId, classEV = void>
structedge_descriptor {
VId source_id;
VId target_id;
EV value; // omitted when EV = void
};
}
Example: Using an Edge List
#include<graph/edge_list/edge_list.hpp>
#include<vector>
#include<tuple>// Tuple-based edge list
std::vector<std::tuple<int, int, double>> edges = {
{0, 1, 1.5}, {1, 2, 2.0}, {2, 0, 0.5}
};
static_assert(graph::edge_list::basic_sourced_index_edgelist<decltype(edges)>);
static_assert(graph::edge_list::has_edge_value<decltype(edges)>);
for (auto& e : edges) {
auto s = graph::source_id(edges, e); // get<0>(e)auto t = graph::target_id(edges, e); // get<1>(e)auto w = graph::edge_value(edges, e); // get<2>(e)
}