Forellin brings weighted-graph review into a Windows project conversation. Ask a compatible model to examine forest selection and disconnected inputs, then check its suggested edges before accepting code.
A concrete starting point · Minimum spanning forests ×
def spanning_forest(count, edges):
if type(count) is not int or not 0 <= count <= 64 or type(edges) is not list or len(edges) > 1024:
raise ValueError("forest.input")
ordered = []
for edge in edges:
if type(edge) not in (list, tuple) or len(edge) != 3 or any(type(x) is not int for x in edge):
raise ValueError("forest.edge")
a, b, weight = edge
if not 0 <= a < count or not 0 <= b < count or abs(weight) > 10**9:
raise ValueError("forest.bounds")
ordered.append((weight, min(a, b), max(a, b)))
parent = list(range(count))
def root(node):
while parent[node] != node:
parent[node] = parent[parent[node]]
node = parent[node]
return node
selected, total = [], 0
for weight, a, b in sorted(ordered):
x, y = root(a), root(b)
if x != y:
parent[x] = y
selected.append((a, b, weight))
total += weight
return total, selected
✳Minimum spanning forests
✓ ChangesReview before applying ↗
Illustrative workspace
Review before applying
Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.
Connection
Base URL, credentials and a reachable server.
Project
Test disconnected nodes, parallel edges, self-loops and deterministic ties, rejecting invalid endpoints or Boolean values without changing the input.
def spanning_forest(count, edges):
if type(count) is not int or not 0 <= count <= 64 or type(edges) is not list or len(edges) > 1024:
raise ValueError("forest.input")
ordered = []
for edge in edges:
if type(edge) not in (list, tuple) or len(edge) != 3 or any(type(x) is not int for x in edge):
raise ValueError("forest.edge")
a, b, weight = edge
if not 0 <= a < count or not 0 <= b < count or abs(weight) > 10**9:
raise ValueError("forest.bounds")
ordered.append((weight, min(a, b), max(a, b)))
parent = list(range(count))
def root(node):
while parent[node] != node:
parent[node] = parent[parent[node]]
node = parent[node]
return node
selected, total = [], 0
for weight, a, b in sorted(ordered):
x, y = root(a), root(b)
if x != y:
parent[x] = y
selected.append((a, b, weight))
total += weight
return total, selected
AI coding workspace
Make disconnected inputs part of the graph software contract
Forellin gives developers a Windows AI coding workspace for examining graph-processing code together with the application that relies on it. Start a project conversation with the input representation and the result the caller needs. Ask the assistant to inspect how the implementation handles missing connections, repeated edges and output ordering before proposing a change. Those choices shape the feature as much as the central calculation.
The spanning_forest.py context suggests a task where disconnected nodes are expected rather than treated as a failed attempt to connect everything. You could ask the model to explain which edges are selected and how the total relates to them. Review the answer against a small graph you can check by hand, then request a focused patch if the result contract or validation needs adjustment.
Run project checks on connected and disconnected inputs and inspect how isolated nodes are represented by the surrounding application. If several valid results exist, agree on whether deterministic selection matters to the consumer. Forellin accepts supported OpenAI-compatible or Anthropic endpoints with credentials when necessary. An unfiltered AI model can be chosen when offered, but model restrictions, tools and context capacity remain dependent on the configured service. The workspace supports your investigation; the graph examples and test results support acceptance of the code.
Questions for a graph-processing change
Should disconnected input always be rejected?
Only if the application requires a single connected structure. For a forest result, disconnected components may be valid. State that distinction before requesting a fix so the assistant does not force connections that the input never provided.
What if multiple edge selections have the same total?
Decide whether any valid optimum is acceptable or the consumer needs repeatable selection. If ordering or tie behavior matters, make it part of the expected result and test it explicitly rather than relying on incidental input order.
How do I check the reported total?
Use a small example and compare the selected edges with their summed weights independently. Also inspect whether the caller expects only the total or the selected structure, because those outputs support different application behavior.
Why test isolated nodes separately?
They can disappear from an edge-only result even when the input includes them. Check the surrounding representation and decide how the application should retain or display those nodes, rather than assuming the selected edges describe every vertex.