Choreo Analysis Algorithms Reference

Copy Markdown View Source

Choreo turns every diagram into a graph, then runs classic graph algorithms on it to answer practical questions: "Will this deployment order work?", "What breaks if this service fails?", "Where are the cycles?", and so on.

This guide catalogs the analysis functions in each diagram module, what question they answer, and the underlying algorithm they use. The implementations live in lib/choreo/analysis.ex, lib/choreo/internal.ex, the lib/choreo/*/analysis.ex modules, and lib/choreo/analysis/tracing.ex.

Most functions build on the yog_ex graph library, which provides BFS/DFS, topological sort, strongly connected components, shortest paths, MST, centrality, and connectivity primitives.


Supported diagram types

Diagram typeMain moduleAnalysis moduleTypical use
System architectureChoreoChoreo.AnalysisServices, databases, caches, queues
C4 modelChoreo.C4Choreo.C4.AnalysisSoftware architecture views
Cloud infrastructureChoreo.InfrastructureChoreo.Infrastructure.AnalysisVPC/subnet/security audits
Finite-state machinesChoreo.FSMChoreo.FSM.AnalysisState machines and automata
Dataflow / pipelinesChoreo.DataflowChoreo.Dataflow.AnalysisStreaming/data pipelines
Dependency graphsChoreo.DependencyChoreo.Dependency.AnalysisModule/library dependencies
Decision treesChoreo.DecisionTreeChoreo.DecisionTree.AnalysisClassification trees
Threat modelsChoreo.ThreatModelChoreo.ThreatModel.AnalysisSTRIDE threat modeling
WorkflowsChoreo.WorkflowChoreo.Workflow.AnalysisBPMN/saga workflows
Planner / tasksChoreo.PlannerChoreo.Planner.AnalysisProject/task planning
Mind mapsChoreo.MindMapChoreo.MindMap.AnalysisHierarchical idea maps
Entity-relationship diagramsChoreo.ERDChoreo.ERD.AnalysisDatabase schemas
UML class diagramsChoreo.UMLChoreo.UML.AnalysisSoftware design
Domain / event stormingChoreo.DomainChoreo.Domain.AnalysisDomain-driven design
Sequence diagramsChoreo.SequenceChoreo.Sequence.AnalysisMessage sequence validation
RequirementsChoreo.RequirementChoreo.Requirement.AnalysisRequirements traceability
Cross-diagram tracingChoreo.Analysis.TracingTrace edges across diagrams

Core / cross-cutting analysis

Choreo.Analysis — system architecture

These functions operate on the general Choreo architecture graph. Many of them are re-used or mirrored by diagram-specific modules.

FunctionPurposeAlgorithm used
mst/2Cheapest way to connect all servicesMST — Kruskal (default), Prim, or Borůvka on an undirected simple graph
topological_sort/1Deployment or execution orderTopological sort via Yog.Traversal.topological_sort/1 (Kahn / DFS-based)
cyclic?/1Detect feedback loopsCycle detection via Yog.cyclic?/1
dag?/1Check if the graph is acyclicAcyclicity check via Yog.acyclic?/1
strongly_connected_components/1Find mutually dependent servicesStrongly Connected Components (SCC) via Yog.Connectivity
single_points_of_failure/1Find articulation points and bridge edgesTarjan's articulation-point/bridge algorithm on an undirected view
cut_vertices/1Nodes whose removal disconnects the graphTarjan's articulation points
impact_analysis/2What breaks if a node failsBFS on the transposed graph
shortest_path/4Cheapest/fastest route between servicesDijkstra / shortest path with semiring support (cost, latency, custom metrics)
path/4Domain-specific pathfindingDijkstra / widest path with measures :shortest, :latency, :throughput, :risk, :weighted
centrality/2Most critical or coupled nodesDegree / betweenness / closeness / PageRank centrality via Yog.Centrality
core_numbers/1K-core decompositionK-core decomposition via Yog.Connectivity.core_numbers/1
reduce_transitive/1Remove redundant edges while preserving reachabilityTransitive reduction
isolated_nodes/1Find orphan servicesIn-degree + out-degree check
heatmap/2Color nodes by centrality or scoreCentrality → min-max normalization → color scale
validate/1Structural health checkComposite: isolated nodes, SPOF, cycles, bridges

Choreo.Analysis.Tracing — cross-diagram tracing

FunctionPurposeAlgorithm used
impact_analysis/2Nodes transitively impacted via trace edgesBFS on the transposed trace-only graph
trace_path/3Shortest trace path between two nodesDijkstra on the trace-only graph
analyze/3Nested cross-domain analysis along a trace pathPath reconstruction + domain metadata classification

Choreo.Internal — shared graph primitives

FunctionPurposeAlgorithm used
bfs_reachable/2Reachable nodes from seed nodesBreadth-First Search (BFS)
transitive_reduction/1Redundant edges implied by longer pathsBFS reachability from alternate successors
compute_dp/3Longest-path DP tableDynamic programming over a topological order
find_best_end_path/2Best predecessor chainLinear scan of the DP table
reconstruct_path/2Reconstruct a path from DP predecessorsBacktracking
dfs_cycles/1All elementary cycles in a multigraphDepth-First Search (DFS) with recursion-stack tracking
unsatisfied_contract/3Missing functions for a contractSet difference on function name/arity

Diagram-specific analysis

Choreo.C4.Analysis — C4 architecture model validation

FunctionPurposeAlgorithm used
isolated_nodes/1Elements with no relationshipsIn-degree + out-degree on a simple graph
missing_parents/1Containers/components without parentsMetadata filter
missing_descriptions/1Nodes lacking descriptionsMetadata filter
missing_technology/1Containers/components without technology labelsMetadata filter
missing_relationship_labels/1Relationships lacking labelsEdge metadata filter
parents_without_relationships/1Parent nodes with children but no edgesDegree + parent metadata check
validate/1Full C4 model validationComposite rule check

Choreo.Infrastructure.Analysis — cloud topology audits

FunctionPurposeAlgorithm used
validate/1Security audit (internet-to-private, DB placement, LB placement, etc.)Rule-based set membership checks on node/edge metadata
warnings/1Audit warningsRule-based set membership checks

Choreo.FSM.Analysis — finite-state machines

FunctionPurposeAlgorithm used
reachable_states/1States reachable from the initial stateBFS
dead_states/1States with no path to a final stateReverse BFS from final states
livelock_states/1Reachable non-accepting loop statesIntersection of reachable/dead + BFS self-reachability
accepts?/2Simulate input string acceptanceDeterministic walk
shortest_accepting_path/1Minimum input to reach acceptanceBFS
accepted_strings/2All accepted strings up to length NBFS level-order expansion
alphabet/1Distinct input symbolsSet construction
complete?/1Whether every state handles every symbolSet subset check
generate_test_cases/2Input sequences for state/transition coverageBFS shortest paths to all states
equivalent?/2Check if two FSMs accept the same languageProduct automaton BFS
minimize/1Minimize a DFAMoore's partition refinement
violates_invariant?/2Forbidden state sequence existsEdge existence check
validate/1Structural FSM validationComposite checks

Choreo.Dataflow.Analysis — streaming/data pipelines

FunctionPurposeAlgorithm used
sources/1 / sinks/1Identify source/sink nodesNode type filter
cyclic?/1Feedback-loop detectionCycle detection on the normal-edge subgraph
topological_sort/1Stage execution orderTopological sort
orphan_nodes/1Nodes unreachable from any sourceBFS from sources + set difference
dead_ends/1Nodes that cannot reach any sinkBFS on the transposed graph from sinks
fan_hubs/1High in-degree + out-degree stagesDegree threshold
longest_path/1Critical path (longest source→sink chain)DP over topological order
capacity_bottlenecks/1Stages where in_rate > capacityThroughput simulation via topological propagation
simulate/1Steady-state throughput simulationTopological-order traversal + rate summation
backpressure_points/1Nodes with inbound flow above thresholdSimulation result filter
upstream_lineage/1 / downstream_impact/1Ancestors/descendantsBFS (transposed for upstream)
upstream_sources/1 / downstream_sinks/1Source/sink subsets of lineageBFS + set intersection
heatmap/2Throughput heatmapSimulation → color scale
validate/1Pipeline structural validationComposite checks

Choreo.Dependency.Analysis — dependency graphs

FunctionPurposeAlgorithm used
cyclic_dependencies/1All circular dependency chainsSCC + DFS cycle extraction
affected_by/2Components that break if the target changesBFS on the transposed graph
depends_on/2Components the target depends onBFS
layer_violations/2Edges violating layered architectureEdge + layer-index comparison
centrality/2Most coupled componentsDegree centrality (in + out)
leaves/1 / roots/1Nodes with no dependents / no dependenciesIn-degree / out-degree filter
transitive_reduction/1Redundant explicit dependenciesTransitive reduction
instability/1Instability metric per componentCe / (Ca + Ce)
isolated_subsystems/1Disconnected component groupsWeakly connected components
longest_dependency_chain/1Deepest dependency chainDP over topological order
validate/1Dependency graph validationComposite checks

Choreo.DecisionTree.Analysis — decision trees

FunctionPurposeAlgorithm used
decide/2Evaluate tree against feature valuesTree walk
paths/1All root-to-leaf pathsDFS enumeration
paths_with_conditions/1Paths with branch conditionsDFS enumeration
depth/1 / breadth/1Tree depth / leaf countRecursive traversal / count
feature_importance/1Feature split frequencyGroup-by + count
reachable_outcomes/1Reachable outcome classesBFS
orphan_nodes/1Unreachable declared nodesBFS + set difference
rules/1Extract IF-THEN rulesPath-to-conditions mapping
generate_test_cases/1Feature maps covering every leafPath conditions
missing_branches/2Expected feature values not coveredSet difference
inconsistent_paths/1Logically impossible pathsPath condition grouping
prune_redundant/1Remove redundant decision nodesPost-order tree traversal
validate/1Tree structural validationComposite checks

Choreo.ThreatModel.Analysis — STRIDE threat modeling

FunctionPurposeAlgorithm used
stride_threats/2Generate STRIDE threatsRule-based generation by element type
threat_summary/1Threat distribution by category/severityAggregation
risk_score/2Total weighted risk scoreWeighted sum by severity
cross_boundary_flows/1Data flows crossing trust boundariesBoundary comparison
exposed_data_stores/1Data stores reachable from external entitiesBFS from external entities
attack_paths/1Paths from externals to data storesDFS path enumeration
high_risk_processes/1Low-trust processes accessing sensitive storesBFS + risk/trust checks
unencrypted_boundary_flows/1Unencrypted cross-boundary flowsEdge metadata + boundary check
heatmap/2Threat density heatmapThreat count → color scale
validate/1Threat model validationComposite checks

Choreo.Workflow.Analysis — workflows and orchestration

FunctionPurposeAlgorithm used
reachable_tasks/1Tasks reachable from start nodesBFS
orphan_tasks/1Tasks not reachable from startsBFS + set difference
dead_ends/1Tasks that cannot reach an end nodeBFS on the transposed graph from ends
critical_path/1Longest latency path start→endDP over topological order
parallelizable_tasks/1Tasks that can run in parallelTopological levels
compensable_tasks/1Tasks with compensation edgesEdge metadata check
uncompensated_paths/1Failing tasks without valid compensationBFS on the compensation subgraph
missing_compensations/1Retry-configured tasks lacking compensationsMetadata check
bottlenecks/2High-latency / high-retry tasksThreshold filter
simulate/1Estimated latency per taskTopological-order latency propagation
heatmap/2Cumulative latency heatmapSimulation → color scale
validate/1Workflow structural validationComposite checks

Choreo.Planner.Analysis — project/task planning

FunctionPurposeAlgorithm used
ready/1Tasks whose dependencies are doneStatus + dependency resolution
blocked/1Tasks with unresolved dependenciesStatus + dependency resolution
orphans/1Tasks not in any milestoneParent metadata check
critical_path/2Longest dependency chain by estimateDP over topological order
bottlenecks/1Tasks ranked by transitive downstream impactBFS reachability count
validate/1Structural integrity checksComposite: cycles, unassigned tasks, orphans, empty milestones

Choreo.MindMap.Analysis — mind maps

FunctionPurposeAlgorithm used
depth/1Maximum depth from rootDFS with cycle guard
breadth/1 / leaves/1Leaf count / leaf nodesOut-degree filter
orphan_nodes/1Nodes not reachable from rootBFS on branch edges
max_width/1Widest levelBFS level counting
paths/1All root-to-leaf pathsDFS enumeration
type_frequencies/1Node type compositionGroup-by + count
cyclic?/1Cycle in hierarchyCycle detection
suggest_merges/2Candidate node pairs to mergeJaccard similarity of neighborhoods
validate/1Structural validationComposite checks

Choreo.ERD.Analysis — database schemas

FunctionPurposeAlgorithm used
shortest_join_path/3Optimal join sequencePath finding on an undirected simple graph
cycles/1Circular foreign-key referencesDFS cycle detection
orphans/1Tables with no relationshipsDegree check
table_degrees/1In/out/total coupling per tableDegree metrics
affected_by/2Tables that reference target transitivelyBFS on the transposed graph
depends_on/2Tables the target depends onBFS
transitive_reduction/1Redundant relationshipsTransitive reduction
longest_dependency_chain/1Deepest FK cascadeDP over topological order
normalization_score/2Schema quality scoreHeuristic penalty scoring
validate/1ERD structural validationComposite checks

Choreo.UML.Analysis — UML class diagrams

FunctionPurposeAlgorithm used
cycles/1Circular dependency loopsDFS cycle detection
broken_contracts/1Incomplete interface/behavior realizationsContract function comparison
coupling_metrics/1Afferent/efferent coupling and instabilityIn/out degree + Ce/(Ca+Ce)
law_of_demeter_violations/1Structural Law of Demeter violationsTriplet enumeration (A→B, B→C, A→C)
affected_by/2Classes that depend on targetBFS on the transposed graph
depends_on/2Classes target depends onBFS
transitive_reduction/1Redundant relationshipsTransitive reduction
validate/1UML structural validationComposite checks

Choreo.Domain.Analysis — event storming / domain models

FunctionPurposeAlgorithm used
validate/1 / warnings/1Semantic validation of events/commands/policiesRule-based adjacency-map checks
ubiquitous_language/1Markdown glossary from nodesSort + format

Choreo.Sequence.Analysis — sequence diagrams

FunctionPurposeAlgorithm used
validate/1Full sequence diagram validationComposite checks
isolated_participants/1Participants with no messagesSet difference
missing_labels/1Messages without labelsMetadata filter
unknown_participants/1References to undeclared participantsSet membership check
unbalanced_activations/1Unmatched activate/deactivate pairsStack balance
unclosed_fragments/1Fragments opened but not closedStack balance on reversed events

Choreo.Requirement.Analysis — requirements traceability

FunctionPurposeAlgorithm used
orphan_requirements/1Requirements with no relationshipsSet difference
unsatisfied/1 / unverified/1Requirements missing satisfies/verifies edgesEdge metadata check
coverage/1Coverage ratiosSet operations
traceability_matrix/1Requirements → components/tests/stakeholdersEdge aggregation
requirements_for/2 / components_for/2Related nodes by edge typeEdge traversal
high_risk_gaps/1High-risk requirements not satisfied/verifiedSet intersection
risk_propagation/1Inherited risk from ancestorsRecursive ancestor traversal
unmitigated_risks/1High-risk items without lower-risk childrenRisk-level comparison
impact_of/2Upstream + downstream affected nodesBFS in both directions
circular_dependencies/1Cycles among requirement relationshipsTarjan's SCC
validate/1Requirements validationComposite checks

Algorithm index

A quick lookup of which algorithms appear where.

AlgorithmUsed by
BFSChoreo.Analysis.impact_analysis/2, Choreo.Dataflow reachability/lineage, Choreo.Dependency.affected_by/2, Choreo.ERD.affected_by/2, Choreo.UML.affected_by/2, Choreo.FSM, Choreo.Workflow, Choreo.MindMap, Choreo.ThreatModel.exposed_data_stores/1, Choreo.Requirement.impact_of/2, Choreo.Internal.bfs_reachable/2
DFSChoreo.ERD.cycles/1, Choreo.UML.cycles/1, Choreo.MindMap.paths/1, Choreo.DecisionTree.paths/1, Choreo.ThreatModel.attack_paths/1, Choreo.Internal.dfs_cycles/1
Topological sortChoreo.Analysis.topological_sort/1, Choreo.Dataflow, Choreo.Dependency.longest_dependency_chain/1, Choreo.ERD.longest_dependency_chain/1, Choreo.Workflow.critical_path/1, Choreo.Planner.critical_path/2, Choreo.Dataflow.simulate/1
SCC (Tarjan)Choreo.Analysis.strongly_connected_components/1, Choreo.Dependency.cyclic_dependencies/1, Choreo.Requirement.circular_dependencies/1
Articulation points / bridgesChoreo.Analysis.single_points_of_failure/1, Choreo.Analysis.cut_vertices/1 via Yog.Connectivity.analyze/1
Shortest path (Dijkstra)Choreo.Analysis.shortest_path/4, Choreo.Analysis.path/4, Choreo.Analysis.Tracing.trace_path/3
Widest pathChoreo.Analysis.path/4 (:throughput, :weighted)
MST (Kruskal/Prim/Borůvka)Choreo.Analysis.mst/2
Longest path in DAGChoreo.Dataflow.longest_path/1, Choreo.Dependency.longest_dependency_chain/1, Choreo.ERD.longest_dependency_chain/1, Choreo.Workflow.critical_path/1, Choreo.Planner.critical_path/2 via Choreo.Internal.compute_dp/3
Transitive reductionChoreo.Analysis.reduce_transitive/1, Choreo.Dependency.transitive_reduction/1, Choreo.ERD.transitive_reduction/1, Choreo.UML.transitive_reduction/1, Choreo.Internal.transitive_reduction/1
CentralityChoreo.Analysis.centrality/2 (degree, betweenness, closeness, PageRank)
K-core decompositionChoreo.Analysis.core_numbers/1
Weakly connected componentsChoreo.Dependency.isolated_subsystems/1
DFA minimization (Moore's partition refinement)Choreo.FSM.Analysis.minimize/1
Product automaton BFSChoreo.FSM.Analysis.equivalent?/2
Jaccard similarityChoreo.MindMap.Analysis.suggest_merges/2
Instability metricChoreo.Dependency.instability/1, Choreo.UML.coupling_metrics/1

Implementation notes

  • Most path and impact analyses work on a simple graph view produced by to_simple_graph/1 or Yog.Multi.to_simple_graph/1, which collapses parallel edges.
  • Topological-order DP (Choreo.Internal.compute_dp/3) is the shared implementation for longest/critical path calculations across Dataflow, Dependency, ERD, Workflow, and Planner.
  • Transitive reduction is implemented centrally in Choreo.Internal.transitive_reduction/1 and reused by Dependency, ERD, and UML.
  • BFS reachability (Choreo.Internal.bfs_reachable/2) is the shared primitive for downstream/upstream impact analysis across nearly all diagram types.