Skip to content

Commit

Permalink
Updated simulator to use marius
Browse files Browse the repository at this point in the history
  • Loading branch information
Devesh Sarda committed Feb 22, 2024
1 parent 84f9198 commit 57856a1
Show file tree
Hide file tree
Showing 489 changed files with 84 additions and 924 deletions.
Empty file modified .clang-format
100644 → 100755
Empty file.
Empty file modified .flake8
100644 → 100755
Empty file.
Empty file modified .github/ISSUE_TEMPLATE/bug_report.md
100644 → 100755
Empty file.
Empty file modified .github/ISSUE_TEMPLATE/documentation-improvement.md
100644 → 100755
Empty file.
Empty file modified .github/ISSUE_TEMPLATE/feature_request.md
100644 → 100755
Empty file.
Empty file modified .github/ISSUE_TEMPLATE/general-question.md
100644 → 100755
Empty file.
Empty file modified .github/PULL_REQUEST_TEMPLATE/pull_request_template.md
100644 → 100755
Empty file.
Empty file modified .github/workflows/build_and_test.yml
100644 → 100755
Empty file.
Empty file modified .github/workflows/db2graph_test_postgres.yml
100644 → 100755
Empty file.
Empty file modified .github/workflows/lint.yml
100644 → 100755
Empty file.
1 change: 1 addition & 0 deletions .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,4 @@ Thumbs.db


# End of https://www.toptal.com/developers/gitignore/api/python
simulator/datasets
Empty file modified .gitmodules
100644 → 100755
Empty file.
Empty file modified CMakeLists.txt
100644 → 100755
Empty file.
Empty file modified CONTRIBUTING.md
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified MANIFEST.in
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified docs/.nojekyll
100644 → 100755
Empty file.
Empty file modified docs/CMakeLists.txt
100644 → 100755
Empty file.
Empty file modified docs/Doxyfile
100644 → 100755
Empty file.
Empty file modified docs/Doxyfile.in
100644 → 100755
Empty file.
Empty file modified docs/README.md
100644 → 100755
Empty file.
Empty file modified docs/_static/css/marius_theme.css
100644 → 100755
Empty file.
Empty file modified docs/_templates/layout.html
100644 → 100755
Empty file.
Empty file modified docs/assets/configuration_lp.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/assets/configuration_nc.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/assets/marius_arch.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/assets/samples_dismult.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/assets/samples_gs.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/conf.py
100644 → 100755
Empty file.
Empty file modified docs/config_interface/configuration.rst
100644 → 100755
Empty file.
Empty file modified docs/config_interface/full_schema.rst
100644 → 100755
Empty file.
Empty file modified docs/config_interface/index.rst
100644 → 100755
Empty file.
Empty file modified docs/config_interface/samples.rst
100644 → 100755
Empty file.
Empty file modified docs/db2graph/db2graph.rst
100644 → 100755
Empty file.
Empty file modified docs/examples/config/index.rst
100644 → 100755
Empty file.
Empty file modified docs/examples/config/lp_custom.rst
100644 → 100755
Empty file.
Empty file modified docs/examples/config/lp_fb15k237.rst
100644 → 100755
Empty file.
Empty file modified docs/examples/config/lp_paleobiology.rst
100644 → 100755
Empty file.
Empty file modified docs/examples/config/nc_custom.rst
100644 → 100755
Empty file.
Empty file modified docs/examples/config/nc_ogbn_arxiv.rst
100644 → 100755
Empty file.
Empty file modified docs/examples/config/resume_training.rst
100644 → 100755
Empty file.
Empty file modified docs/examples/index.rst
100644 → 100755
Empty file.
Empty file modified docs/examples/introduction.rst
100644 → 100755
Empty file.
Empty file modified docs/examples/prediction/command_line.rst
100644 → 100755
Empty file.
Empty file modified docs/examples/prediction/python.rst
100644 → 100755
Empty file.
Empty file modified docs/examples/preprocessing/command_line.rst
100644 → 100755
Empty file.
Empty file modified docs/examples/preprocessing/python.rst
100644 → 100755
Empty file.
Empty file modified docs/examples/python/index.rst
100644 → 100755
Empty file.
Empty file modified docs/examples/python/lp_custom.rst
100644 → 100755
Empty file.
Empty file modified docs/examples/python/lp_fb15k237.rst
100644 → 100755
Empty file.
Empty file modified docs/examples/python/nc_ogbn_arxiv.rst
100644 → 100755
Empty file.
Empty file modified docs/export_and_inference/index.rst
100644 → 100755
Empty file.
Empty file modified docs/export_and_inference/marius_postprocess.rst
100644 → 100755
Empty file.
Empty file modified docs/export_and_inference/marius_predict.rst
100644 → 100755
Empty file.
Empty file modified docs/favicon.ico
100644 → 100755
Empty file.
Empty file modified docs/graph_learning/decoders.rst
100644 → 100755
Empty file.
Empty file modified docs/graph_learning/downstream_tasks.rst
100644 → 100755
Empty file.
Empty file modified docs/graph_learning/encoders.rst
100644 → 100755
Empty file.
Empty file modified docs/graph_learning/index.rst
100644 → 100755
Empty file.
Empty file modified docs/graph_learning/intro.rst
100644 → 100755
Empty file.
Empty file modified docs/graph_learning/learning_tasks.rst
100644 → 100755
Empty file.
Empty file modified docs/index.rst
100644 → 100755
Empty file.
Empty file modified docs/introduction.rst
100644 → 100755
Empty file.
Empty file modified docs/marius_logo.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/marius_logo.svg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/marius_logo_scaled.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/preprocess_datasets/built_in.rst
100644 → 100755
Empty file.
Empty file modified docs/preprocess_datasets/command_line.rst
100644 → 100755
Empty file.
Empty file modified docs/preprocess_datasets/index.rst
100644 → 100755
Empty file.
Empty file modified docs/preprocess_datasets/python.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/configuration/index.rst
100644 → 100755
Empty file.
11 changes: 0 additions & 11 deletions docs/python_api/data/batch.rst

