ArcGIS Pro 2.9 API Reference Guide
TraverseAssociationsDescription Constructor(TraversalDirection,Int32)
Example 

ArcGIS.Core.Data.UtilityNetwork Namespace > TraverseAssociationsDescription Class > TraverseAssociationsDescription Constructor : TraverseAssociationsDescription Constructor(TraversalDirection,Int32)
Specifies the direction to perform the association traversal.
Specifies the maximum number of hops through the association graph to traverse in a specified traversalDirection
Initializes a new instance of TraverseAssociationsDescription with a full traversal in a specified TraversalDirection with a user-defined depth limit.
Syntax
public TraverseAssociationsDescription( 
   TraversalDirection traversalDirection,
   int maximumDepth
)
Public Function New( _
   ByVal traversalDirection As TraversalDirection, _
   ByVal maximumDepth As Integer _
)

Parameters

traversalDirection
Specifies the direction to perform the association traversal.
maximumDepth
Specifies the maximum number of hops through the association graph to traverse in a specified traversalDirection
Example
public static void GetTraverseAssociationsResultFromDownwardTraversal(UtilityNetwork utilityNetwork, IReadOnlyList<Element> startingElements)
{
  // Set downward traversal with maximum depth
  TraverseAssociationsDescription traverseAssociationsDescription = new TraverseAssociationsDescription(TraversalDirection.Descending);

  // Get traverse associations result from the staring element up to maximum depth
  TraverseAssociationsResult traverseAssociationsResult = utilityNetwork.TraverseAssociations(startingElements, traverseAssociationsDescription);

  // Get associations participated in traversal
  IReadOnlyList<Association> associations = traverseAssociationsResult.Associations;
}
public static void GetTraverseAssociationsResultFromUpwardTraversalWithDepthLimit(UtilityNetwork utilityNetwork, IReadOnlyList<Element> startingElements)
{
  // List of fields whose values will be fetched as name-values pairs during association traversal operation
  List<string> additionalFieldsToFetch = new List<string> { "ObjectId", "AssetName", "AssetGroup", "AssetType" };

  // Set downward traversal with maximum depth level of 3 
  TraverseAssociationsDescription traverseAssociationsDescription = new TraverseAssociationsDescription(TraversalDirection.Ascending, 3) { AdditionalFields = additionalFieldsToFetch };

  // Get traverse associations result from the staring element up to depth level 3
  TraverseAssociationsResult traverseAssociationsResult = utilityNetwork.TraverseAssociations(startingElements, traverseAssociationsDescription);

  // List of associations participated in traversal
  IReadOnlyList<Association> associations = traverseAssociationsResult.Associations;

  // KeyValue mapping between involved elements and their field name-values 
  IReadOnlyDictionary<Element, IReadOnlyList<AssociationElementFieldValue>> associationElementValuePairs = traverseAssociationsResult.AdditionalFieldValues;

  foreach (KeyValuePair<Element, IReadOnlyList<AssociationElementFieldValue>> keyValuePair in associationElementValuePairs)
  {
    // Element 
    Element element = keyValuePair.Key;

    // List of field names and their values 
    IReadOnlyList<AssociationElementFieldValue> elementFieldValues = keyValuePair.Value;
  }
}
Requirements

Target Platforms: Windows 11, Windows 10, Windows 8.1

See Also

Reference

TraverseAssociationsDescription Class
TraverseAssociationsDescription Members
Overload List