Skip to content

Commit

Permalink
Merge pull request #22 from ComplexData-MILA/dtdg
Browse files Browse the repository at this point in the history
Dtdg
  • Loading branch information
shenyangHuang authored Jan 21, 2024
2 parents 689d1bc + 34a4d7e commit 9b5076f
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 3 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Temporal Graph Analysis with TGX (to appear in WSDM 2024)


### Example Usage ###
TGX provides many built in datasets as well as supporting TGB datasets. In addition, TGX provides dataset discretization and visualization.
To get started, see our [starting example](https://github.com/ComplexData-MILA/TGX/blob/master/starting_example.py)
```
python starting_example.py -d tgbl-wiki -t daily
```


### Install dependency
Our implementation works with python >= 3.9 and can be installed as follows

Expand Down
5 changes: 3 additions & 2 deletions examples/data_viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
# Number of Connected Components
tgx.connected_components_per_ts(dtdg, network_name=dataset.name)

# Degree Density
tgx.degree_density(dtdg, k=3, network_name=dataset.name)

# Size of Largest Connected Component
component_sizes = tgx.size_connected_components(dtdg)
largest_component_sizes = [max(inner_list) if inner_list else 0 for inner_list in component_sizes]
Expand All @@ -57,5 +60,3 @@
filename = f"{dataset.name}_average_node_engagement"
plot_for_snapshots(engagements, y_title="Average Engagement", filename="./"+filename)

# Degree Density
tgx.degree_density(dtdg, k=3, network_name=dataset.name)
47 changes: 46 additions & 1 deletion starting_example.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import tgx
from tgx.utils.plotting_utils import plot_for_snapshots
import argparse
import sys

Expand Down Expand Up @@ -29,6 +30,50 @@ def get_args():
# ctdg.save2csv("ctdg") #! save the graph to csv files

time_scale = args.time #"minutely" #"monthly" #"weekly" #"daily" #"hourly"
dtdg = ctdg.discretize(time_scale=time_scale)
dtdg = ctdg.discretize(time_scale=time_scale)[0]
print ("discretize to ", time_scale)



#* plotting the statistics
tgx.degree_over_time(dtdg, network_name=dataset.name)
tgx.nodes_over_time(dtdg, network_name=dataset.name)
tgx.edges_over_time(dtdg, network_name=dataset.name)
tgx.nodes_and_edges_over_time(dtdg, network_name=dataset.name)

tgx.TET(dtdg,
network_name=dataset.name,
figsize = (9, 5),
axis_title_font_size = 24,
ticks_font_size = 24)


tgx.TEA(dtdg,
network_name=dataset.name)



#* compute statistics
test_ratio = 0.15
tgx.get_reoccurrence(ctdg, test_ratio=test_ratio)
tgx.get_surprise(ctdg, test_ratio=test_ratio)
tgx.get_novelty(dtdg)


# Number of Connected Components
tgx.connected_components_per_ts(dtdg, network_name=dataset.name)

# Degree Density
tgx.degree_density(dtdg, k=3, network_name=dataset.name)

# Size of Largest Connected Component
component_sizes = tgx.size_connected_components(dtdg)
largest_component_sizes = [max(inner_list) if inner_list else 0 for inner_list in component_sizes]
filename = f"{dataset.name}_largest_connected_component_size"
plot_for_snapshots(largest_component_sizes, y_title="Size of Largest Connected Component", filename="./"+filename)

# Average Node Engagement
engagements = tgx.get_avg_node_engagement(dtdg)
filename = f"{dataset.name}_average_node_engagement"
plot_for_snapshots(engagements, y_title="Average Engagement", filename="./"+filename)

0 comments on commit 9b5076f

Please sign in to comment.