Skip to content

Commit

Permalink
update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
rshirzadkhani committed Nov 10, 2023
1 parent 0b56d0c commit ad65862
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 274 deletions.
Binary file modified docs/gallery/0-tet-tgb.md
Binary file not shown.
207 changes: 0 additions & 207 deletions examples/test.py

This file was deleted.

18 changes: 0 additions & 18 deletions examples/test_package1.py

This file was deleted.

16 changes: 11 additions & 5 deletions examples/test_package2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@
data_path = '/network/scratch/r/razieh.shirzadkhani/'
Plot_path = "./docs/gallery/node_edge"

dataset = tgx.builtin.reddit(root = data_path)
dataset1 = tgx.builtin.uci(root = data_path)
dataset = tgx.tgb_data("tgbl-wiki")
G = tgx.Graph(dataset)
new_G = G.discretize(intervals=dataset.intervals)
# new_G.count_freq()
# tgx.TEA(G, filepath = Plot_path, network_name=dataset.name)
# tgx.TET(G, filepath = Plot_path, network_name=dataset.name)
# tgx.degree_over_time(new_G, filepath= Plot_path, network_name=dataset.name)
tgx.nodes_and_edges_over_time(new_G, filepath= Plot_path, network_name=dataset.name)
tgx.TEA(new_G, filepath = Plot_path, network_name=dataset.name)
tgx.TET(new_G, filepath = Plot_path, network_name=dataset.name)
tgx.degree_over_time(new_G, filepath= Plot_path, network_name=dataset.name)
tgx.nodes_over_time(new_G, filepath= Plot_path, network_name=dataset.name)
tgx.nodes_and_edges_over_time(new_G, filepath= Plot_path, network_name=dataset.name)
tgx.get_reoccurrence(new_G)
tgx.get_surprise(new_G)
tgx.get_novelty(new_G)
tgx.get_avg_node_activity(new_G)
Binary file modified tgx/classes/__pycache__/graph.cpython-39.pyc
Binary file not shown.
20 changes: 17 additions & 3 deletions tgx/classes/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ def __init__(self,
discretized: whether the given edgelist was discretized or not
"""

if dataset is not None and isinstance(dataset, type):
self.data = read_csv(dataset)
if dataset is not None:
if isinstance(dataset, type) or isinstance(dataset,object):
self.data = read_csv(dataset)
elif fname is not None and isinstance(fname, str):
self.data = read_csv(fname)
elif edgelist is not None and isinstance(edgelist, dict):
Expand Down Expand Up @@ -60,6 +61,19 @@ def number_of_edges(self) -> int:

return e_num

def unique_edges(self) -> int:
r"""
Calculate the number of unique edges
Parameters:
graph_edgelist: Dictionary containing graph data
"""
unique_edges = {}
for _, e_list in self.data.items():
for e in e_list:
if e not in unique_edges:
unique_edges[e] = 1
return len(unique_edges)

def total_nodes(self) -> int:
r"""
Calculate total number of nodes present in an edgelist
Expand All @@ -80,7 +94,7 @@ def node_per_ts(self):
active_nodes = {}
for ts in range(len(self.data)):
edgelist_t = self.data[ts]
active_nodes.append(self._count_node(edgelist_t))
active_nodes.append(self.edgelist_node_count(edgelist_t))
return active_nodes

def edgelist_node_count(self, edge_data: list):
Expand Down
6 changes: 0 additions & 6 deletions tgx/data/builtin.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import pandas as pd
import numpy as np
import requests
from clint.textui import progress
import os, io
import shutil
import sys
import zipfile
import urllib

Expand Down
12 changes: 7 additions & 5 deletions tgx/data/tgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ def __init__(self, dname: str,
from here: https://zenodo.org/record/7213796#.Y1cO6y8r30o
and locate them in ./data/ directory.
"""
return self.tgb(dname,
edge_feat = edge_feat,
w = w,
edge_label = edge_label,
edge_idxs = edge_idxs)
self.tgb(dname,
edge_feat = edge_feat,
w = w,
edge_label = edge_label,
edge_idxs = edge_idxs)

return

@classmethod
def tgb(self, dname: str,
Expand Down
2 changes: 1 addition & 1 deletion tgx/io/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def read_csv(fname: Union[str, object] = None,

cols_to_read = [u_col, v_col, t_col]

if isinstance(fname, type):
if isinstance(fname, type) or isinstance(fname, object):
return _datasets_edgelist_loader(fname.data)
elif isinstance(fname, str):
return _load_edgelist(fname, cols_to_read, header=header)
Expand Down
Loading

0 comments on commit ad65862

Please sign in to comment.