

Public Class CIMFilteredFindPathsConfiguration Inherits CIMObject Implements System.ComponentModel.INotifyPropertyChanged, System.Xml.Serialization.IXmlSerializable
public class CIMFilteredFindPathsConfiguration : CIMObject, System.ComponentModel.INotifyPropertyChanged, System.Xml.Serialization.IXmlSerializable
{
// access the currently active knowledge graph investigation view
KnowledgeGraphInvestigationView activeView = KnowledgeGraphInvestigationView.Active;
KnowledgeGraphInvestigation investigation = activeView?.Investigation;
if (investigation != null)
{
await QueuedTask.Run(() =>
{
// get all the configurations
var configurations = investigation.GetAllFilteredFindPathsConfigurations();
// get a specific FFP configuration
var myConfiguration = investigation.GetFilteredFindPathsConfiguration("FFPConfig1");
});
}
}
{
var newFFPConfig = new CIMFilteredFindPathsConfiguration();
newFFPConfig.Name = "FFPConfig1";
//Limit the set of origin entities to all entities of type POI and Supplier
var poi_entity = new CIMFilteredFindPathsEntity();
poi_entity.EntityTypeName = "POI";
var supp_entity = new CIMFilteredFindPathsEntity();
supp_entity.EntityTypeName = "Supplier";
var originEntities = new List<CIMFilteredFindPathsEntity>();
originEntities.Add(poi_entity);
originEntities.Add(supp_entity);
//Apply to the configuration origin entities filter
newFFPConfig.OriginEntities = originEntities.ToArray();
// access the currently active knowledge graph investigation view
KnowledgeGraphInvestigationView activeView = KnowledgeGraphInvestigationView.Active;
KnowledgeGraphInvestigation investigation = activeView?.Investigation;
if (investigation != null)
{
await QueuedTask.Run(() =>
{
// add the new FFPConfig
investigation.AddFilteredFindPathsConfiguration(newFFPConfig);
});
}
}
{
// access the currently active knowledge graph investigation view
KnowledgeGraphInvestigationView activeView = KnowledgeGraphInvestigationView.Active;
KnowledgeGraphInvestigation investigation = activeView?.Investigation;
if (investigation != null)
{
await QueuedTask.Run(() =>
{
// update FFPConfig properties
var myFFPConig = investigation.GetFilteredFindPathsConfiguration("FFPConfig1");
if (myFFPConig != null)
{
//Limit the set of origin entities to just a specific POI entity
var poi_entity = new CIMFilteredFindPathsEntity();
poi_entity.EntityTypeName = "POI";
poi_entity.ID = "{EC2A2D91-B09C-4CF6-93A3-51D6527CF51E}";//upper case guid with "{}"s
var originEntities = new List<CIMFilteredFindPathsEntity>();
originEntities.Add(poi_entity);
//Apply to the configuration origin entities filter
myFFPConig.OriginEntities = originEntities.ToArray();
investigation.UpdateFilteredFindPathsConfiguration(myFFPConig);
}
});
}
}
{
// access the currently active knowledge graph investigation view
KnowledgeGraphInvestigationView activeView = KnowledgeGraphInvestigationView.Active;
KnowledgeGraphInvestigation investigation = activeView?.Investigation;
if (investigation != null)
{
await QueuedTask.Run(() =>
{
// rename the FFPConfig
investigation.RenameFilteredFindPathsConfiguration("FFPConfig1", "FFPConfig_POI");
});
}
}
{
// access the currently active knowledge graph investigation view
KnowledgeGraphInvestigationView activeView = KnowledgeGraphInvestigationView.Active;
KnowledgeGraphInvestigation investigation = activeView?.Investigation;
if (investigation != null)
{
await QueuedTask.Run(() =>
{
// delete the FFPConfig
investigation.DeleteFilteredFindPathsConfiguration("FFPConfig1");
});
}
}
{
// access the currently active knowledge graph investigation view
KnowledgeGraphInvestigationView activeView = KnowledgeGraphInvestigationView.Active;
KnowledgeGraphInvestigation investigation = activeView?.Investigation;
if (investigation != null)
{
string pathName = @"d:\data\EntityFFPConfig.ffpcfg";
// import from ffpcfg
var ffpConfig = await investigation.ImportFilteredFindPathsConfiguration(pathName);
}
}
{
// access the currently active knowledge graph investigation view
KnowledgeGraphInvestigationView activeView = KnowledgeGraphInvestigationView.Active;
KnowledgeGraphInvestigation investigation = activeView?.Investigation;
if (investigation != null)
{
await QueuedTask.Run(() =>
{
// update FFPConfig properties
var myFFPConig = investigation.GetFilteredFindPathsConfiguration("FFPConfig1");
if (myFFPConig != null)
{
string pathName = @"d:\data\EntityFFPConfig.ffpcfg";
// export from ffpcfg
investigation.ExportFilteredFindPathsConfiguration(myFFPConig, pathName, true);
}
});
}
}
{
//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
});
}
{
//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
});
}
{
//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);
});
}
{
//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'
});
}
System.Object
ArcGIS.Core.CIM.CIMObject
ArcGIS.Core.CIM.CIMFilteredFindPathsConfiguration
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)