Skip to content

Commit b03d67e

Browse files
committed
add optional unobserved_links param to some mrrms
1 parent 940782e commit b03d67e

File tree

4 files changed

+118
-3
lines changed

4 files changed

+118
-3
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ include(FetchContent)
99
FetchContent_Declare(
1010
reticula
1111
GIT_REPOSITORY https://github.com/reticula-network/reticula.git
12-
GIT_TAG a349e8771342ac689ce38d64d3936b80b46c75ce)
12+
GIT_TAG 5152713c036c9801c8e309d784cf19dadb589b98)
1313

1414
FetchContent_Declare(
1515
fmt

docs/shuffling/link.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ Connected link shuffling
4040

4141
.. py:function:: microcanonical_reference_models.connected_link_shuffling(\
4242
temporal_network, random_state)
43+
:no-index:
44+
45+
.. py:function:: microcanonical_reference_models.connected_link_shuffling(\
46+
temporal_network, random_state, unobserved_links: list)
4347
4448
.. tab-item:: C++
4549
:sync: cpp
@@ -51,6 +55,15 @@ Connected link shuffling
5155
microcanonical_reference_models::connected_link_shuffling(\
5256
const network<EdgeT>& temp, Gen& generator)
5357

58+
.. cpp:function:: template <temporal_network_edge EdgeT, \
59+
std::uniform_random_bit_generator Gen> \
60+
requires is_dyadic_v<EdgeT> \
61+
network<EdgeT> \
62+
microcanonical_reference_models::connected_link_shuffling(\
63+
const network<EdgeT>& temp, Gen& generator, \
64+
const std::vector<typename EdgeT::StaticProjectionType>& \
65+
unobserved_links)
66+
5467
Produces a random shuffling of the temporal network where all events between two
5568
vertices are attributed to two randomly selected vertices from the original
5669
network. As opposed to `Link shuffling`, this model preserves the pattern of
@@ -60,6 +73,13 @@ components as the input. Generalisation of the micocanonical reference model
6073
with the canonical name :math:`P[I_\lambda, p_{\mathcal{L}}(\Theta)]` to
6174
temporal networks with directed and/or multi-component static projections.
6275

76+
The observed static projection links in the network are complemented by the set
77+
of links passed through the parameter `unobserved_links`. This is used in case
78+
links are omitted in the static projection of the observed temporal network
79+
that are known to exist from other sources. Essentially, it is assumed that the
80+
links in `unobserved_links` would be present in the static projection of the
81+
temporal network had we had a long enough observation window.
82+
6383
In addition to the set of components of the static projection, the set of
6484
vertices, timestamps, the number of events and the multiset of timelines
6585
of the temporal network are conserved.
@@ -75,6 +95,11 @@ Topology-constrained link shuffling
7595
.. py:function:: \
7696
microcanonical_reference_models.topology_constrained_link_shuffling(\
7797
temporal_network, random_state)
98+
:no-index:
99+
100+
.. py:function:: \
101+
microcanonical_reference_models.topology_constrained_link_shuffling(\
102+
temporal_network, random_state, unobserved_links: list)
78103

79104
.. tab-item:: C++
80105
:sync: cpp
@@ -86,11 +111,27 @@ Topology-constrained link shuffling
86111
microcanonical_reference_models::topology_constrained_link_shuffling(\
87112
const network<EdgeT>& temp, Gen& generator)
88113

114+
.. cpp:function:: template <temporal_network_edge EdgeT, \
115+
std::uniform_random_bit_generator Gen> \
116+
requires is_dyadic_v<EdgeT> \
117+
network<EdgeT> \
118+
microcanonical_reference_models::topology_constrained_link_shuffling(\
119+
const network<EdgeT>& temp, Gen& generator, \
120+
const std::vector<typename EdgeT::StaticProjectionType>& \
121+
unobserved_links)
122+
89123

90124
Produces a random shuffling of the temporal network where the events are
91125
shuffled by assigning new, uniformly random timetamps and moving it to a
92126
randomly selected link with a non-empty timeline. Equivalent to micocanonical
93127
reference model with the canonical name :math:`P[\mathcal{L}, E]`.
94128

129+
The observed static projection links in the network are complemented by the set
130+
of links passed through the parameter `unobserved_links`. This is used in case
131+
links are omitted in the static projection of the observed temporal network
132+
that are known to exist from other sources. Essentially, it is assumed that the
133+
links in `unobserved_links` would be present in the static projection of the
134+
temporal network had we had a long enough observation window.
135+
95136
The set of vertices, total number of events and the static projection of the
96137
temporal network are conserved.

docs/shuffling/timeline.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,19 @@ Timeline shuffling
1111

1212
.. py:function:: microcanonical_reference_models.timeline_shuffling(\
1313
temporal_network, random_state)
14+
:no-index:
1415

1516
.. py:function:: microcanonical_reference_models.timeline_shuffling(\
1617
temporal_network, random_state, t_start, t_end)
18+
:no-index:
19+
20+
.. py:function:: microcanonical_reference_models.timeline_shuffling(\
21+
temporal_network, random_state, unobserved_links: list)
22+
:no-index:
23+
24+
.. py:function:: microcanonical_reference_models.timeline_shuffling(\
25+
temporal_network, random_state, t_start, t_end, unobserved_links: list)
26+
:no-index:
1727

1828
.. tab-item:: C++
1929
:sync: cpp
@@ -33,6 +43,26 @@ Timeline shuffling
3343
const network<EdgeT>& temp, Gen& generator, \
3444
typename EdgeT::TimeType t_start, typename EdgeT::TimeType t_end);
3545

