task_graph__node_link__shortest_path_length¶
Program Contract¶
Program: length(shortest_path(graph, source_node, goal_node)); scene=node_link; scope=shortest_path_length
Candidate set: the visible graph, tree, network, route, matrix, table, node, edge, label, weight, path, and option elements inside the shortest_path_length objective scope.
Operands: visible scene state and prompt-bound operands named by shortest_path, graph, source_node, goal_node, node_link, shortest_path_length plus the active query_id branch.
Operation: evaluate length over the candidate set using the visible graph structure, labels, weights, directions, reachability, paths, connectivity, or option-selection constraints encoded in the program expression; generation enforces a unique final answer.
Output binding: answer uses the integer schema; the number of edges on that path,.
Annotation witnesses: annotation uses the point_sequence schema; the point_sequence of node-center pixel points after the source node along the unique shortest path, ending at the goal node.
Query ids: undirected_shortest_path_length, directed_shortest_path_length.
Reasoning Operations¶
Families: counting, ranking, topology
1) Identity¶
- Domain:
graph - Scene:
path - Scene id:
node_link - Task id:
task_graph__node_link__shortest_path_length - Objective: count how many edges lie on the unique shortest path between two labeled nodes in an undirected or directed graph.
2) Scene + task contract¶
- Branch metadata:
query_id query_id:undirected_shortest_path_lengthordirected_shortest_path_length- Supported
graph_directionalityvalues:undirected,directed - Supported
scene_variantvalues:circular,shell,spring,grid_jitter,layered,component_clustered,path_spine,radial_tree answer_gt.type:integerannotation_gt.type:point_sequence- Scene contract:
- one single-panel labeled node-link graph,
- simple unweighted graph only,
- no self-loops or multi-edges,
- directed branches also reject reciprocal directed edge pairs,
- visible node labels use one whole-image label format (
letters,numbers, ornamed), - node count is sampled from
5..15, - generation leaves at least one node outside the queried shortest path.
- Query contract:
- undirected branch asks how many edges are in the unique shortest path from node X to node Y,
- directed branch asks how many edges are in the unique path from node X to node Y when following arrow direction,
target_shortest_path_lengthsupport is2..5,- answer is the number of edges on that path,
- annotation is the ordered node-center pixel path after the source node, ending at the goal node.
3) Prompt contract¶
- Bundle:
graph_node_link_path_v1 scene_key:single_graph_pathtask_key:shortest_path_length_query- Modes:
answer_only,answer_and_annotation - Answer JSON shape:
{"answer":2} - Answer+annotation JSON shape:
{"annotation":[[310,180],[430,260]],"answer":2} - Prompt-facing annotation uses an ordered pixel point path because shortest-path semantics depend on source-to-goal order.
4) Annotation + trace contract¶
- Prompt-facing annotation is the
point_sequenceof node-center pixel points after the source node along the unique shortest path, ending at the goal node. - The annotation path excludes the source endpoint.
answer_gt.value == len(annotation_gt.value)by construction.execution_trace.query_idrecords the concrete public branch:undirected_shortest_path_lengthordirected_shortest_path_length.- The internal generator records
internal_query_id == "shortest_path_length"orinternal_query_id == "directed_shortest_path_length"for diagnostic compatibility. execution_trace.graph_directionalityrecordsundirectedordirected.projected_annotationincludespoint_sequence,pixel_point_sequence, andpixel_bbox_set.
5) Visual policy¶
- Rendering uses the shared graph light-panel style from
src/trace_tasks/resources/configs/domains/graph/base.yaml. - Directed branches render arrowheads and use explicit direction-following wording.
- Node label format, edge routing, glyph style, named node color, layout transform, and layout are visual variation only.
- The task enables the full node-link layout set for generation: the three original layouts plus grid, layered, clustered, path-spine, and radial-tree layouts.
- When
label_variant=named, prompt references to source and goal nodes are quoted, for example node"Lima". - The prompt never refers to node position, color, or shape as semantic annotation.
6) Determinism + constraints¶
- Deterministic sampling/rendering from
instance_seed. - Answers and annotation come from the same finalized adjacency map and verified unique-shortest-path computation.
- Generation rejects graphs with no path or more than one shortest path between the queried endpoints under the selected directionality.
7) Complexity + tests¶
- Complexity components:
topology_reasoning,visual_scan,ambiguity,clutter - Tests:
tests/test_graph_path_shortest_path_length_contracts.py,tests/test_graph_path_shortest_path_length_tasks.py,tests/test_scene_config.py