diff --git a/nxbench/cli.py b/nxbench/cli.py index e4452d9..5908075 100644 --- a/nxbench/cli.py +++ b/nxbench/cli.py @@ -1,6 +1,7 @@ import json import logging import os +import platform import shutil import subprocess import sys @@ -11,8 +12,10 @@ import click import pandas as pd +import psutil import requests +from nxbench._version import __version__ from nxbench.benchmarks.config import DatasetConfig from nxbench.benchmarks.utils import get_benchmark_config from nxbench.data.loader import BenchmarkDataManager @@ -33,6 +36,33 @@ def validate_executable(path: str | Path) -> Path: return executable +def generate_machine_info(results_dir: Path) -> None: + """Generate machine info JSON file if it doesn't already exist.""" + machine = platform.node() + results_dir = Path(f"{results_dir}/{machine}") + results_dir.mkdir(parents=True, exist_ok=True) + machine_info_path = results_dir / "machine.json" + + if machine_info_path.exists(): + logger.debug(f"Machine info already exists: {machine_info_path}") + return + + machine_info = { + "arch": platform.machine(), + "cpu": platform.processor(), + "machine": machine, + "num_cpu": str(psutil.cpu_count(logical=True)), + "os": f"{platform.system()} {platform.release()}", + "ram": str(psutil.virtual_memory().total), + "version": __version__, + } + + with machine_info_path.open("w") as f: + json.dump(machine_info, f, indent=4) + + logger.info(f"Generated machine info at: {machine_info_path}") + + def get_latest_commit_hash(github_url: str) -> str: """ Fetch the latest commit hash from a GitHub repository. diff --git a/nxbench/configs/all.yaml b/nxbench/configs/all.yaml new file mode 100644 index 0000000..d04a8d6 --- /dev/null +++ b/nxbench/configs/all.yaml @@ -0,0 +1,312 @@ +algorithms: + - name: "pagerank" + func: "networkx.pagerank" + params: + alpha: 0.9 + tol: 1.0e-6 + requires_directed: false + groups: ["centrality", "random_walk"] + min_rounds: 10 + warmup: true + warmup_iterations: 50 + + - name: "eigenvector_centrality" + func: "networkx.eigenvector_centrality" + requires_directed: false + groups: ["centrality", "path_based"] + min_rounds: 5 + warmup: true + warmup_iterations: 20 + validate_result: "nxbench.validation.validate_node_scores" + + - name: "betweenness_centrality" + func: "networkx.betweenness_centrality" + params: + normalized: true + endpoints: false + requires_directed: false + groups: ["centrality", "path_based"] + min_rounds: 5 + warmup: true + warmup_iterations: 20 + validate_result: "nxbench.validation.validate_node_scores" + + # - name: "edge_betweenness_centrality" + # func: "networkx.edge_betweenness_centrality" + # params: + # normalized: true + # requires_directed: false + # groups: ["centrality", "path_based"] + # min_rounds: 5 + # warmup: true + # warmup_iterations: 20 + # validate_result: "nxbench.validation.validate_edge_scores" + + # - name: "approximate_all_pairs_node_connectivity" + # func: "networkx.algorithms.approximation.connectivity.all_pairs_node_connectivity" + # params: {} + # requires_directed: false + # groups: ["connectivity", "approximation"] + # min_rounds: 3 + + - name: "average_clustering" + func: "networkx.average_clustering" + params: {} + requires_directed: false + groups: ["clustering", "graph_structure"] + min_rounds: 3 + validate_result: "nxbench.validation.validate_scalar_result" + + - name: "square_clustering" + func: "networkx.square_clustering" + params: {} + requires_directed: false + groups: ["clustering", "graph_structure"] + min_rounds: 3 + validate_result: "nxbench.validation.validate_node_scores" + + - name: "transitivity" + func: "networkx.transitivity" + params: {} + requires_directed: false + groups: ["clustering", "graph_structure"] + min_rounds: 3 + validate_result: "nxbench.validation.validate_scalar_result" + + # - name: "all_pairs_node_connectivity" + # func: "networkx.algorithms.connectivity.connectivity.all_pairs_node_connectivity" + # params: {} + # requires_directed: false + # groups: ["connectivity", "paths"] + # min_rounds: 3 + + # - name: "local_efficiency" + # func: "networkx.local_efficiency" + # params: {} + # requires_directed: false + # groups: ["efficiency", "graph_measure"] + # min_rounds: 3 + # validate_result: "nxbench.validation.validate_node_scores" + + - name: "number_of_isolates" + func: "networkx.number_of_isolates" + params: {} + requires_directed: false + groups: ["isolates", "graph_measure"] + min_rounds: 3 + + # - name: "all_pairs_all_shortest_paths" + # func: "networkx.all_pairs_all_shortest_paths" + # params: + # weight: "weight" + # requires_directed: false + # groups: ["paths", "all_pairs"] + # min_rounds: 3 + + # - name: "all_pairs_shortest_path_length" + # func: "networkx.all_pairs_shortest_path_length" + # params: {} + # requires_directed: false + # groups: ["paths", "distance"] + # min_rounds: 3 + # validate_result: "nxbench.validation.validate_scalar_result" + + # - name: "all_pairs_shortest_path" + # func: "networkx.all_pairs_shortest_path" + # params: {} + # requires_directed: false + # groups: ["paths", "distance"] + # min_rounds: 3 + + # - name: "all_pairs_dijkstra" + # func: "networkx.all_pairs_dijkstra" + # params: + # weight: "weight" + # requires_directed: false + # groups: ["paths", "weighted"] + # min_rounds: 3 + + - name: "all_pairs_dijkstra_path_length" + func: "networkx.all_pairs_dijkstra_path_length" + params: + weight: "weight" + requires_directed: false + groups: ["paths", "weighted"] + min_rounds: 3 + validate_result: "nxbench.validation.validate_scalar_result" + + - name: "all_pairs_bellman_ford_path_length" + func: "networkx.all_pairs_bellman_ford_path_length" + params: + weight: "weight" + requires_directed: false + groups: ["paths", "weighted"] + min_rounds: 3 + validate_result: "nxbench.validation.validate_scalar_result" + + # - name: "johnson" + # func: "networkx.johnson" + # params: + # weight: "weight" + # requires_directed: false + # groups: ["paths", "weighted"] + # min_rounds: 3 + + # - name: "closeness_vitality" + # func: "networkx.closeness_vitality" + # params: {} + # requires_directed: false + # groups: ["vitality", "centrality"] + # min_rounds: 3 + +datasets: + - name: "twitter" + source: "networkrepository" + params: {} + + - name: "08blocks" + source: "networkrepository" + params: {} + + - name: "amazon" + source: "networkrepository" + params: {} + + - name: "google" + source: "networkrepository" + params: {} + + - name: "enron" + source: "networkrepository" + params: {} + + - name: "citationCiteseer" + source: "networkrepository" + params: {} + + - name: "karate" + source: "networkrepository" + params: {} + + - name: "netscience" + source: "networkrepository" + params: {} + + - name: "email-Eu-core" + source: "networkrepository" + params: {} + + - name: "jazz" + source: "networkrepository" + params: {} + + - name: "erdos_renyi_small" + source: "generator" + params: + generator: "networkx.erdos_renyi_graph" + n: 1000 + p: 0.01 + metadata: + directed: false + weighted: false + + - name: "watts_strogatz_small" + source: "generator" + params: + generator: "networkx.watts_strogatz_graph" + n: 10000 + k: 6 + p: 0.1 + metadata: + directed: false + weighted: false + + - name: "barabasi_albert_small" + source: "generator" + params: + generator: "networkx.barabasi_albert_graph" + n: 1000 + m: 3 + metadata: + directed: false + weighted: false + + - name: "powerlaw_cluster_small" + source: "generator" + params: + generator: "networkx.powerlaw_cluster_graph" + n: 1000 + m: 2 + p: 0.1 + metadata: + directed: false + weighted: false + + - name: "erdos_renyi_small" + source: "generator" + params: + generator: "networkx.erdos_renyi_graph" + n: 1000 + p: 0.01 + metadata: + directed: false + weighted: false + + # - name: "watts_strogatz_large" + # source: "generator" + # params: + # generator: "networkx.watts_strogatz_graph" + # n: 10000 + # k: 6 + # p: 0.1 + # metadata: + # directed: false + # weighted: false + + # - name: "barabasi_albert_large" + # source: "generator" + # params: + # generator: "networkx.barabasi_albert_graph" + # n: 10000 + # m: 3 + # metadata: + # directed: false + # weighted: false + + # - name: "powerlaw_cluster_large" + # source: "generator" + # params: + # generator: "networkx.powerlaw_cluster_graph" + # n: 10000 + # m: 2 + # p: 0.1 + # metadata: + # directed: false + # weighted: false + +validation: + skip_slow: false + validate_all: true + error_on_fail: true + report_memory: true + +matrix: + backend: + - "networkx" + - "parallel" + - "graphblas" + - "cugraph" + num_threads: + - "1" + - "4" + - "8" + +env_config: + req: + - "networkx==3.4.2" + - "nx-parallel-0.3rc0.dev0" + - "graphblas_algorithms==2023.10.0" + - "nx-cugraph_cu11==24.8.0" + pythons: + - "3.10" + - "3.11" diff --git a/nxbench/configs/example.yaml b/nxbench/configs/example.yaml index 63517d0..1ad413e 100644 --- a/nxbench/configs/example.yaml +++ b/nxbench/configs/example.yaml @@ -144,14 +144,6 @@ algorithms: min_rounds: 3 validate_result: "nxbench.validation.validate_scalar_result" - # - name: "all_pairs_bellman_ford_path" - # func: "networkx.all_pairs_bellman_ford_path" - # params: - # weight: "weight" - # requires_directed: false - # groups: ["paths", "weighted"] - # min_rounds: 3 - # - name: "johnson" # func: "networkx.johnson" # params: