ArcGIS Pro 3.6 API Reference Guide
ArcGIS.Core.CIM Namespace / CIMFilteredFindPathsConfiguration Class
Members Example

In This Topic
    CIMFilteredFindPathsConfiguration Class
    In This Topic
    Represents a Knowledge Graph Filtered Find Paths Configuration.
    Object Model
    CIMFilteredFindPathsConfiguration ClassCIMFilteredFindPathsConfiguration ClassCIMFilteredFindPathsConfiguration ClassCIMKGTimeFilter Class
    Syntax
    Example
    Run FFP Using Defaults
          //using ArcGIS.Core.Data.Knowledge.Extensions;
    
          await QueuedTask.Run(() =>
    {
              var ffp_config = new CIMFilteredFindPathsConfiguration();
              ffp_config.Name = "Run FFP Using Defaults";
    
              //Origin Entities
              var originEntities = new List<CIMFilteredFindPathsEntity>();
    
              var poi_entity = new CIMFilteredFindPathsEntity();
              poi_entity.EntityTypeName = "POI";//All entities of entity type "POI"
              poi_entity.PropertyFilterPredicate = "";
              originEntities.Add(poi_entity);
              //Add the CIMFilteredFindPathsEntity to the OriginEntities collection
              ffp_config.OriginEntities = originEntities.ToArray();
    
              //Destination Entities
              var destEntities = new List<CIMFilteredFindPathsEntity>();
    
              var supp_entity = new CIMFilteredFindPathsEntity();
              supp_entity.EntityTypeName = "Supplier";//All entities of entity type "Supplier"
              supp_entity.PropertyFilterPredicate = "";
              destEntities.Add(supp_entity);
    
              //Add the CIMFilteredFindPathsEntity to the DestinationEntities collection
              ffp_config.DestinationEntities = destEntities.ToArray();
    
              //Path Filters
              ffp_config.PathFilters = [];//Empty
              //Traversal
              ffp_config.TraversalDirections = [];//Empty
    
              //Other
              ffp_config.RelationshipCostProperty = "";
              ffp_config.DefaultRelationshipCost = 1.0;
              ffp_config.DefaultTraversalDirectionType = KGTraversalDirectionType.Any;
              ffp_config.EntityUsage = FilteredFindPathsEntityUsage.AnyOriginAnyDestination;
              ffp_config.PathMode = KGPathMode.Shortest;
              ffp_config.MinPathLength = (int)1;//Min number of relationships in path
              ffp_config.MaxPathLength = (int)8;//Max number of relationships in path
              ffp_config.MaxCountPaths = (int)100000;//Total number of paths to return
              ffp_config.ClosedPathPolicy = KGClosedPathPolicy.Forbid;
              ffp_config.TimeFilter = null;
    
              var results = kg.RunFilteredFindPaths(ffp_config);
              //TODO process/analyze results
          });
    Run FFP Using Multiple Entities and Destinations
        //using ArcGIS.Core.Data.Knowledge.Extensions;
    
        await QueuedTask.Run(() =>
        {
            var ffp_config = new CIMFilteredFindPathsConfiguration();
            ffp_config.Name = "Run FFP w Multiple Entities and Destinations";
    
            //Origin Entities
            var originEntities = new List<CIMFilteredFindPathsEntity>();
    
            foreach (var entity_name in new List<string> { "Person", "POI", "Supplier", "Plant" })
            {
                var origin_entity = new CIMFilteredFindPathsEntity();
                origin_entity.EntityTypeName = entity_name;
                origin_entity.PropertyFilterPredicate = "";
                originEntities.Add(origin_entity);
            }
    
            //Add the CIMFilteredFindPathsEntity to the OriginEntities collection
            ffp_config.OriginEntities = originEntities.ToArray();
    
            //Destination Entities
            var destEntities = new List<CIMFilteredFindPathsEntity>();
    
            foreach (var entity_name in new List<string> { 
      "Supplier", "Plant", "Part", "Customer" })
    {
                var dest_entity = new CIMFilteredFindPathsEntity();
                dest_entity.EntityTypeName = entity_name;
                dest_entity.PropertyFilterPredicate = "";
                destEntities.Add(dest_entity);
            }
    
            //Add the CIMFilteredFindPathsEntity to the DestinationEntities collection
            ffp_config.DestinationEntities = destEntities.ToArray();
    
            //Path Filters
            ffp_config.PathFilters = [];//Empty
                                                                    //Traversal
            ffp_config.TraversalDirections = [];//Empty
    
            //Other
            ffp_config.RelationshipCostProperty = "";
            ffp_config.DefaultRelationshipCost = 1.0;
            ffp_config.DefaultTraversalDirectionType = KGTraversalDirectionType.Any;
            ffp_config.EntityUsage = FilteredFindPathsEntityUsage.AnyOriginAnyDestination;
            ffp_config.PathMode = KGPathMode.Shortest;
            ffp_config.MinPathLength = (int)1;//Min number of relationships in path
            ffp_config.MaxPathLength = (int)8;//Max number of relationships in path
            ffp_config.MaxCountPaths = (int)100000;//Total number of paths to return
            ffp_config.ClosedPathPolicy = KGClosedPathPolicy.Forbid;
            ffp_config.TimeFilter = null;
    
            var results = kg.RunFilteredFindPaths(ffp_config);
            //TODO process/analyze results
        });
    Create Link Chart from FFP Results
        //using ArcGIS.Core.Data.Knowledge.Extensions;
    
        await QueuedTask.Run(async() =>
        {
            var ffp_config = new CIMFilteredFindPathsConfiguration();
            ffp_config.Name = "Create Link Chart from FFP Results";
    //set up config
    //...
            
            var results = kg.RunFilteredFindPaths(ffp_config);
    
            var pathsEntitiesAndRelationships = results.ExtractPathsEntitiesAndRelationships(null);
    
            //Create a KG layer id set
            var kgLayerIdSet = KnowledgeGraphLayerIDSet.FromKnowledgeGraphIDSet(
                pathsEntitiesAndRelationships.ToKnowledgeGraphIDSet(
                    KGResultContentFromFFP.EntitiesAndRelationships));
    
            //Create a brand new link chart with the results and show it
            var linkChart = MapFactory.Instance.CreateLinkChart(
                                                "KG Intro", kg, kgLayerIdSet);
    
            var mapPane = await FrameworkApplication.Panes.CreateMapPaneAsync(linkChart);
            var linkChartView = mapPane.MapView;
    
            //Change layout algo to match the default used by the UI after FFP
            await linkChartView.SetLinkChartLayoutAsync(
                KnowledgeLinkChartLayoutAlgorithm.Hierarchical_TopToBottom);
    
            //Set root nodes - they correspond to the origin nodes of the result paths
            var kgLayerIdSetForRootNodes = KnowledgeGraphLayerIDSet.FromKnowledgeGraphIDSet(
                pathsEntitiesAndRelationships.ToKnowledgeGraphIDSet(
                    KGResultContentFromFFP.OnlyPathsOriginEntities));
    
            //To correctly identify the ids in the link chart we must change the ids
            //from Geodatabase oids returned in the KnowledgeGraphLayerIDSet to the
    //temporary/synthetic oids used by layers in the link chart...
            var kg_layer = linkChart.GetLayersAsFlattenedList().OfType<KnowledgeGraphLayer>().First();
            var mapMembers = kg_layer.GetMapMembersAsFlattenedList();
            var oidDict = kgLayerIdSetForRootNodes.ToOIDDictionary();
            var mmDict = new Dictionary<MapMember, List<long>>();
            foreach (var kvp in oidDict)
            {
                var named_type = kvp.Key;
                foreach (var mm in mapMembers)
                {
                    if (mm is LinkChartFeatureLayer fl_lc && fl_lc.IsEntity)
                    {
                        if (fl_lc.GetTypeName().ToLower() == named_type.ToLower())
                        {
                            var lc_oids = new List<long>();
                            //these oids are from the geodatabase
                            var oid_field = $"{fl_lc.GetTypeName()}.objectid";
                            var id_list = string.Join(',', kvp.Value.ToArray());
                            var where = $"{fl_lc.GetTypeName()}.objectid IN ({id_list})";
    
                            var qf = new ArcGIS.Core.Data.QueryFilter()
                            {
                                WhereClause = where,
                                SubFields = $"LC.OID,{oid_field}"//the 'LC.OID' oids are the ones
                                               //we need for the mapmember id set
                                               //in the link chart
                            };
                            var rc = fl_lc.Search(qf);
                            var oid_idx = rc.FindField(oid_field);
                            while (rc.MoveNext())
                            {
                                var oid = (long)rc.Current[oid_idx];
                                var lc_oid = rc.Current.GetObjectID();
                                lc_oids.Add(lc_oid);
                            }
                            rc.Dispose();
                            mmDict[fl_lc] = lc_oids;
                            break;
                        }
                    }
                }
            }
    
            var mmIdSet = MapMemberIDSet.FromDictionary(mmDict);
            linkChartView.SetRootNodes(mmIdSet);
        });
    Append to Link Chart from FFP Results
    //using ArcGIS.Core.Data.Knowledge.Extensions;
    
    var linkChartView = MapView.Active;
    
    await QueuedTask.Run(async () =>
    {
        var ffp_config = new CIMFilteredFindPathsConfiguration();
        ffp_config.Name = "Append to Link Chart from FFP Results";
        //set up config
        //...
    
        var results = kg.RunFilteredFindPaths(ffp_config);
    
        var pathsEntitiesAndRelationships = results.ExtractPathsEntitiesAndRelationships(null);
    
        //Create a KG layer id set
        var kgLayerIdSet = KnowledgeGraphLayerIDSet.FromKnowledgeGraphIDSet(
            pathsEntitiesAndRelationships.ToKnowledgeGraphIDSet(
                KGResultContentFromFFP.EntitiesAndRelationships));
    
        var map = linkChartView.Map;
    
        if (!map.CanAppendToLinkChart(kgLayerIdSet))
            return;//not compatible
    
        map.AppendToLinkChart(kgLayerIdSet);
        //switch layout algo
        var algo = linkChartView.GetLinkChartLayout();
        if (algo != KnowledgeLinkChartLayoutAlgorithm.Hierarchical_TopToBottom)
        {
            //Change layout algo to match the default used by the UI after FFP
            await linkChartView.SetLinkChartLayoutAsync(
                KnowledgeLinkChartLayoutAlgorithm.Hierarchical_TopToBottom);
        }
    
        //To set link chart root nodes see 'Create Link Chart from FFP Results'
    });
    Inheritance Hierarchy

    System.Object
       ArcGIS.Core.CIM.CIMObject
          ArcGIS.Core.CIM.CIMFilteredFindPathsConfiguration

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.3 or higher.
    See Also