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",