本文整理汇总了C#中Cluster.AddSearchNode方法的典型用法代码示例。如果您正苦于以下问题:C# Cluster.AddSearchNode方法的具体用法?C# Cluster.AddSearchNode怎么用?C# Cluster.AddSearchNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cluster
的用法示例。
在下文中一共展示了Cluster.AddSearchNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExpandCluster
// Private Functions //
// ExpandCluster //
// Requires and initial search node and a list of its neighbours, along with full list of search nodes for expansion //
// Returns a Cluster Class object - which deals with its own variables //
private Cluster ExpandCluster( SearchNode initialPoint, List< SearchNode > neighbours, SearchNode[] nodesToBeSearched )
{
// Create new cluster
Cluster cluster = new Cluster();
// Flag and add initial point to cluster
initialPoint.SetAsPartOfCluster( true );
cluster.AddSearchNode( initialPoint );
// Loop through passed neighbour points
for( int i = 0; i < neighbours.Count; i++ ) {
// If it has NOT been visited
if( !neighbours[ i ].HasBeenVisited() ) {
// Now flag as visited
neighbours[ i ].SetVisited( true );
// Get neighbours of each point
List< SearchNode > localNeighbours = GetNeighbours( neighbours[ i ], nodesToBeSearched );
// If this point has enough neighbours
if( localNeighbours.Count >= mMinimumPoints ) {
for( int j = 0; j < localNeighbours.Count; j++ ) {
// If this point isnt already a neighbour or has NOT been previously visited
// Add it as a brand new neighbour
//if( ( !localNeighbours[ j ].IsNeighbour() ) && ( !localNeighbours[ j ].HasBeenVisited() ) ) {
if( !localNeighbours[ j ].HasBeenVisited() ) {
// Add ONLY add localNeighbours that are 'joined' with nodes in neighbours
if( CheckIfJoined( localNeighbours[ j ], neighbours ) ) {
neighbours.Add( localNeighbours[ j ] );
}
}
}
// If this point is not part of a cluster - flag and add it!
if( !neighbours[ i ].PartOfCluster() ) {
neighbours[ i ].SetAsPartOfCluster( true );
cluster.AddSearchNode( neighbours[ i ] );
}
}
}
}
// Return final cluster
return cluster;
}