Skip to content

Comments

Implement an API for temporal graphs#4

Merged
MarcT0K merged 5 commits intomasterfrom
temporal-graph
Feb 18, 2026
Merged

Implement an API for temporal graphs#4
MarcT0K merged 5 commits intomasterfrom
temporal-graph

Conversation

@MarcT0K
Copy link
Owner

@MarcT0K MarcT0K commented Feb 12, 2026

This PR adds a new API point to return a temporal graph based on index or date range.

See #2 and #3 for more motivations behind the PR.

Resolves #3 .

@MarcT0K
Copy link
Owner Author

MarcT0K commented Feb 12, 2026

Hi @colltoaction,
As promised, here is the PR adding support for temporal graphs. Sorry, I have been really busy during the last two months, but the feature is finally there.

The new API point is quite straightforward: it is the same as classic graphs, except that we provide date/index ranges instead of a single date/index. The list of ranges is directly loaded in networkx-temporal using from_snapshots.

Tell me what you think about it. If you see any possible improvement, tell me and I would be glad to implement it. 😃

@colltoaction
Copy link

I'll be happy to test this. @nelsonaloysio I think your review would be very valuable here if you have the time.

Thank you for considering this idea!

@nelsonaloysio
Copy link

Looks great! The temporal implementation using from_snapshots is straightforward and since edges only have a weight attribute (unique to each edge), avoiding a slice strategy makes sense as it would just add overhead.

On an unrelated note, I've noticed that nx.Graph (or DiGraph) objects are used to build the networks on get_graph calls, which causes parallel edges among node pairs on the same query date to be discarded. I don't know the data, so I can't tell if this is intentional, but if not I would suggest replacing it with MultiGraph and MultiDiGraph instead.

For example, calling loader.get_graph("peertube", "follow", date="20250414") returns (before/after change):

DiGraph with 893 nodes and 16423 edges
MultiDiGraph with 893 nodes and 16796 edges

(Note that with this change some graphs in the test units would change their size, like in this case.)

@MarcT0K
Copy link
Owner Author

MarcT0K commented Feb 17, 2026

@nelsonaloysio Thanks for the feedback! If you or @colltoaction has no further suggestion or remark, I'll merge this feature and release a new version of the package. I would remain available to do anything that could simplify its integration in networkx-temporal

@MarcT0K
Copy link
Owner Author

MarcT0K commented Feb 17, 2026

@nelsonaloysio Your unrelated note is really interesting because it may have identified a slight data cleaning issue. In short, there should be no parallel edges, so multigraph are unnecessary. However, there is clearly a small issue in the Peertube graph of 14/04/2025 because the data cleaning should have removed duplicate edges.

Thus, I will stick to single graph because the dataset is supposed to contain no parallel edges. I am also checking the full dataset to identify other graphs with duplicates edges. So, far the graph you found is the only one with the issue so it is a really good catch! Thanks again.

@MarcT0K MarcT0K merged commit 71b6b60 into master Feb 18, 2026
3 checks passed
@MarcT0K MarcT0K deleted the temporal-graph branch February 18, 2026 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for temporal graphs

3 participants