Skip to content

Commit

Permalink
revert and make sure verts are def. constructible
Browse files Browse the repository at this point in the history
  • Loading branch information
arashbm committed Nov 19, 2023
1 parent 88f8eb7 commit c5122c2
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 19 deletions.
1 change: 1 addition & 0 deletions include/reticula/network_concepts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace reticula {

template <typename T>
concept network_vertex =
std::default_initializable<T> &&
std::totally_ordered<T> &&
hashable_with<T, hash>;

Expand Down
8 changes: 3 additions & 5 deletions include/reticula/static_edges.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace reticula {
or the relation.
@param v2 Head end of the edge, often the receiving end of an effect.
*/
directed_edge(VertexType v1, VertexType v2);
directed_edge(const VertexType& v1, const VertexType& v2);


/**
Expand Down Expand Up @@ -213,11 +213,9 @@ namespace reticula {

undirected_edge() = default;
/**
Create an undirected edge. Order of the parameters are arbitrary unless
dealing with IO functions. IO functions try to preserve the same order as
of vertices from input string in the output string.
Create an undirected edge. Order of the parameters are arbitrary.
*/
undirected_edge(VertexType v1, VertexType v2);
undirected_edge(const VertexType& v1, const VertexType& v2);

/**
An undirected edge is incident to vertex `v` iff `v` is either of its
Expand Down
6 changes: 3 additions & 3 deletions include/reticula/temporal_edges.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ namespace reticula {
@param time Timestamp at which the event "happened".
*/
directed_temporal_edge(
VertexType tail, VertexType head, TimeType time);
const VertexType& tail, const VertexType& head, TimeType time);
/**
Create a directed temporal edge from a static projection and a time. The
resulting edge would have the same endpoints as projection and the time
Expand Down Expand Up @@ -322,7 +322,7 @@ namespace reticula {
@param effect_time The timestamp at which the event was "received".
*/
directed_delayed_temporal_edge(
VertexType tail, VertexType head,
const VertexType& tail, const VertexType& head,
TimeType cause_time, TimeType effect_time);
/**
Create a directed delayed temporal edge from a static projection, a cause
Expand Down Expand Up @@ -514,7 +514,7 @@ namespace reticula {
@param time Timestamp at which the event "happened".
*/
undirected_temporal_edge(
VertexType v1, VertexType v2, TimeType time);
const VertexType& v1, const VertexType& v2, TimeType time);
/**
Create an undirected temporal edge from a static projection and a time.
The resulting edge would have the same endpoints as projection and the
Expand Down
10 changes: 5 additions & 5 deletions src/static_edges.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ namespace reticula {
// properties of directed edge:

template <network_vertex VertexType>
directed_edge<VertexType>::directed_edge(VertexType tail, VertexType head)
directed_edge<VertexType>::directed_edge(
const VertexType& tail, const VertexType& head)
: _tail(tail), _head(head) {}

template <network_vertex VertexType>
Expand Down Expand Up @@ -146,10 +147,9 @@ namespace reticula {
// properties of undirected edge:

template <network_vertex VertexType>
undirected_edge<VertexType>::undirected_edge(VertexType v1, VertexType v2) {
auto [i, j] = std::minmax(v1, v2);
_v1 = i;
_v2 = j;
undirected_edge<VertexType>::undirected_edge(
const VertexType& v1, const VertexType& v2) {
std::tie(_v1, _v2) = std::minmax(v1, v2);
}

template <network_vertex VertexType>
Expand Down
11 changes: 5 additions & 6 deletions src/temporal_edges.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ namespace reticula {

template <network_vertex VertexType, typename TimeType>
directed_temporal_edge<VertexType, TimeType>::directed_temporal_edge(
VertexType tail, VertexType head, TimeType time)
const VertexType& tail, const VertexType& head, TimeType time)
: _time(time), _tail(tail), _head(head) {}

template <network_vertex VertexType, typename TimeType>
Expand Down Expand Up @@ -209,7 +209,7 @@ namespace reticula {
template <network_vertex VertexType, typename TimeType>
directed_delayed_temporal_edge<VertexType, TimeType>::
directed_delayed_temporal_edge(
VertexType tail, VertexType head,
const VertexType& tail, const VertexType& head,
TimeType cause_time, TimeType effect_time) :
_cause_time(cause_time), _effect_time(effect_time),
_tail(tail), _head(head) {
Expand Down Expand Up @@ -344,10 +344,9 @@ namespace reticula {

template <network_vertex VertexType, typename TimeType>
undirected_temporal_edge<VertexType, TimeType>::undirected_temporal_edge(
VertexType v1, VertexType v2, TimeType time) : _time(time) {
auto [i, j] = std::minmax(v1, v2);
_v1 = i;
_v2 = j;
const VertexType& v1, const VertexType& v2,
TimeType time) : _time(time) {
std::tie(_v1, _v2) = std::minmax(v1, v2);
}

template <network_vertex VertexType, typename TimeType>
Expand Down

0 comments on commit c5122c2

Please sign in to comment.