ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Core.Data.Knowledge.Analytics Namespace / KnowledgeGraphFilteredFindPathsResults Class / PathIndicesOrderedByIncreasingPathLength Property
Example

In This Topic
    PathIndicesOrderedByIncreasingPathLength Property
    In This Topic
    Returns an array of (path length, path index) ordered by increasing "path length".
    Syntax
    Public ReadOnly Property PathIndicesOrderedByIncreasingPathLength As ValueTuple(Of Long,Long)()
    public ValueTuple<long,long>[] PathIndicesOrderedByIncreasingPathLength {get;}
    Remarks
    The paths indexes present in this array are guaranteed to correspond to valid paths, i.e a subsequent call to MaterializePath using any of these indexes will return a non-null value.
    Example
    List out FFP Results by Path Length, Min Cost, Max Cost
    {
      //using ArcGIS.Core.Data.Knowledge.Extensions;
    
      await QueuedTask.Run(async () =>
      {
        var ffp_config = new CIMFilteredFindPathsConfiguration();
        ffp_config.Name = "List out FFP Results by Path Length, Min Cost, Max Cost";
        //set up config
        //...
    
        var results = kg.RunFilteredFindPaths(ffp_config);
    
        if (results.CountPaths == 0)
        {
          System.Diagnostics.Debug.WriteLine("FFP returned no paths");
          return;
        }
    
        //print out paths by increasing length, min cost, max cost
        var path_by_len_indices = (IEnumerable<long>)results.PathIndicesOrderedByIncreasingPathLength
                                    .Select(idx => idx.index);
        var path_by_min_cost = (IEnumerable<long>)results.PathIndicesOrderedByIncreasingMinPathCost
                                    .Select(idx => idx.index);
        var path_by_max_cost = (IEnumerable<long>)results.PathIndicesOrderedByIncreasingMaxPathCost
                                    .Select(idx => idx.index);
    
        var x = 0;
        StringBuilder sb = new StringBuilder();
    
        foreach (var path_indeces in new List<IEnumerable<long>> {
        path_by_len_indices,
        path_by_min_cost,
        path_by_max_cost})
        {
          if (x == 0)
            sb.AppendLine($"Paths by length: {path_by_len_indices.Count()}");
          else if (x == 1)
            sb.AppendLine($"Paths by min cost: {path_by_min_cost.Count()}");
          else if (x == 2)
            sb.AppendLine($"Paths by max cost: {path_by_max_cost.Count()}");
          x++;
          foreach (var path_idx in path_indeces)
          {
            var path = (ResultPath)results.MaterializePath(path_idx);
            sb.AppendLine(
              $"Path[{path_idx}] length: {path.Length}, min: {path.MinCost} max: {path.MaxCost}");
            var g = 0;
            foreach (var rel_group in path.RelationshipGroups)
            {
              var first_entity = $"({rel_group.FirstEntity.TypeName}:{rel_group.FirstEntity.Uid})";
              var second_entity = $"({rel_group.SecondEntity.TypeName}:{rel_group.SecondEntity.Uid})";
    
              foreach (var relation in rel_group.Relationships)
              {
                sb.Append($"  [{g++}] ");
                var arrow = relation.SameDirectionAsPath ? "->" : "<-";
                var rel_uid = FormatUID(relation.Relationship.Uid.ToString());
                sb.Append($"{first_entity} '\r\n\t{relation.Relationship.TypeName}:{rel_uid}' {arrow}\r\n" +
                  $"\t\t{second_entity}");
                sb.Append($" cost: {relation.Relationship.Cost}\r\n");
              }
            }
          }
        }
    
      });
    }
    
    string FormatUID(string id)
    {
      id = id.ToUpperInvariant();
      if (!id.StartsWith('{'))
        id = '{' + id;
      if (!id.EndsWith('}'))
        id += '}';
      return id;
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.6 or higher.
    See Also