CComponentWisp
AI coding workspace

Directed strongly connected components

ComponentWisp brings directed connectivity questions into a Windows project conversation. Supply your adjacency representation, ask a compatible model about strongly connected groups, and inspect the resulting traversal instead of assuming every reachable vertex belongs to one component.

● ● ●ComponentWisp●
A concrete starting point · Directed strongly connected components ×
def strong_components(graph):
    if type(graph) is not list or len(graph) > 64:
        raise ValueError("scc.graph")
    n = len(graph)
    if any(type(row) is not set or any(type(v) is not int or not 0 <= v < n for v in row) for row in graph):
        raise ValueError("scc.edge")
    seen, order = set(), []
    for start in range(n):
        if start in seen:
            continue
        seen.add(start)
        stack = [(start, iter(sorted(graph[start])))]
        while stack:
            node, edges = stack[-1]
            target = next(edges, None)
            if target is None:
                order.append(node)
                stack.pop()
            elif target not in seen:
                seen.add(target)
                stack.append((target, iter(sorted(graph[target]))))
    reverse = [set() for _ in graph]
    for node, edges in enumerate(graph):
        for target in edges:
            reverse[target].add(node)
    seen, result = set(), []
    for start in reversed(order):
        if start in seen:
            continue
        group, pending = [], [start]
        seen.add(start)
        while pending:
            node = pending.pop()
            group.append(node)
            for target in reverse[node]-seen:
                seen.add(target)
                pending.append(target)
        result.append(sorted(group))
    return sorted(result)
✳Directed strongly connected components
✓ ChangesReview before applying ↗
Illustrative workspace
  1. Review before applying

    Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.

  2. Connection

    Base URL, credentials and a reachable server.

  3. Project

    Test cycles, isolated vertices and empty input, rejecting invalid set members without changing the adjacency sets.

Workflows

Directed strongly connected components

Workflows ↗
A concrete starting point
def strong_components(graph):
    if type(graph) is not list or len(graph) > 64:
        raise ValueError("scc.graph")
    n = len(graph)
    if any(type(row) is not set or any(type(v) is not int or not 0 <= v < n for v in row) for row in graph):
        raise ValueError("scc.edge")
    seen, order = set(), []
    for start in range(n):
        if start in seen:
            continue
        seen.add(start)
        stack = [(start, iter(sorted(graph[start])))]
        while stack:
            node, edges = stack[-1]
            target = next(edges, None)
            if target is None:
                order.append(node)
                stack.pop()
            elif target not in seen:
                seen.add(target)
                stack.append((target, iter(sorted(graph[target]))))
    reverse = [set() for _ in graph]
    for node, edges in enumerate(graph):
        for target in edges:
            reverse[target].add(node)
    seen, result = set(), []
    for start in reversed(order):
        if start in seen:
            continue
        group, pending = [], [start]
        seen.add(start)
        while pending:
            node = pending.pop()
            group.append(node)
            for target in reverse[node]-seen:
                seen.add(target)
                pending.append(target)
        result.append(sorted(group))
    return sorted(result)
AI coding workspace

Give dependency groups a meaning the application can use

ComponentWisp is a Windows AI coding workspace for developers tracing relationships through project data and code. Bring the graph representation and the consumer that needs its groups into the conversation. Ask the assistant to inspect what a directed edge means before proposing a grouping change. A result is useful only when the relationships it preserves match the question your application is trying to answer.

A task around strong_components.py could examine groups whose vertices can reach one another through directed paths. Use a small dependency example to distinguish mutual reachability from a one-way connection, then review the implementation and its output ordering. If you are applying the code to dependencies, make the mapping from real objects to vertices explicit; the helper alone cannot establish what those dependencies mean.

After reading a proposal, run the project checks with a cycle, a one-way link and isolated vertices. Inspect the consumer to confirm it treats the resulting groups consistently. ComponentWisp connects to supported OpenAI-compatible or Anthropic endpoints, with credentials when required. Unrestricted models may be selected where offered, while the model and server determine restrictions, tools and context limits. Keep the meaning of the edges and the expected groups in the conversation so subsequent edits preserve the same software requirement.

Questions about dependency grouping code

Is a one-way dependency enough to put objects together?

Not for a group defined by mutual directed reachability. State the intended grouping rule and include a one-way example, so a proposed implementation does not accidentally treat a directed relationship as an undirected connection.

How should real project objects map to vertices?

Keep an explicit mapping that the consumer can use to interpret results. Inspect what happens when objects are removed or reordered, and test that the returned groups still refer to the intended project objects.

Does grouping dependencies decide an execution order?

It answers a different question. Your application may need additional logic to order groups or handle cycles. Identify that requirement separately and inspect the relevant consumer rather than assuming a partition is a complete execution plan.

Why include isolated vertices in the checks?

They verify that objects without edges still receive the representation your application expects. Check both the helper output and the consumer view, especially if a refactor builds intermediate structures by iterating only over existing connections.

Get the Windows app ↗

ComponentWisp · Updated 2026-10-25