LinearGraphAnswer (@NotNull final ActionContext context) { if (isForDelegateGraph(context)) return null; GraphElement affectedGraphElement = context.getAffectedGraphElement(); if (affectedGraphElement == null) return null; LinearFragmentGenerator compiledLinearFragmentGenerator = context.myCompiledFragmentGenerators.linearFragmentGenerator; FragmentGenerator compiledFragmentGenerator = context.myCompiledFragmentGenerators.fragmentGenerator; if (context.getActionType() == GraphAction.Type.MOUSE_OVER) { GraphFragment fragment = compiledLinearFragmentGenerator.getPartLongFragment(affectedGraphElement); if (fragment == null) return null; Set<Integer> middleCompiledNodes = compiledFragmentGenerator.getMiddleNodes(fragment.upNodeIndex, fragment.downNodeIndex, false); return LinearGraphUtils.createSelectedAnswer(context.getCompiledGraph(), middleCompiledNodes); } GraphFragment fragment = compiledLinearFragmentGenerator.getLongFragment(affectedGraphElement); if (fragment == null) return null; Set<Integer> middleCompiledNodes = compiledFragmentGenerator.getMiddleNodes(fragment.upNodeIndex, fragment.downNodeIndex, true); Set<GraphEdge> dottedCompiledEdges = new HashSet<>(); for (Integer middleNodeIndex : middleCompiledNodes) { dottedCompiledEdges.addAll(ContainerUtil.filter(context.getCompiledGraph().getAdjacentEdges(middleNodeIndex, EdgeFilter.NORMAL_ALL), edge -> edge.getType() == GraphEdgeType.DOTTED)); } int upNodeIndex = context.convertToDelegateNodeIndex(fragment.upNodeIndex); int downNodeIndex = context.convertToDelegateNodeIndex(fragment.downNodeIndex); Set<Integer> middleNodes = context.convertToDelegateNodeIndex(middleCompiledNodes); Set<GraphEdge> dottedEdges = ContainerUtil.map2Set(dottedCompiledEdges, edge -> context.convertToDelegateEdge(edge)); CollapsedGraph.Modification modification = context.myCollapsedGraph.startModification(); for (GraphEdge edge : dottedEdges) modification.removeEdge(edge); for (Integer middleNode : middleNodes) modification.hideNode(middleNode); modification.createEdge(new GraphEdge(upNodeIndex, downNodeIndex, null, GraphEdgeType.DOTTED)); modification.apply(); return new LinearGraphController.LinearGraphAnswer(GraphChangesUtil.SOME_CHANGES); }