Skip to main content

Build and visualize orbit graphs for discrete iterations under guarded rules.

Project description

VisIter

Build and visualize orbit graphs for discrete iterations under guarded rules.

VisIter is a small library that does two complementary things:

  1. iterate(start, rules, default=..., max_depth=..., ...) — applies a list of guard-and-operation Rules to seed values via BFS, producing a graph (nodes, edges, per-node depth, optional pseudo-edges marking structural boundaries).

  2. to_dot(graph, ...) — turns the graph into a Graphviz Digraph for SVG/HTML/PDF rendering, with anchor/radius cropping, per-rule edge coloring, wedged-pie node fills for branching nodes, and dashed ghost stubs at every kind of cut boundary.

The two are independent: any graph dict that fits the documented shape can be rendered, and iterate can be used purely for graph construction without ever touching the renderer.

Install

pip install visiter

Graphviz must be available on PATH for image rendering (the Python graphviz package wraps the system tool).

Quickstart — descent with divisor rule

A rule that divides by three when applicable, with a +2 fallback for all other values. Every integer path eventually joins one of two small cycles (1 → 3 → 1, 2 → 4 → 6 → 2).

from visiter import iterate, Op, Rule, to_dot

graph = iterate(
    start=range(1, 30),
    rules=[Rule(lambda x: x % 3 == 0, Op(lambda x: x // 3, label="÷3"))],
    default=Op(lambda x: x + 2, label="+2"),
)
dot = to_dot(graph, anchor=1, radius=8, direction="backward")
dot.render("descent", format="svg")

Quickstart — reverse binary tree with bound

Generate every positive integer up to a ceiling as the binary tree of ×2 / ×2+1 successors of 1. Rule.bound keeps the expansion inside the ceiling; to_dot draws the frontier as dashed ghost stubs.

from visiter import iterate, Op, Rule, to_dot

ceiling = 64

graph = iterate(
    start=[1],
    rules=[
        Rule(lambda x: True,
             Op(lambda x: 2 * x, label="×2"),
             bound=lambda x: 2 * x <= ceiling),
        Rule(lambda x: True,
             Op(lambda x: 2 * x + 1, label="×2+1"),
             bound=lambda x: 2 * x + 1 <= ceiling),
    ],
    default=None,
)
dot = to_dot(graph, show_binary=True)
dot.render("binary_tree", format="svg")

CLI

Two entry points, same Python API underneath:

  • viter — one-shot alias for the full pipeline. Takes the iterate argstring and writes the rendered image directly. Safe defaults (--max-nodes 10000, --time-limit 00:00:30, stop with a warning on overflow) keep a typo'd rule from running away.
  • visiter — pipe-composable subcommands (build, to-dot, validate, analyze, render) for when you want to save the JSON, validate it, run NetworkX over it, or render the same data multiple ways.

Quickstart via viter:

viter 'range(1, 30),
       [Rule(lambda x: x%3==0, Op(lambda x: x//3, label="÷3"))],
       default=Op(lambda x: x+2, label="+2")' \
  --render 'anchor=1, radius=8, direction="backward"' \
  -o descent.svg

Same thing via the visiter pipeline (JSON on the wire, no safety caps — spelled out for full control):

visiter build 'range(1, 30),
               [Rule(lambda x: x%3==0, Op(lambda x: x//3, label="÷3"))],
               default=Op(lambda x: x+2, label="+2")' \
  | visiter to-dot 'anchor=1, radius=8, direction="backward"' \
  | dot -Tsvg > descent.svg

The validate subcommand checks a graph JSON document against the bundled JSON Schema (schemas/v1/graph.schema.json, Draft 2020-12):

pip install visiter[validate]
visiter build '...' | visiter validate

The analyze subcommand bridges to NetworkX so you can run any of its hundreds of graph algorithms on the output (cycles, shortest paths, centrality, strongly-connected components, ...) — and when the algorithm returns a NetworkX graph itself, it flows straight back into visiter to-dot:

pip install visiter[analytics]
visiter build '...' \
  | visiter analyze 'nx.condensation(graph)' \
  | visiter to-dot '' | dot -Tsvg > scc.svg

Why VisIter?

The short pitch: VisIter is free, scriptable, Graphviz-native, Unix-pipe-composable orbit-graph rendering for discrete iterations under guarded rules — with cutoff boundaries (bounds, depth limits, render crops) as a first-class visual primitive, not silent truncation.

If you have a Mathematica license, NestGraph covers the core BFS. For term rewriting with equational theories, use Maude. For Petri-net reachability, LoLA. For generic graph analytics, NetworkX. For the specific combination of "Python + rule-driven reachability from a seed + opinionated rendering + shell pipes", the niche is small but real.

Full honest comparison against NetworkX, NestGraph, Maude, LoLA, and continuous-dynamics tooling: docs/comparison.md.

Documentation

  • docs/tutorial.md — gentle introduction: what problem the tool solves, smallest example, what each piece does, what the dashed arrows mean. Start here.
  • docs/manual.md — reference: every parameter, every data field, the rendering model in full, design decisions.
  • docs/comparison.md — how VisIter relates to other tools in the ecosystem, and when to pick something else.
  • demos/ — runnable end-to-end examples: make demo writes SVG/PDF/DOT into demos/out/.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

visiter-0.7.1.tar.gz (188.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

visiter-0.7.1-py3-none-any.whl (29.3 kB view details)

Uploaded Python 3

File details

Details for the file visiter-0.7.1.tar.gz.

File metadata

  • Download URL: visiter-0.7.1.tar.gz
  • Upload date:
  • Size: 188.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for visiter-0.7.1.tar.gz
Algorithm Hash digest
SHA256 6b02f10481430a7aa7e2f2a1dce5485da308d387b5aceb801d63614666fd0b36
MD5 f504d443f23f3360732fff74c2f52091
BLAKE2b-256 a889bf226878f09fad3bfa9203a540943894188d91277247b6b6b680c4fbd8f9

See more details on using hashes here.

File details

Details for the file visiter-0.7.1-py3-none-any.whl.

File metadata

  • Download URL: visiter-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 29.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for visiter-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ef46954b0093683467d92ef1a67a2295703200ec2fc83a0b59e994abeebb2cae
MD5 06344a887201d7923c274498f2d4556c
BLAKE2b-256 d99bc3235db9bc5b901f02d9299f991352a358546bf39570c7b7f44426165686

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page