optNetwork

cycle

Description

The cycle action calculates the elementary cycles (simple circuits) of a graph. A cycle is a path that starts and ends at the same node and visits other nodes at most once. This action supports both directed and undirected graphs and provides options to filter cycles based on their length (number of links) or total weight. It is widely used in fraud detection, process analysis, and circular dependency resolution.

Settings
ParameterDescription
directionSpecifies whether the graph is directed or undirected. Default is UNDIRECTED.
linksSpecifies the input data table that contains the graph link information (edges).
nodesSpecifies the input data table that contains the graph node information.
maxCyclesSpecifies the maximum number of cycles to return. The default is 1. Set to 'ALL' to find all cycles.
minLengthSpecifies the minimum number of links required for a cycle to be included in the results.
maxLengthSpecifies the maximum number of links allowed for a cycle to be included in the results.
outSpecifies the output data table to contain the nodes of the identified cycles.
outCyclesLinksSpecifies the output data table to contain the links of the identified cycles.
Data Preparation View data prep sheet
Graph Data Creation

Creates a dataset defining a directed graph with two potential cycles: A-B-C-A (total weight 6) and A-D-C-A (total weight 18).

Copied!
1DATA mycas.LinkSetIn;
2 INPUT from $ to $ weight;
3 DATALINES;
4 A B 1
5 B C 2
6 C A 3
7 A D 10
8 D C 5
9 ;
10RUN;

Examples

Detects a cycle in the directed graph using default settings (returns the first cycle found).

SAS® / CAS Code Code awaiting community validation
Copied!
1PROC CAS;
2 optNetwork.cycle RESULT=r STATUS=s /
3 direction="DIRECTED",
4 links={name="LinkSetIn"},
5 out={name="CyclesNodes", replace=true},
6 outCyclesLinks={name="CyclesLinks", replace=true};
7RUN;
Result :
The action finds one of the cycles (e.g., A-B-C-A) and exports the node and link details to the specified output tables.

Finds all cycles that meet a specific weight criteria (total weight >= 10) by using the 'minLinkWeight' parameter.

SAS® / CAS Code Code awaiting community validation
Copied!
1PROC CAS;
2 optNetwork.cycle RESULT=r STATUS=s /
3 direction="DIRECTED",
4 links={name="LinkSetIn"},
5 maxCycles="ALL",
6 minLinkWeight=10,
7 out={name="HeavyCycles", replace=true};
8RUN;
Result :
Only the cycle A-D-C-A is returned because its total weight (18) meets the minimum threshold, unlike the A-B-C-A cycle.

FAQ

What is the primary purpose of the cycle action in the optNetwork action set?
Which algorithms are available for enumerating cycles in the cycle action?
How is the default algorithm determined if not explicitly specified?
How can I specify whether the input graph is directed or undirected?
What does the `deterministic` parameter control?
How can I limit the number of cycles returned by the action?
What parameters allow filtering cycles based on their length?
How can I filter cycles based on link weights?
How can I filter cycles based on node weights?
What input tables are used by the cycle action?
Which parameter specifies the output table for the nodes of the cycles?
How can I get an output table containing the links of the cycles?
What does the `multiLinks` parameter do?
How can I control the maximum time the algorithm runs?
What information is returned in the action's results?

Associated Scenarios

Use Case
Anti-Money Laundering: Circular Transaction Detection

A banking institution needs to identify 'smurfing' or circular money laundering patterns where funds are transferred through a series of accounts and return to the originator (e...

Use Case
Manufacturing: Infinite Loop Detection in Large Processes

A car manufacturer wants to validate the Bill of Materials (BOM) for a new vehicle. With thousands of parts, they must ensure no process inadvertently waits for itself (Infinite...

Use Case
IT Infrastructure: Service Deadlocks & Self-Links

In a microservices architecture, mapping dependencies is crucial. The goal is to find 'Deadlocks' where a service waits for itself (Self-Link) or two services wait for each othe...