Write a function. Test real cases. Improve your solution.
links is a list of directed [from_node, to_node] pairs with string node names. Return a path from start to target with the fewest links, including both endpoints. If several shortest paths exist, return the lexicographically smallest whole path using Python's normal string ordering. Duplicate links and cycles are allowed. Return None when target is unreachable. When start equals target, return [start], even if it appears in no link. Direction matters: a link from A to B does not imply B to A. Inputs contain at most 100 different node names. Leave them unchanged.
[[["a", "b"], ["b", "c"], ["a", "c"]], "a", "c"]
["a", "c"]
[[["start", "beta"], ["beta", "end"], ["start", "alpha"], ["alpha", "end"]], "start", "end"]
["start", "alpha", "end"]
[[["a", "b"]], "b", "a"]
None
[[], "solo", "solo"]
["solo"]
[[["a", "b"], ["a", "b"], ["b", "a"], ["b", "c"]], "a", "c"]
["a", "b", "c"]
[[], "a", "z"]
None
[[["a", "b"], ["b", "d"], ["d", "z"], ["b", "c"], ["c", "z"]], "a", "z"]
["a", "b", "c", "z"]
Python 3.14 runs in your browser. The first run downloads about 13 MB; your browser can cache it for later visits. Each run starts fresh. Use synchronous functions and core standard-library modules. Network requests, package installs, and interactive input() are unavailable. Return lists, string-key dictionaries, strings, finite numbers, bools, or None. Student code stops after about four seconds, after Python loads. Python engine credits. Test results support self-study and don’t certify proficiency.