Skip to main content

Elegant visualizer and analyzer for LangGraph-like workflow graphs

Project description

🌀 LangFlow-Viz

A Python Library for Workflow Graph Visualization & Analysis

LangFlow-Viz is a lightweight yet powerful toolkit for building, analyzing, and visualizing directed workflow graphs.

It provides modular components to model process flows, detect structural insights (like cycles and dead ends), and generate beautiful visualizations in Graphviz, Mermaid, and HTML formats — all with a few lines of Python.

PyPI Python versions License: MIT

✨ Key Features

  • 🧩 StateGraph Builder — Create nodes, edges, and conditional (dashed) branches programmatically
  • 🔍 GraphAnalyzer — Automatically detect cycles, isolated nodes, and compute longest paths
  • 🎨 Visualizer — Export high-quality workflow diagrams (SVG, PNG, Mermaid, HTML)
  • ⚙️ Modular Design — Use each module independently or together
  • 🪄 Fully Customizable — Override colors, shapes, fonts, and themes via a global STYLE dictionary
  • 🔁 Supports Parallel & Conditional Flows — Model real-world pipelines and decision trees effortlessly

📦 Installation

Install directly from PyPI:

pip install langflow-viz

Or from source:

git clone https://github.com/yourusername/langflow-viz.git
cd langflow-viz
pip install -e .

🚀 Quick Start

Example 1: Simple Sequential Workflow

from langflow_viz import Visualizer, analyze_graph

# Define a simple flow
nodes = ["start", "plan", "act", "reflect", "finish"]
edges = [
    ("start", "plan"),
    ("plan", "act"),
    ("act", "reflect"),
    ("reflect", "finish")
]

# Analyze
report = analyze_graph(nodes, edges)
print("📊 Graph Analysis:", report)

# Visualize
viz = Visualizer("LangFlowViz_Test", nodes, edges)
viz.render_all()

🧾 Output:

  • SVG: outputs/LangFlowViz_Test.svg
  • Mermaid: outputs/LangFlowViz_Test.mmd
  • PNG / HTML: Optional rich export formats

Example 2: Conditional Workflow (Decision Branches)

from langflow_viz.graph import StateGraph
from langflow_viz import Visualizer

# Define workflow graph
graph = StateGraph()
graph.add_edge("start", "classify")
graph.add_conditional_edge("classify", "creative")
graph.add_conditional_edge("classify", "general")
graph.add_conditional_edge("classify", "technical")
graph.add_edge("creative", "end")
graph.add_edge("general", "end")
graph.add_edge("technical", "end")

# Visualize and export
viz = Visualizer(
    name="ConditionalFlow",
    nodes=graph.get_nodes(),
    edges=graph.get_edges(),
    conditional_edges=graph.conditional_edges  
)
viz.render_all()

💡 Conditional edges appear as dashed lines, representing optional or decision-based transitions.


Example 3: Parallel Tasks / Merge Flow

from langflow_viz.graph import StateGraph
from langflow_viz import Visualizer, analyze_graph

g = StateGraph()
g.add_edge("start", "task_A")
g.add_edge("start", "task_B")
g.add_edge("task_A", "merge")
g.add_edge("task_B", "merge")
g.add_edge("merge", "end")

print(analyze_graph(g.get_nodes(), g.get_edges()))

viz = Visualizer("ParallelFlow", g.get_nodes(), g.get_edges())
viz.render_all()

🧠 Core Modules & API Reference

🧩 StateGraph — Build Workflows

langflow_viz.graph.state_graph

Method Description
add_node(name) Add a node if not already present
add_edge(src, dst, conditional=False) Add a directed edge (supports dashed/conditional edges)
add_conditional_edge(src, dst) Shortcut for dashed conditional edge
get_nodes() Return list of nodes
get_edges() Return list of all edges
get_conditional_edges() Return set of all dashed conditional edges

🔍 GraphAnalyzer — Analyze Graph Topology

langflow_viz.graph.analyzer

Method Description
summary() Returns node count, edge count, cycle detection, dead ends, and longest path
has_cycles() Detect if graph contains cycles
find_dead_ends() Identify nodes with no outgoing connections
longest_path_length() Compute the longest directed path length

Shortcut:

from langflow_viz import analyze_graph
report = analyze_graph(nodes, edges)

🎨 Visualizer — Create Beautiful Diagrams

langflow_viz.visualizer.visualizer

Method Description
build_graph() Builds internal Graphviz structure
render_all() Exports SVG, PNG, Mermaid, and HTML files
to_mermaid(nodes, edges) Generates Mermaid diagram text
to_svg() Exports as SVG file
to_html(mermaid_text) Creates interactive HTML preview

Constructor:

Visualizer(name: str, nodes: List[str], edges: List[Tuple[str, str]], conditional_edges: Optional[Set[Tuple[str, str]]] = None)

📤 Exporter — Format Conversion Layer

langflow_viz.visualizer.exporter

Method Description
to_mermaid(nodes, edges, dashed_edges) Convert to Mermaid syntax
to_svg() Export to SVG via Graphviz
to_png() Export to PNG
to_html(mermaid_text) Generate interactive HTML view

🖌 STYLE — Customize Visuals

langflow_viz.visualizer.style

from langflow_viz.visualizer import STYLE

STYLE["node"]["fillcolor"] = "#E8DAEF"
STYLE["edge"]["color"] = "#8E44AD"

🧪 Testing

Test the library locally using:

python -m test_demo

Expected Output:

📊 Graph Analysis: {'nodes': 5, 'edges': 4, 'has_cycles': False, 'dead_ends': ['finish'], 'longest_path': 4}
✅ SVG saved at: outputs/LangFlowViz_Test.svg
✅ Mermaid saved at: outputs/LangFlowViz_Test.mmd


🤝 Contributing

Contributions are welcome!

To set up your development environment:

git clone https://github.com/yourusername/langflow-viz.git
cd langflow-viz
python -m venv .venv
source .venv/bin/activate  # or .venv\Scripts\activate on Windows
pip install -e ".[dev]"

🧩 Run Tests

pytest

🧱 Submit a Pull Request

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/new-feature)
  3. Commit your changes (git commit -m 'Add new visualization option')
  4. Push and open a Pull Request

📘 Documentation

Comprehensive developer documentation is coming soon at:

👉 https://langflow-viz.readthedocs.io


🧾 License

Licensed under the MIT License © 2025

Developed and maintained by the LangFlow-Viz Team.


💬 Community

Join the discussion, share workflows, and suggest improvements:

📢 GitHub Discussions → https://github.com/Sarjak369/langflow-viz/discussions


🌟 Why LangFlow-Viz?

LangFlow-Viz helps developers, researchers, and AI engineers visualize and analyze workflow graphs effortlessly.

It’s built for clarity, precision, and speed — designed to turn your logical pipelines into beautiful, meaningful diagrams.

🪶 Attribution

All design, icons, and visual elements are purely for illustrative and educational purposes.

LangFlow-Viz is open-source and welcomes contributions, improvements, and feature requests from the community.

That’s it — happy visualizing! ✨

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

langflow_viz-0.2.2.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

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

langflow_viz-0.2.2-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file langflow_viz-0.2.2.tar.gz.

File metadata

  • Download URL: langflow_viz-0.2.2.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for langflow_viz-0.2.2.tar.gz
Algorithm Hash digest
SHA256 8cb6791c106e50eea353eae75e4127598bdadd0d27a674328f8b1d49f99b265d
MD5 cd2c975556bb013ee6529621cd38cd08
BLAKE2b-256 3eccc9e90027e11cd91a6a0efed7432306c18126a349e82ca0e9dfd9295ef2db

See more details on using hashes here.

Provenance

The following attestation bundles were made for langflow_viz-0.2.2.tar.gz:

Publisher: publish.yml on Sarjak369/langflow-viz

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file langflow_viz-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: langflow_viz-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for langflow_viz-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2443f7c26da3fe20baf8f3553d7b3e2dc59422c910686964c71982813eb4361f
MD5 7f954ee091829b06e25adf37b161c2ee
BLAKE2b-256 6d7d3395b4d7f458a4bd1b89b38e052f08ddd3f6678302977fced1556c0ff984

See more details on using hashes here.

Provenance

The following attestation bundles were made for langflow_viz-0.2.2-py3-none-any.whl:

Publisher: publish.yml on Sarjak369/langflow-viz

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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