This file was deleted.

17 changes: 0 additions & 17 deletions docs/python_api/data/dataloader.rst

This file was deleted.

19 changes: 0 additions & 19 deletions docs/python_api/data/dense_graph.rst

This file was deleted.

25 changes: 0 additions & 25 deletions docs/python_api/data/graph.rst

This file was deleted.

13 changes: 0 additions & 13 deletions docs/python_api/data/index.rst

This file was deleted.

9 changes: 0 additions & 9 deletions docs/python_api/data/samplers/edge.rst

This file was deleted.

11 changes: 0 additions & 11 deletions docs/python_api/data/samplers/index.rst

This file was deleted.

9 changes: 0 additions & 9 deletions docs/python_api/data/samplers/negative.rst

This file was deleted.

15 changes: 0 additions & 15 deletions docs/python_api/data/samplers/neighbor.rst

This file was deleted.

Empty file modified docs/python_api/index.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/manager/index.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/nn/activation.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/nn/decoders/decoder.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/nn/decoders/edge/comparators.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/nn/decoders/edge/complex.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/nn/decoders/edge/distmult.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/nn/decoders/edge/edge_decoder.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/nn/decoders/edge/index.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/nn/decoders/edge/relation_operators.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/nn/decoders/edge/transe.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/nn/decoders/index.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/nn/decoders/node/index.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/nn/decoders/node/node_decoder.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/nn/decoders/node/noop_node_decoder.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/nn/encoders/general_encoder.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/nn/encoders/index.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/nn/index.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/nn/initialization.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/nn/layers/embedding.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/nn/layers/feature.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/nn/layers/gnn.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/nn/layers/index.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/nn/layers/layer.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/nn/layers/reduction.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/nn/loss.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/nn/model.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/nn/optim.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/pipeline/evaluator.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/pipeline/graph_encoder.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/pipeline/index.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/pipeline/trainer.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/reporting/index.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/reporting/metrics.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/reporting/reporters.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/storage/graph_storage.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/storage/index.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/storage/storage.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/tools/configuration/constants.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/tools/configuration/datatypes.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/tools/configuration/index.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/tools/configuration/marius_config.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/tools/index.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/tools/preprocess/converters/index.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/tools/preprocess/datasets/index.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/tools/preprocess/index.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/tools/preprocess/partitioners/index.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/tools/preprocess/readers/index.rst
100644 → 100755
Empty file.
Empty file modified docs/python_api/tools/preprocess/writers/index.rst
100644 → 100755
Empty file.
Empty file modified docs/quickstart.rst
100644 → 100755
Empty file.
Empty file modified examples/configuration/custom_lp.yaml
100644 → 100755
Empty file.
Empty file modified examples/configuration/custom_nc.yaml
100644 → 100755
Empty file.
Empty file modified examples/configuration/fb15k_237.yaml
100644 → 100755
Empty file.
Empty file modified examples/configuration/ogbn_arxiv.yaml
100644 → 100755
Empty file.
Empty file modified examples/configuration/sakila.yaml
100644 → 100755
Empty file.
Empty file modified examples/db2graph/dockerfile
100644 → 100755
Empty file.
Empty file modified examples/db2graph/run.sh
100644 → 100755
Empty file.
Empty file modified examples/docker/README.md
100644 → 100755
Empty file.
Empty file modified examples/docker/cpu_ubuntu/dockerfile
100644 → 100755
Empty file.
Empty file modified examples/docker/gpu_ubuntu/dockerfile
100644 → 100755
Empty file.
Empty file modified examples/preprocessing/custom_dataset.py
100644 → 100755
Empty file.
Empty file modified examples/python/custom.py
100644 → 100755
Empty file.
Empty file modified examples/python/custom_lp.py
100644 → 100755
Empty file.
Empty file modified examples/python/custom_nc_graphsage.py
100644 → 100755
Empty file.
Empty file modified examples/python/fb15k_237.py
100644 → 100755
Empty file.
Empty file modified examples/python/fb15k_237_gpu.py
100644 → 100755
Empty file.
Empty file modified examples/python/ogbn_arxiv_nc.py
100644 → 100755
Empty file.
Empty file modified pyproject.toml
100644 → 100755
Empty file.
Empty file modified setup.cfg
100644 → 100755
Empty file.
6 changes: 3 additions & 3 deletions setup.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self, name, sourcedir=""):
class CMakeBuild(build_ext):
def run(self):
try:
_ = subprocess.check_output(["cmake", "--version"])
_ = subprocess.run(["cmake", "--version"])
except OSError:
raise RuntimeError(
"CMake must be installed to build the following extensions: "
Expand Down Expand Up @@ -69,8 +69,8 @@ def build_extension(self, ext):

print(cmake_args)

subprocess.check_call(["cmake", ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env)
subprocess.check_call(["cmake", "--build", ".", "--target", "bindings"] + build_args, cwd=self.build_temp)
subprocess.run(["cmake", ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env)
subprocess.run(["cmake", "--build", ".", "--target", "bindings"] + build_args, cwd=self.build_temp)
print() # Add an empty line for cleaner output


Expand Down
Empty file modified simulator/__init__.py
100644 → 100755
Empty file.
Empty file modified simulator/configs/arvix_linear.json
100644 → 100755
Empty file.
Empty file modified simulator/configs/arvix_linear_in_mem.json
100644 → 100755
Empty file.
Empty file modified simulator/configs/arvix_metis.json
100644 → 100755
Empty file.
Empty file modified simulator/configs/arvix_neighbors.json
100644 → 100755
Empty file.
Empty file modified simulator/configs/arvix_random.json
100644 → 100755
Empty file.
Empty file modified simulator/configs/papers.json
100644 → 100755
Empty file.
3 changes: 2 additions & 1 deletion simulator/configs/products_linear.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"feature_dimension" : 100,
"feature_size" : "float32"
},
"sampling_depth" : 1
"sampling_depth" : 1,
"batch_size" : 11
}
Binary file added simulator/images/products_linear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 27 additions & 22 deletions simulator/main.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import argparse
import random
import time
import datetime

from src.dataset_loader import *
from src.features_loader import *
Expand All @@ -19,7 +20,7 @@ def read_arguments():
parser.add_argument("--config_file", type=str, help="The config file containing the details for the simulation")
parser.add_argument("--save_path", required=True, type=str, help="The path to save the resulting image to")
parser.add_argument("--graph_title", required=True, type=str, help="The title of the saved graph")
parser.add_argument("--num_nodes", default = -1, type = int, help = "The number of nodes we want in our sample")
parser.add_argument("--sample_percentage", default = 50, type = int, help = "The percentage of batches to sample to generate CDF")
parser.add_argument("--log_rate", type=int, default=20, help="Log rate of the nodes processed")
return parser.parse_args()

Expand All @@ -30,37 +31,42 @@ def main():

# Create the loaders
data_loader = DatasetLoader(config)
print(data_loader.get_num_nodes(), data_loader.get_num_edges())
'''
features_loader = get_featurizer(data_loader, config["features_stats"])
sampler = SubgraphSampler(data_loader, features_loader, config)
print("Finished loading all objects")

# Perform sampling
nodes_to_sample = [i for i in range(data_loader.get_num_nodes())]
random.shuffle(nodes_to_sample)
if arguments.num_nodes > 0:
nodes_to_sample = nodes_to_sample[ : arguments.num_nodes]
log_rate = int(len(nodes_to_sample) / arguments.log_rate)
# Determine the sample nodes
sample_percentage = arguments.sample_percentage
all_nodes = data_loader.get_nodes_sorted_by_incoming()
batch_size = int(config["batch_size"])
all_nodes = all_nodes.reshape((-1, batch_size))

num_sample_nodes = int((sample_percentage * all_nodes.shape[0])/100.0)
batches_to_keep = np.random.choice(all_nodes.shape[0], num_sample_nodes, replace = False)
sample_nodes = all_nodes[batches_to_keep, : ]
print("Processing", sample_nodes.shape[0], "batches with each batch having", batch_size, "nodes")

# Perform the sampling
log_rate = int(sample_nodes.shape[0]/arguments.log_rate)
pages_loaded = []
for curr_node in nodes_to_sample:
num_pages_read = sampler.perform_sampling_for_node(curr_node)
if num_pages_read > 0:
pages_loaded.append(num_pages_read)
for idx, curr_batch in enumerate(sample_nodes):
average_pages_loaded = sampler.perform_sampling_for_nodes(curr_batch)
if average_pages_loaded > 0:
pages_loaded.append(average_pages_loaded)

if len(pages_loaded) > 0 and len(pages_loaded) % log_rate == 0:
percentage_finished = (100.0 * len(pages_loaded)) / len(nodes_to_sample)
if idx > 0 and idx % log_rate == 0:
percentage_finished = (100.0 * idx)/sample_nodes.shape[0]
print("Finished processing", round(percentage_finished), "percent of nodes")

# Get the arguments to log
vals_to_log = dict()
total_time = time.time() - start_time
vals_to_log = {
"Total Processing Time" : str(datetime.timedelta(seconds = int(total_time))),
"Batch Size" : batch_size,
"Sample Percentage" : sample_percentage,
}

for curr_obj in [data_loader, features_loader, sampler]:
vals_to_log.update(curr_obj.get_values_to_log())
# Log the time taken
total_time = time.time() - start_time
print("Processed all", len(nodes_to_sample), "nodes in", total_time, "seconds")

# Save the histogram
os.makedirs(os.path.dirname(arguments.save_path), exist_ok=True)
Expand All @@ -73,7 +79,6 @@ def main():
"values_to_log": vals_to_log,
}
visualize_results(visualize_arguments)
'''

if __name__ == "__main__":
main()
Empty file modified simulator/src/__init__.py
100644 → 100755
Empty file.
61 changes: 28 additions & 33 deletions simulator/src/dataset_loader.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
import os
import numpy as np
import torch
import traceback
from collections import defaultdict
import marius.storage
from marius.data import Batch, DENSEGraph, MariusGraph
from marius.data.samplers import LayeredNeighborSampler

class DatasetLoader:
SAVE_DIR = "datasets"
Expand Down Expand Up @@ -33,47 +35,40 @@ def load_dataset(self):
edges_flaten_arr = np.frombuffer(edges_bytes, dtype=np.int32)
edges_arr = edges_flaten_arr.reshape((-1, 2))

'''
# Create the graph
self.edge_list = torch.from_numpy(edges_arr)
self.nodes = torch.unique(self.edge_list)
self.current_graph = MariusGraph(self.edge_list, self.edge_list[torch.argsort(edge_list[:, -1])], self.get_num_nodes())
self.sampler = LayeredNeighborSampler(full_graph, [-1 for _ in range(self.sampling_depth)])
# Neighbors cache
'''
self.edge_list = torch.tensor(edges_arr, dtype = torch.int64)
self.total_nodes = torch.max(self.edge_list).item() + 1
self.current_graph = MariusGraph(self.edge_list, self.edge_list[torch.argsort(self.edge_list[:, -1])], self.total_nodes)
self.sampler = LayeredNeighborSampler(self.current_graph, [-1 for _ in range(self.sampling_depth)])

def get_num_nodes(self):
return self.nodes.shape(0)

def get_neigbhors_for_node(self, node_id, all_depths = False):
if node_id not in self.adjacency_map:
return []

return list(self.adjacency_map[node_id])

def get_incoming_neighbors(self, node_id):
if node_id not in self.num_incoming_edges:
return 0

return self.num_incoming_edges[node_id]
return self.total_nodes

def get_neigbhors_for_nodes(self, nodes):
# Get the neighbors for the nodes
try:
nodes_to_sample = torch.tensor(nodes, dtype = torch.int64)
sampled_nodes = self.sampler.getNeighbors(nodes_to_sample)
sampled_nodes.performMap()
return sampled_nodes.getNeighborIDs(True, True).numpy()
except:
return np.array([])

def get_num_edges(self):
return self.edge_list.shape(0)
return self.edge_list.size(0)

def get_nodes_sorted_by_incoming(self):
return torch.argsort(torch.bincount(self.edge_list[ : , 1]), descending=True).numpy()

def get_average_neighbors(self):
neighbors_count = []
for node_neighbors in self.adjacency_map.values():
neighbors_count.append(len(node_neighbors))

return np.mean(np.array(neighbors_count))
outgoing_nodes = self.edge_list[ : , 0]
outgoing_unique_nodes = torch.unique(outgoing_nodes)
return outgoing_nodes.size(0)/outgoing_unique_nodes.size(0)

def get_average_incoming(self):
incoming_counts = []
for num_incoming in self.num_incoming_edges.values():
incoming_counts.append(num_incoming)

return np.mean(np.array(incoming_counts))
incoming_nodes = self.edge_list[ : , 1]
incoming_unique_nodes = torch.unique(incoming_nodes)
return incoming_nodes.size(0)/incoming_unique_nodes.size(0)

def get_values_to_log(self):
return {
Expand Down
8 changes: 5 additions & 3 deletions simulator/src/features_loader.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@ def __init__(self, data_loader, features_stat):

def initialize(self):
total_nodes = self.data_loader.get_num_nodes()
print("Total nodes of", total_nodes)
self.total_pages = int(math.ceil(total_nodes / (1.0 * self.nodes_per_page)))
self.node_location_map = [i for i in range(self.total_pages)]
self.node_location_map = np.arange(total_nodes)
if "feature_layout" in self.features_stat and self.features_stat["feature_layout"] == "random":
random.shuffle(self.node_location_map)
self.node_to_page = (self.node_location_map/self.nodes_per_page).astype(int)

def get_node_page(self, src_node, neighbor_node):
print("Querying for node", neighbor_node, "with total of", len(self.node_location_map), "nodes")
start_node = int(self.node_location_map[neighbor_node] / self.nodes_per_page)
curr_page_nodes = set(range(start_node, start_node + self.nodes_per_page))
return curr_page_nodes

def num_pages_for_nodes(self, nodes):
return np.unique(self.node_to_page[nodes]).shape[0]

def get_single_node_feature_size(self):
return self.node_feature_size
Expand Down
Loading

0 comments on commit 57856a1

Please sign in to comment.