46+
.. cpp:function:: template <temporal_network_edge EdgeT, \
47+
std::uniform_random_bit_generator Gen> \
48+
requires is_dyadic_v<EdgeT> \
49+
network<EdgeT> \
50+
microcanonical_reference_models::timeline_shuffling(\
51+
const network<EdgeT>& temp, Gen& generator, \
52+
const std::vector<typename EdgeT::StaticProjectionType>& \
53+
unobserved_links);
54+
55+
.. cpp:function:: template <temporal_network_edge EdgeT, \
56+
std::uniform_random_bit_generator Gen> \
57+
requires is_dyadic_v<EdgeT> \
58+
network<EdgeT> \
59+
microcanonical_reference_models::timeline_shuffling(\
60+
const network<EdgeT>& temp, Gen& generator, \
61+
typename EdgeT::TimeType t_start, typename EdgeT::TimeType t_end, \
62+
const std::vector<typename EdgeT::StaticProjectionType>& \
63+
unobserved_links);
64+
65+
3666
Produces a random shuffling of the temporal network where the events are
3767
shuffled by assigning new, uniformly random timetamps and moving it to a
3868
randomly selected link with a non-empty timeline. Equivalent to the
@@ -46,6 +76,13 @@ maximum cause time of all the events to automatically set values for parameters
4676
:cpp:`t_start` and :cpp:`t_end`, for cases where information about observation
4777
window is not available.
4878

79+
The observed static projection links in the network are complemented by the set
80+
of links passed through the parameter `unobserved_links`. This is used in case
81+
links are omitted in the static projection of the observed temporal network
82+
that are known to exist from other sources. Essentially, it is assumed that the
83+
links in `unobserved_links` would be present in the static projection of the
84+
temporal network had we had a long enough observation window.
85+
4986
The set of vertices, total number of events and the static projection of
5087
the temporal network are conserved.
5188

