Skip to content

Commit

Permalink
Merge pull request #27 from ComplexData-MILA/dtdg
Browse files Browse the repository at this point in the history
Update with README
  • Loading branch information
shenyangHuang authored Feb 13, 2024
2 parents bf47a29 + 1f26ac5 commit e3c7636
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tgx/classes/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,22 @@ def max_nid(self) -> int:
max_id = u
if v > max_id:
max_id = v
return max_id + 1 #offset by 1
return max_id #offset by 1

def min_nid(self) -> int:
r"""
find the smallest node ID in the dataset
"""
edgelist = self.data
min_id = 1000000000
for _, edge_data in edgelist.items():
for u,v in edge_data.keys():
if u < min_id:
min_id = u
if v < min_id:
min_id = v
return min_id #offset by 1


def map_nid(self) -> dict:
r"""
Expand Down
3 changes: 3 additions & 0 deletions tgx/utils/graph_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
SEC_IN_WEEK = 86400 * 7
SEC_IN_MONTH = 86400 * 30
SEC_IN_YEAR = 86400 * 365
SEC_IN_BIYEARLY = 86400 * 365 * 2

# helper function to do ceiling divison, i.e. 5/2 = 3
def ceiling_division(n, d):
Expand Down Expand Up @@ -57,6 +58,8 @@ def discretize_edges(edgelist: dict,
interval_size = SEC_IN_MONTH
elif time_scale == "yearly":
interval_size = SEC_IN_YEAR
elif time_scale == "biyearly":
interval_size = SEC_IN_BIYEARLY
else:
raise TypeError("Invalid time interval")
else:
Expand Down

0 comments on commit e3c7636

Please sign in to comment.