Spaces:
Running
Running
<html> | |
<head> | |
<title>ROCm Package Dependencies</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/7.8.5/d3.min.js"></script> | |
<style> | |
.node { | |
fill: #69b3a2; | |
stroke: #fff; | |
stroke-width: 1.5px; | |
cursor: pointer; | |
} | |
.node.highlighted { | |
fill: #ff7f0e; | |
} | |
.node.dimmed { | |
opacity: 0.1; | |
} | |
.link { | |
stroke: #999; | |
stroke-opacity: 0.6; | |
} | |
.link.highlighted { | |
stroke: #ff7f0e; | |
stroke-width: 2px; | |
} | |
.link.dimmed { | |
opacity: 0.1; | |
} | |
.label { | |
font-family: Arial; | |
font-size: 10px; | |
pointer-events: none; | |
} | |
.label.dimmed { | |
opacity: 0.1; | |
} | |
#graph { | |
width: 100%; | |
height: 800px; | |
overflow: hidden; | |
} | |
svg { | |
width: 100%; | |
height: 100%; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="graph"></div> | |
<script> | |
const data = { | |
"amd-smi-lib": { | |
"bundleSrcs": [ | |
"amd-smi-lib" | |
], | |
"deps": [ | |
"rocm-core" | |
] | |
}, | |
"amdgpu-core": { | |
"bundleSrcs": [ | |
"amdgpu-core" | |
], | |
"deps": [] | |
}, | |
"comgr": { | |
"bundleSrcs": [ | |
"comgr" | |
], | |
"deps": [ | |
"rocm-core" | |
] | |
}, | |
"composablekernel-dev": { | |
"bundleSrcs": [ | |
"composablekernel-dev" | |
], | |
"deps": [ | |
"rocm-core" | |
] | |
}, | |
"half": { | |
"bundleSrcs": [ | |
"half" | |
], | |
"deps": [ | |
"rocm-core" | |
] | |
}, | |
"hip-dev": { | |
"bundleSrcs": [ | |
"hip-dev" | |
], | |
"deps": [ | |
"hip-runtime-amd", | |
"hsa-rocr", | |
"rocm-core", | |
"rocm-llvm" | |
] | |
}, | |
"hip-doc": { | |
"bundleSrcs": [ | |
"hip-doc" | |
], | |
"deps": [ | |
"hip-dev", | |
"rocm-core" | |
] | |
}, | |
"hip-runtime-amd": { | |
"bundleSrcs": [ | |
"hip-runtime-amd" | |
], | |
"deps": [ | |
"comgr", | |
"hsa-rocr", | |
"rocm-core", | |
"rocminfo", | |
"rocprofiler-register" | |
] | |
}, | |
"hip-samples": { | |
"bundleSrcs": [ | |
"hip-samples" | |
], | |
"deps": [ | |
"hip-dev", | |
"hipcc", | |
"rocm-core" | |
] | |
}, | |
"hipblas": { | |
"bundleSrcs": [ | |
"hipblas", | |
"hipblas-dev" | |
], | |
"deps": [ | |
"hipblas-common-dev", | |
"rocblas", | |
"rocm-core", | |
"rocsolver" | |
] | |
}, | |
"hipblas-common-dev": { | |
"bundleSrcs": [ | |
"hipblas-common-dev" | |
], | |
"deps": [ | |
"rocm-core" | |
] | |
}, | |
"hipblaslt": { | |
"bundleSrcs": [ | |
"hipblaslt", | |
"hipblaslt-dev" | |
], | |
"deps": [ | |
"hipblas-common-dev", | |
"rocm-core" | |
] | |
}, | |
"hipcc": { | |
"bundleSrcs": [ | |
"hipcc" | |
], | |
"deps": [ | |
"hip-dev", | |
"rocm-core", | |
"rocm-llvm" | |
] | |
}, | |
"hipcub-dev": { | |
"bundleSrcs": [ | |
"hipcub-dev" | |
], | |
"deps": [ | |
"rocm-core", | |
"rocprim-dev" | |
] | |
}, | |
"hipfft": { | |
"bundleSrcs": [ | |
"hipfft", | |
"hipfft-dev" | |
], | |
"deps": [ | |
"rocfft", | |
"rocm-core" | |
] | |
}, | |
"hipfort-dev": { | |
"bundleSrcs": [ | |
"hipfort-dev" | |
], | |
"deps": [ | |
"hip-runtime-amd", | |
"rocm-core" | |
] | |
}, | |
"hipify-clang": { | |
"bundleSrcs": [ | |
"hipify-clang" | |
], | |
"deps": [ | |
"rocm-core" | |
] | |
}, | |
"hiprand": { | |
"bundleSrcs": [ | |
"hiprand", | |
"hiprand-dev" | |
], | |
"deps": [ | |
"rocm-core" | |
] | |
}, | |
"hipsolver": { | |
"bundleSrcs": [ | |
"hipsolver", | |
"hipsolver-dev" | |
], | |
"deps": [ | |
"rocblas", | |
"rocm-core", | |
"rocsolver" | |
] | |
}, | |
"hipsparse": { | |
"bundleSrcs": [ | |
"hipsparse", | |
"hipsparse-dev" | |
], | |
"deps": [ | |
"rocm-core", | |
"rocsparse" | |
] | |
}, | |
"hipsparselt": { | |
"bundleSrcs": [ | |
"hipsparselt", | |
"hipsparselt-dev" | |
], | |
"deps": [ | |
"hipsparse", | |
"rocm-core" | |
] | |
}, | |
"hiptensor": { | |
"bundleSrcs": [ | |
"hiptensor", | |
"hiptensor-dev" | |
], | |
"deps": [ | |
"rocm-core" | |
] | |
}, | |
"hsa-amd-aqlprofile": { | |
"bundleSrcs": [ | |
"hsa-amd-aqlprofile" | |
], | |
"deps": [ | |
"rocm-core" | |
] | |
}, | |
"hsa-rocr": { | |
"bundleSrcs": [ | |
"hsa-rocr", | |
"hsa-rocr-dev" | |
], | |
"deps": [ | |
"libdrm-amdgpu-amdgpu1", | |
"libdrm-amdgpu-dev", | |
"rocm-core", | |
"rocprofiler-register" | |
] | |
}, | |
"libdrm-amdgpu-amdgpu1": { | |
"bundleSrcs": [ | |
"libdrm-amdgpu-amdgpu1" | |
], | |
"deps": [ | |
"libdrm-amdgpu-common", | |
"libdrm2-amdgpu" | |
] | |
}, | |
"libdrm-amdgpu-common": { | |
"bundleSrcs": [ | |
"libdrm-amdgpu-common" | |
], | |
"deps": [ | |
"amdgpu-core" | |
] | |
}, | |
"libdrm-amdgpu-dev": { | |
"bundleSrcs": [ | |
"libdrm-amdgpu-dev" | |
], | |
"deps": [ | |
"libdrm-amdgpu-amdgpu1", | |
"libdrm-amdgpu-radeon1", | |
"libdrm2-amdgpu" | |
] | |
}, | |
"libdrm-amdgpu-radeon1": { | |
"bundleSrcs": [ | |
"libdrm-amdgpu-radeon1" | |
], | |
"deps": [ | |
"libdrm2-amdgpu" | |
] | |
}, | |
"libdrm2-amdgpu": { | |
"bundleSrcs": [ | |
"libdrm2-amdgpu" | |
], | |
"deps": [ | |
"amdgpu-core" | |
] | |
}, | |
"libglapi-amdgpu-mesa": { | |
"bundleSrcs": [ | |
"libglapi-amdgpu-mesa" | |
], | |
"deps": [ | |
"amdgpu-core" | |
] | |
}, | |
"libllvm19.1-amdgpu": { | |
"bundleSrcs": [ | |
"libllvm19.1-amdgpu" | |
], | |
"deps": [ | |
"amdgpu-core" | |
] | |
}, | |
"libva-amdgpu-dev": { | |
"bundleSrcs": [ | |
"libva-amdgpu-dev" | |
], | |
"deps": [ | |
"libva-amdgpu-drm2", | |
"libva-amdgpu-glx2", | |
"libva-amdgpu-wayland2", | |
"libva-amdgpu-x11-2", | |
"libva2-amdgpu" | |
] | |
}, | |
"libva-amdgpu-drm2": { | |
"bundleSrcs": [ | |
"libva-amdgpu-drm2" | |
], | |
"deps": [ | |
"amdgpu-core", | |
"libdrm2-amdgpu", | |
"libva2-amdgpu" | |
] | |
}, | |
"libva-amdgpu-glx2": { | |
"bundleSrcs": [ | |
"libva-amdgpu-glx2" | |
], | |
"deps": [ | |
"amdgpu-core", | |
"libva-amdgpu-x11-2", | |
"libva2-amdgpu" | |
] | |
}, | |
"libva-amdgpu-wayland2": { | |
"bundleSrcs": [ | |
"libva-amdgpu-wayland2" | |
], | |
"deps": [ | |
"amdgpu-core", | |
"libdrm2-amdgpu", | |
"libva2-amdgpu", | |
"libwayland-amdgpu-client0" | |
] | |
}, | |
"libva-amdgpu-x11-2": { | |
"bundleSrcs": [ | |
"libva-amdgpu-x11-2" | |
], | |
"deps": [ | |
"amdgpu-core", | |
"libdrm2-amdgpu", | |
"libva2-amdgpu" | |
] | |
}, | |
"libva2-amdgpu": { | |
"bundleSrcs": [ | |
"libva2-amdgpu" | |
], | |
"deps": [ | |
"amdgpu-core" | |
] | |
}, | |
"libwayland-amdgpu-client0": { | |
"bundleSrcs": [ | |
"libwayland-amdgpu-client0" | |
], | |
"deps": [ | |
"amdgpu-core" | |
] | |
}, | |
"mesa-amdgpu-libgallium": { | |
"bundleSrcs": [ | |
"mesa-amdgpu-libgallium" | |
], | |
"deps": [ | |
"amdgpu-core", | |
"libdrm-amdgpu-amdgpu1", | |
"libdrm-amdgpu-radeon1", | |
"libdrm2-amdgpu", | |
"libglapi-amdgpu-mesa", | |
"libllvm19.1-amdgpu" | |
] | |
}, | |
"mesa-amdgpu-va-drivers": { | |
"bundleSrcs": [ | |
"mesa-amdgpu-va-drivers" | |
], | |
"deps": [ | |
"amdgpu-core", | |
"mesa-amdgpu-libgallium" | |
] | |
}, | |
"migraphx": { | |
"bundleSrcs": [ | |
"migraphx", | |
"migraphx-dev" | |
], | |
"deps": [ | |
"half", | |
"hip-dev", | |
"hip-runtime-amd", | |
"hipblaslt", | |
"miopen-hip", | |
"rocblas", | |
"rocm-core" | |
] | |
}, | |
"miopen-hip": { | |
"bundleSrcs": [ | |
"miopen-hip", | |
"miopen-hip-dev" | |
], | |
"deps": [ | |
"comgr", | |
"hip-runtime-amd", | |
"hipblaslt", | |
"rocblas", | |
"rocm-core", | |
"rocrand", | |
"roctracer" | |
] | |
}, | |
"mivisionx": { | |
"bundleSrcs": [ | |
"mivisionx", | |
"mivisionx-dev" | |
], | |
"deps": [ | |
"half", | |
"migraphx", | |
"miopen-hip", | |
"rocblas", | |
"rocm-core", | |
"rocm-hip-runtime", | |
"rpp" | |
] | |
}, | |
"openmp-extras-dev": { | |
"bundleSrcs": [ | |
"openmp-extras-dev" | |
], | |
"deps": [ | |
"hsa-rocr", | |
"openmp-extras-runtime", | |
"rocm-core", | |
"rocm-device-libs", | |
"rocm-llvm" | |
] | |
}, | |
"openmp-extras-runtime": { | |
"bundleSrcs": [ | |
"openmp-extras-runtime" | |
], | |
"deps": [ | |
"hsa-rocr", | |
"rocm-core" | |
] | |
}, | |
"rccl": { | |
"bundleSrcs": [ | |
"rccl", | |
"rccl-dev" | |
], | |
"deps": [ | |
"hip-runtime-amd", | |
"rocm-core", | |
"rocm-smi-lib", | |
"rocprofiler-register" | |
] | |
}, | |
"rocalution": { | |
"bundleSrcs": [ | |
"rocalution", | |
"rocalution-dev" | |
], | |
"deps": [ | |
"hip-runtime-amd", | |
"rocblas", | |
"rocm-core", | |
"rocrand", | |
"rocsparse" | |
] | |
}, | |
"rocblas": { | |
"bundleSrcs": [ | |
"rocblas", | |
"rocblas-dev" | |
], | |
"deps": [ | |
"hip-runtime-amd", | |
"hipblaslt", | |
"rocm-core" | |
] | |
}, | |
"rocdecode": { | |
"bundleSrcs": [ | |
"rocdecode", | |
"rocdecode-dev" | |
], | |
"deps": [ | |
"libva-amdgpu-dev", | |
"libva-amdgpu-drm2", | |
"libva-amdgpu-wayland2", | |
"libva-amdgpu-x11-2", | |
"libva2-amdgpu", | |
"mesa-amdgpu-va-drivers", | |
"rocm-core", | |
"rocm-hip-runtime" | |
] | |
}, | |
"rocdecode-test": { | |
"bundleSrcs": [ | |
"rocdecode-test" | |
], | |
"deps": [ | |
"rocdecode", | |
"rocm-core" | |
] | |
}, | |
"rocfft": { | |
"bundleSrcs": [ | |
"rocfft", | |
"rocfft-dev" | |
], | |
"deps": [ | |
"rocm-core" | |
] | |
}, | |
"rocm": { | |
"bundleSrcs": [ | |
"rocm" | |
], | |
"deps": [ | |
"migraphx", | |
"mivisionx", | |
"rocm-core", | |
"rocm-developer-tools", | |
"rocm-ml-sdk", | |
"rocm-opencl-sdk", | |
"rocm-openmp-sdk", | |
"rocm-utils", | |
"rpp" | |
] | |
}, | |
"rocm-cmake": { | |
"bundleSrcs": [ | |
"rocm-cmake" | |
], | |
"deps": [ | |
"rocm-core" | |
] | |
}, | |
"rocm-core": { | |
"bundleSrcs": [ | |
"rocm-core" | |
], | |
"deps": [] | |
}, | |
"rocm-dbgapi": { | |
"bundleSrcs": [ | |
"rocm-dbgapi" | |
], | |
"deps": [ | |
"rocm-core" | |
] | |
}, | |
"rocm-debug-agent": { | |
"bundleSrcs": [ | |
"rocm-debug-agent" | |
], | |
"deps": [ | |
"rocm-core", | |
"rocm-dbgapi" | |
] | |
}, | |
"rocm-developer-tools": { | |
"bundleSrcs": [ | |
"rocm-developer-tools" | |
], | |
"deps": [ | |
"amd-smi-lib", | |
"hsa-amd-aqlprofile", | |
"rocm-core", | |
"rocm-dbgapi", | |
"rocm-debug-agent", | |
"rocm-gdb", | |
"rocm-language-runtime", | |
"rocm-smi-lib", | |
"rocprofiler", | |
"rocprofiler-plugins", | |
"rocprofiler-register", | |
"rocprofiler-sdk", | |
"rocprofiler-sdk-roctx", | |
"roctracer" | |
] | |
}, | |
"rocm-device-libs": { | |
"bundleSrcs": [ | |
"rocm-device-libs" | |
], | |
"deps": [ | |
"rocm-core" | |
] | |
}, | |
"rocm-gdb": { | |
"bundleSrcs": [ | |
"rocm-gdb" | |
], | |
"deps": [ | |
"rocm-core", | |
"rocm-dbgapi" | |
] | |
}, | |
"rocm-hip-libraries": { | |
"bundleSrcs": [ | |
"rocm-hip-libraries" | |
], | |
"deps": [ | |
"hipblas", | |
"hipblaslt", | |
"hipfft", | |
"hiprand", | |
"hipsolver", | |
"hipsparse", | |
"hipsparselt", | |
"hiptensor", | |
"rccl", | |
"rocalution", | |
"rocblas", | |
"rocfft", | |
"rocm-core", | |
"rocm-hip-runtime", | |
"rocm-smi-lib", | |
"rocrand", | |
"rocsolver", | |
"rocsparse" | |
] | |
}, | |
"rocm-hip-runtime": { | |
"bundleSrcs": [ | |
"rocm-hip-runtime", | |
"rocm-hip-runtime-dev" | |
], | |
"deps": [ | |
"hip-dev", | |
"hip-doc", | |
"hip-runtime-amd", | |
"hip-samples", | |
"hipcc", | |
"hipify-clang", | |
"hsa-rocr", | |
"rocm-cmake", | |
"rocm-core", | |
"rocm-device-libs", | |
"rocm-language-runtime", | |
"rocm-llvm", | |
"rocminfo" | |
] | |
}, | |
"rocm-hip-sdk": { | |
"bundleSrcs": [ | |
"rocm-hip-sdk" | |
], | |
"deps": [ | |
"composablekernel-dev", | |
"hipblas", | |
"hipblaslt", | |
"hipcub-dev", | |
"hipfft", | |
"hipfort-dev", | |
"hiprand", | |
"hipsolver", | |
"hipsparse", | |
"hipsparselt", | |
"hiptensor", | |
"rccl", | |
"rocalution", | |
"rocblas", | |
"rocfft", | |
"rocm-core", | |
"rocm-hip-libraries", | |
"rocm-hip-runtime", | |
"rocprim-dev", | |
"rocrand", | |
"rocsolver", | |
"rocsparse", | |
"rocthrust-dev", | |
"rocwmma-dev" | |
] | |
}, | |
"rocm-language-runtime": { | |
"bundleSrcs": [ | |
"rocm-language-runtime" | |
], | |
"deps": [ | |
"comgr", | |
"hsa-rocr", | |
"openmp-extras-runtime", | |
"rocm-core" | |
] | |
}, | |
"rocm-llvm": { | |
"bundleSrcs": [ | |
"rocm-llvm", | |
"rocm-llvm-dev" | |
], | |
"deps": [ | |
"rocm-core" | |
] | |
}, | |
"rocm-ml-libraries": { | |
"bundleSrcs": [ | |
"rocm-ml-libraries" | |
], | |
"deps": [ | |
"half", | |
"miopen-hip", | |
"rocm-core", | |
"rocm-hip-libraries", | |
"rocm-llvm" | |
] | |
}, | |
"rocm-ml-sdk": { | |
"bundleSrcs": [ | |
"rocm-ml-sdk" | |
], | |
"deps": [ | |
"miopen-hip", | |
"rocm-core", | |
"rocm-hip-sdk", | |
"rocm-ml-libraries" | |
] | |
}, | |
"rocm-opencl": { | |
"bundleSrcs": [ | |
"rocm-opencl", | |
"rocm-opencl-dev" | |
], | |
"deps": [ | |
"comgr", | |
"hsa-rocr", | |
"rocm-core" | |
] | |
}, | |
"rocm-opencl-runtime": { | |
"bundleSrcs": [ | |
"rocm-opencl-runtime" | |
], | |
"deps": [ | |
"rocm-core", | |
"rocm-language-runtime", | |
"rocm-opencl" | |
] | |
}, | |
"rocm-opencl-sdk": { | |
"bundleSrcs": [ | |
"rocm-opencl-sdk" | |
], | |
"deps": [ | |
"hsa-rocr", | |
"rocm-core", | |
"rocm-opencl", | |
"rocm-opencl-runtime" | |
] | |
}, | |
"rocm-openmp-sdk": { | |
"bundleSrcs": [ | |
"rocm-openmp-sdk" | |
], | |
"deps": [ | |
"hsa-rocr", | |
"openmp-extras-dev", | |
"rocm-core", | |
"rocm-device-libs", | |
"rocm-language-runtime", | |
"rocm-llvm" | |
] | |
}, | |
"rocm-smi-lib": { | |
"bundleSrcs": [ | |
"rocm-smi-lib" | |
], | |
"deps": [ | |
"rocm-core" | |
] | |
}, | |
"rocm-utils": { | |
"bundleSrcs": [ | |
"rocm-utils" | |
], | |
"deps": [ | |
"rocm-cmake", | |
"rocm-core", | |
"rocminfo" | |
] | |
}, | |
"rocm-validation-suite": { | |
"bundleSrcs": [ | |
"rocm-validation-suite" | |
], | |
"deps": [ | |
"comgr", | |
"hip-runtime-amd", | |
"hipblaslt", | |
"hiprand", | |
"hsa-rocr", | |
"rocblas", | |
"rocm-core", | |
"rocm-smi-lib" | |
] | |
}, | |
"rocminfo": { | |
"bundleSrcs": [ | |
"rocminfo" | |
], | |
"deps": [ | |
"hsa-rocr", | |
"rocm-core" | |
] | |
}, | |
"rocprim-dev": { | |
"bundleSrcs": [ | |
"rocprim-dev" | |
], | |
"deps": [ | |
"hip-runtime-amd", | |
"rocm-core" | |
] | |
}, | |
"rocprofiler": { | |
"bundleSrcs": [ | |
"rocprofiler", | |
"rocprofiler-dev" | |
], | |
"deps": [ | |
"hsa-rocr", | |
"rocm-core", | |
"rocminfo" | |
] | |
}, | |
"rocprofiler-compute": { | |
"bundleSrcs": [ | |
"rocprofiler-compute" | |
], | |
"deps": [ | |
"rocprofiler" | |
] | |
}, | |
"rocprofiler-plugins": { | |
"bundleSrcs": [ | |
"rocprofiler-plugins" | |
], | |
"deps": [ | |
"hsa-rocr", | |
"rocm-core", | |
"rocprofiler" | |
] | |
}, | |
"rocprofiler-register": { | |
"bundleSrcs": [ | |
"rocprofiler-register" | |
], | |
"deps": [ | |
"rocm-core" | |
] | |
}, | |
"rocprofiler-sdk": { | |
"bundleSrcs": [ | |
"rocprofiler-sdk" | |
], | |
"deps": [ | |
"rocm-core", | |
"rocprofiler-sdk-roctx" | |
] | |
}, | |
"rocprofiler-sdk-roctx": { | |
"bundleSrcs": [ | |
"rocprofiler-sdk-roctx" | |
], | |
"deps": [ | |
"rocm-core" | |
] | |
}, | |
"rocprofiler-systems": { | |
"bundleSrcs": [ | |
"rocprofiler-systems" | |
], | |
"deps": [ | |
"rocm-smi-lib", | |
"rocprofiler", | |
"roctracer" | |
] | |
}, | |
"rocrand": { | |
"bundleSrcs": [ | |
"rocrand", | |
"rocrand-dev" | |
], | |
"deps": [ | |
"rocm-core" | |
] | |
}, | |
"rocsolver": { | |
"bundleSrcs": [ | |
"rocsolver", | |
"rocsolver-dev" | |
], | |
"deps": [ | |
"rocblas", | |
"rocm-core" | |
] | |
}, | |
"rocsparse": { | |
"bundleSrcs": [ | |
"rocsparse", | |
"rocsparse-dev" | |
], | |
"deps": [ | |
"hip-runtime-amd", | |
"rocm-core" | |
] | |
}, | |
"rocthrust-dev": { | |
"bundleSrcs": [ | |
"rocthrust-dev" | |
], | |
"deps": [ | |
"rocm-core", | |
"rocprim-dev" | |
] | |
}, | |
"roctracer": { | |
"bundleSrcs": [ | |
"roctracer", | |
"roctracer-dev" | |
], | |
"deps": [ | |
"hsa-rocr", | |
"rocm-core" | |
] | |
}, | |
"rocwmma-dev": { | |
"bundleSrcs": [ | |
"rocwmma-dev" | |
], | |
"deps": [ | |
"rocm-core" | |
] | |
}, | |
"rpp": { | |
"bundleSrcs": [ | |
"rpp", | |
"rpp-dev" | |
], | |
"deps": [ | |
"half", | |
"rocm-hip-runtime" | |
] | |
} | |
} | |
const nodes = Object.keys(data).map(id => ({ id })); | |
const links = []; | |
const nodeMap = new Map(nodes.map((node, i) => [node.id, i])); | |
Object.entries(data).forEach(([source, info]) => { | |
info.deps.forEach(target => { | |
if (nodeMap.has(target)) { | |
links.push({ | |
source: nodeMap.get(source), | |
target: nodeMap.get(target) | |
}); | |
} | |
}); | |
}); | |
const svg = d3.select("#graph") | |
.append("svg") | |
.call(d3.zoom().on("zoom", (event) => { | |
g.attr("transform", event.transform); | |
})); | |
const g = svg.append("g"); | |
const simulation = d3.forceSimulation(nodes) | |
.force("link", d3.forceLink(links).distance(100)) | |
.force("charge", d3.forceManyBody().strength(-300)) | |
.force("center", d3.forceCenter(400, 300)) | |
.force("collision", d3.forceCollide().radius(50)); | |
const link = g.append("g") | |
.selectAll("line") | |
.data(links) | |
.join("line") | |
.attr("class", "link"); | |
const node = g.append("g") | |
.selectAll("circle") | |
.data(nodes) | |
.join("circle") | |
.attr("class", "node") | |
.attr("r", 5) | |
.on("click", highlightConnections); | |
const label = g.append("g") | |
.selectAll("text") | |
.data(nodes) | |
.join("text") | |
.attr("class", "label") | |
.text(d => d.id); | |
function highlightConnections(event, d) { | |
const connectedNodeIds = new Set([d.id]); | |
links.forEach(link => { | |
if (nodes[link.source.index].id === d.id) { | |
connectedNodeIds.add(nodes[link.target.index].id); | |
} | |
if (nodes[link.target.index].id === d.id) { | |
connectedNodeIds.add(nodes[link.source.index].id); | |
} | |
}); | |
node.classed("highlighted", n => connectedNodeIds.has(n.id)) | |
.classed("dimmed", n => !connectedNodeIds.has(n.id)); | |
label.classed("highlighted", n => connectedNodeIds.has(n.id)) | |
.classed("dimmed", n => !connectedNodeIds.has(n.id)); | |
link.classed("highlighted", l => | |
connectedNodeIds.has(nodes[l.source.index].id) && | |
connectedNodeIds.has(nodes[l.target.index].id)) | |
.classed("dimmed", l => | |
!(connectedNodeIds.has(nodes[l.source.index].id) && | |
connectedNodeIds.has(nodes[l.target.index].id))); | |
} | |
simulation.on("tick", () => { | |
link | |
.attr("x1", d => d.source.x) | |
.attr("y1", d => d.source.y) | |
.attr("x2", d => d.target.x) | |
.attr("y2", d => d.target.y); | |
node | |
.attr("cx", d => d.x) | |
.attr("cy", d => d.y); | |
label | |
.attr("x", d => d.x + 8) | |
.attr("y", d => d.y + 3); | |
}); | |
// Click background to reset | |
svg.on("click", function (event) { | |
if (event.target.tagName === "svg") { | |
node.classed("highlighted dimmed", false); | |
link.classed("highlighted dimmed", false); | |
label.classed("highlighted dimmed", false); | |
} | |
}); | |
</script> | |
</body> | |
</html> |