diff --git a/tgx/classes/graph.py b/tgx/classes/graph.py index cd79fe8..b5afe9a 100644 --- a/tgx/classes/graph.py +++ b/tgx/classes/graph.py @@ -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""" diff --git a/tgx/utils/graph_utils.py b/tgx/utils/graph_utils.py index b9b9023..270809a 100644 --- a/tgx/utils/graph_utils.py +++ b/tgx/utils/graph_utils.py @@ -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): @@ -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: