From eb6234eabc683e82c9c09379d938cdb400a631c1 Mon Sep 17 00:00:00 2001 From: moririn2528 Date: Thu, 14 Sep 2023 17:39:06 +0900 Subject: [PATCH] erase isolated node from graph --- optuna_dashboard/ts/components/PreferentialGraph.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/optuna_dashboard/ts/components/PreferentialGraph.tsx b/optuna_dashboard/ts/components/PreferentialGraph.tsx index 48364598..f343cb06 100644 --- a/optuna_dashboard/ts/components/PreferentialGraph.tsx +++ b/optuna_dashboard/ts/components/PreferentialGraph.tsx @@ -181,6 +181,7 @@ export const PreferentialGraph: FC<{ if (!studyDetail.is_preferential || studyDetail.preferences === undefined) return const preferences = reductionPreference(studyDetail.preferences) + const trialNodes = Array.from(new Set(preferences.flat())) const graph: ElkNode = { id: "root", layoutOptions: { @@ -189,8 +190,8 @@ export const PreferentialGraph: FC<{ "elk.layered.spacing.nodeNodeBetweenLayers": nodeMargin.toString(), "elk.spacing.nodeNode": nodeMargin.toString(), }, - children: studyDetail.trials.map((trial) => ({ - id: `${trial.number}`, + children: trialNodes.map((trial) => ({ + id: `${trial}`, targetPosition: "top", sourcePosition: "bottom", width: nodeWidth, @@ -207,7 +208,7 @@ export const PreferentialGraph: FC<{ .then((layoutedGraph) => { setNodes( layoutedGraph.children?.map((node, index) => { - const trial = studyDetail.trials[index] + const trial = studyDetail.trials[trialNodes[index]] return { id: `${trial.number}`, type: "note",