Skip to content

Conversation

ChuckHastings
Copy link
Collaborator

@ChuckHastings ChuckHastings commented Sep 25, 2025

Closes #5040.

Update temporal sampling to support the following variations:

  • STRICTLY_INCREASING - time of next edge > time of previous edge
  • MONOTONICALLY_INCREASING - time of next edge >= time of previous edge. ** OLD default behavior
  • STRICTLY_DECREASING - time of next edge < time of previous edge
  • MONOTONICALLY_DECREASING - time of next edge <= time of previous edge

This PR includes C++ tests and C API tests.

Marked as breaking as we add a parameter to the C++ temporal sampling function, although it can be defaulted so it's only breaking for code that specifies do_expensive_check.

Copy link

copy-pr-bot bot commented Sep 25, 2025

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@ChuckHastings ChuckHastings self-assigned this Sep 25, 2025
@ChuckHastings ChuckHastings added improvement Improvement / enhancement to an existing function breaking Breaking change labels Sep 25, 2025
@ChuckHastings ChuckHastings marked this pull request as ready for review September 25, 2025 22:50
@ChuckHastings ChuckHastings requested a review from a team as a code owner September 25, 2025 22:50
Copy link
Contributor

@seunghwak seunghwak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except for few cosmetic issues.

STRICTLY_DECREASING, /** Time strictly decreasing (each time is before the previous one) */
MONOTONICALLY_DECREASING, /** Time monotonically decreasing (could have multiple edges with same
time) */
LAST /** Support last n behavior */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LAST /** Support last n behavior */

This sounds vague to me.

Isn't this something like NUM_COMPARISON_TYPES? (basically the number of supported temporal sampling comparison methods/modes/types... and so o n)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the end of the enum. It's actually to support a feature that will be implemented later called "last n".

If LAST is specified, the software will (eventually, not part of this PR) use the fanout value (call it n) and instead of randomly selecting n edges that leave this vertex it will select the n edges with the largest time stamps. You can think of this as sorting the outgoing edges by time and selecting the "last n" of them.

This is a feature that we'll add later (perhaps later in 25.12, perhaps not until 26.01, not sure of the priorities and how far we'll progress).

temporal_sampling_comparison =
cugraph::temporal_sampling_comparison_t::MONOTONICALLY_DECREASING;
break;
default: CUGRAPH_FAIL("Invalid temporal sampling comparison type");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auto temporal_sampling_comparison = options_.temporal_sampling_comparison_;

Won't this work?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're converting between types here. I'm hesitant to assume that translating from the C enum definition in the .h file to the C++ enum class definition in the .hpp file is guaranteed to work by assignment. This was my simple solution.

options_.dedupe_sources_,
options_.with_replacement_},
options_.with_replacement_,
temporal_sampling_comparison},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or can we just call this with options_.temporal_sampling_comparison_? Why are we creating a temporary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type conversion as mentioned above

return (edge_time < key_time);
case temporal_sampling_comparison_t::MONOTONICALLY_DECREASING:
return (edge_time <= key_time);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert(false); // never be reached I assume this part should never be reached...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make that change.

return (edge_time < key_time);
case temporal_sampling_comparison_t::MONOTONICALLY_DECREASING:
return (edge_time <= key_time);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

assert(false); // never be reached

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make that change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Breaking change improvement Improvement / enhancement to an existing function
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Temporal Sampling - Support > and >= Temporal Constraints in C/C++/PLC API
3 participants