private long tasksCost(final SortedSet<TaskId> tasks,
                           final SortedMap<ProcessId, ClientState> clientStates,
                           final int trafficCost,
                           final int nonOverlapCost,
                           final BiPredicate<ClientState, TaskId> hasAssignedTask,
                           final boolean hasReplica,
                           final boolean isStandby) {
        if (tasks.isEmpty()) {
            return 0;
        }
        final List<ProcessId> clientList = new ArrayList<>(clientStates.keySet());
        final List<TaskId> taskIdList = new ArrayList<>(tasks);
        final Graph<Integer> graph = new MinTrafficGraphConstructor<ClientState>()
            .constructTaskGraph(
                clientList,
                taskIdList,
                clientStates,
                new HashMap<>(),
                new HashMap<>(),
                hasAssignedTask,
                this::getCost,
                trafficCost,
                nonOverlapCost,
                hasReplica,
                isStandby
            );
        return graph.totalCost();
    }
Compute the cost for the provided {@code standbyTasks}. The passed in standby tasks must be contained in {@code clientState}.
streams/src/main/java/org/apache/kafka/streams/processor/internals/assignment/RackAwareTaskAssignor.java