Advanced Patterns
Description
Advanced Patterns
Pattern 1: Graph Traversal
Find all transitive dependencies of a task.
deps = graph.transitive_deps("task-001", relationship="blocked_by")
print(f"Task depends on: {deps}")
Pattern 2: Bottleneck Detection
Find tasks that block the most other tasks.
bottlenecks = graph.find_bottlenecks(top_n=5)
for task_id, blocked_count in bottlenecks:
print(f"{task_id} blocks {blocked_count} tasks")
Pattern 3: Agent Coordination
Multiple agents working on the same graph.
from htmlgraph.agents import AgentInterface
agent = AgentInterface(".", agent_id="agent-1")
# Get next available task
task = agent.get_next_task(priority="high")
# Claim it
agent.claim_task(task.id, agent_id="agent-1")
# Work on it...
agent.complete_step(task.id, step_index=0)
# Complete it
agent.complete_task(task.id)
Pattern 4: Visualization
Generate Mermaid diagrams of your graph.
mermaid = graph.to_mermaid(relationship="blocked_by")
print(mermaid)
# Paste into https://mermaid.live/