src/temporal_microcanonical_reference_models.cpp

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,53 @@ struct declare_temporal_mrrm_algorithms {
1616
&reticula::mrrms::instant_event_shuffling<EdgeT, Gen>,
1717
"temporal_network"_a, "random_state"_a,
1818
nb::call_guard<nb::gil_scoped_release>());
19+
1920
m.def("link_shuffling",
2021
&reticula::mrrms::link_shuffling<EdgeT, Gen>,
2122
"temporal_network"_a, "random_state"_a,
2223
nb::call_guard<nb::gil_scoped_release>());
24+
2325
m.def("connected_link_shuffling",
24-
&reticula::mrrms::connected_link_shuffling<EdgeT, Gen>,
26+
nb::overload_cast<const reticula::network<EdgeT>&, Gen&>(
27+
&reticula::mrrms::connected_link_shuffling<EdgeT, Gen>),
2528
"temporal_network"_a, "random_state"_a,
2629
nb::call_guard<nb::gil_scoped_release>());
30+
m.def("connected_link_shuffling",
31+
nb::overload_cast<const reticula::network<EdgeT>&, Gen&,
32+
const std::vector<typename EdgeT::StaticProjectionType>&>(
33+
&reticula::mrrms::connected_link_shuffling<EdgeT, Gen >),
34+
"temporal_network"_a, "random_state"_a, "unobserved_links"_a,
35+
nb::call_guard<nb::gil_scoped_release>());
36+
2737
m.def("topology_constrained_link_shuffling",
28-
&reticula::mrrms::topology_constrained_link_shuffling<EdgeT, Gen>,
38+
nb::overload_cast<const reticula::network<EdgeT>&, Gen&>(
39+
&reticula::mrrms::topology_constrained_link_shuffling<EdgeT, Gen>),
2940
"temporal_network"_a, "random_state"_a,
3041
nb::call_guard<nb::gil_scoped_release>());
42+
m.def("topology_constrained_link_shuffling",
43+
nb::overload_cast<const reticula::network<EdgeT>&, Gen&,
44+
const std::vector<typename EdgeT::StaticProjectionType>&>(
45+
&reticula::mrrms::topology_constrained_link_shuffling<EdgeT, Gen>),
46+
"temporal_network"_a, "random_state"_a, "unordered_links"_a,
47+
nb::call_guard<nb::gil_scoped_release>());
3148

49+
50+
m.def("timeline_shuffling",
51+
nb::overload_cast<
52+
const reticula::network<EdgeT>&, Gen&,
53+
typename EdgeT::TimeType, typename EdgeT::TimeType,
54+
const std::vector<typename EdgeT::StaticProjectionType>&>(
55+
&reticula::mrrms::timeline_shuffling<EdgeT, Gen>),
56+
"temporal_network"_a, "random_state"_a,
57+
"t_start"_a, "t_end"_a, "unobserved_links"_a,
58+
nb::call_guard<nb::gil_scoped_release>());
59+
m.def("timeline_shuffling",
60+
nb::overload_cast<
61+
const reticula::network<EdgeT>&, Gen&,
62+
const std::vector<typename EdgeT::StaticProjectionType>&>(
63+
&reticula::mrrms::timeline_shuffling<EdgeT, Gen>),
64+
"temporal_network"_a, "random_state"_a, "unobserved_links"_a,
65+
nb::call_guard<nb::gil_scoped_release>());
3266
m.def("timeline_shuffling",
3367
nb::overload_cast<
3468
const reticula::network<EdgeT>&, Gen&,
@@ -41,6 +75,7 @@ struct declare_temporal_mrrm_algorithms {
4175
&reticula::mrrms::timeline_shuffling<EdgeT, Gen>),
4276
"temporal_network"_a, "random_state"_a,
4377
nb::call_guard<nb::gil_scoped_release>());
78+
4479
m.def("weight_constrained_timeline_shuffling",
4580
nb::overload_cast<
4681
const reticula::network<EdgeT>&, Gen&,
@@ -53,10 +88,12 @@ struct declare_temporal_mrrm_algorithms {
5388
&reticula::mrrms::weight_constrained_timeline_shuffling<EdgeT, Gen>),
5489
"temporal_network"_a, "random_state"_a,
5590
nb::call_guard<nb::gil_scoped_release>());
91+
5692
m.def("activity_constrained_timeline_shuffling",
5793
&reticula::mrrms::activity_constrained_timeline_shuffling<EdgeT, Gen>,
5894
"temporal_network"_a, "random_state"_a,
5995
nb::call_guard<nb::gil_scoped_release>());
96+
6097
m.def("inter_event_shuffling",
6198
&reticula::mrrms::inter_event_shuffling<EdgeT, Gen>,
6299
"temporal_network"_a, "random_state"_a,

0 commit comments

Comments
 (0)