LiteLinearGraph (@NotNull final LinearGraph graph) { return new LiteLinearGraph() { @Override public int nodesCount() { return graph.nodesCount(); } @NotNull @Override public List<Integer> getNodes(final int nodeIndex, @NotNull final NodeFilter filter) { return ContainerUtil.mapNotNull(graph.getAdjacentEdges(nodeIndex, filter.edgeFilter), edge -> { if (isEdgeUp(edge, nodeIndex)) return edge.getUpNodeIndex(); if (isEdgeDown(edge, nodeIndex)) return edge.getDownNodeIndex(); return null; }); } }; }