Skip to content

Commit

Permalink
updte data dist for shortest path distribution for only citation2
Browse files Browse the repository at this point in the history
  • Loading branch information
cc7738@kit.edu committed Jun 10, 2024
1 parent 0b8bee2 commit 2454da6
Show file tree
Hide file tree
Showing 6 changed files with 785 additions and 3,122 deletions.
14 changes: 14 additions & 0 deletions core/graphgps/utility/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -954,3 +954,17 @@ def analyse_hyper(file_path: str):
best_combination_df = pd.DataFrame(best_combination).transpose()
best_combination_df.to_csv('best_hyperparameter_combination.csv', index=False)
return


import time
import random

def timeit(func):
def wrapper(*args, **kwargs):
start = time.perf_counter()
result = func(*args, **kwargs)
end = time.perf_counter()
elapsed = end - start
print(f'Time taken: {elapsed:.6f} seconds')
return result
return wrapper
14 changes: 7 additions & 7 deletions core/heuristic/cora_heuristic.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,18 @@ def eval_cora_acc() -> None:
test_pct = 0.05,
split_labels = False
)
test_split = splits['test']
labels = test_split.edge_label
test_index = test_split.edge_label_index

labels = splits['test'].edge_label
test_index = splits['test'].edge_label_index

edge_index = splits['test'].edge_index
edge_weight = torch.ones(edge_index.size(1))
test_edge_index = splits['test'].edge_index
edge_weight = torch.ones(test_edge_index.size(1))
num_nodes = dataset._data.num_nodes

m = construct_sparse_adj(edge_index)
m = construct_sparse_adj(test_edge_index)
plot_coo_matrix(m, f'cora_test_edge_index.png')

A = ssp.csr_matrix((edge_weight.view(-1), (edge_index[0], edge_index[1])), shape=(num_nodes, num_nodes))
A = ssp.csr_matrix((edge_weight.view(-1), (test_edge_index[0], test_edge_index[1])), shape=(num_nodes, num_nodes))

result_acc = {}
for use_lsf in ['CN', 'AA', 'RA', 'InverseRA']:
Expand Down
1 change: 1 addition & 0 deletions core/heuristic/gsf.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def shortest_path(A, edge_index, remove=False):
print(f'evaluated shortest path for {len(scores)} edges')
return torch.FloatTensor(scores)


def katz_apro(A, edge_index, beta=0.005, path_len=3, remove=False):

scores = []
Expand Down
279 changes: 173 additions & 106 deletions core/ipynbs/data_dist.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit 2454da6

Please # to comment.