Write a function to determine the optimal path in a given data structure.
Treat the data structure as a directed weighted graph with nonnegative edge weights. Implement def optimal_path(graph, start, target):, where graph maps each node to a list of [neighbor, weight] pairs. Return {"path": [...], "cost": number} for the minimum-cost route, or None when the target is unreachable. If start == target, return a zero-cost path containing only start.
def optimal_path(graph, start, target):