score:0
This algorithm removes the checked nodes to decrease processing time. I didn't try it on your problem but I'm sure it will help you because I tested it on another scenario and it works perfectly.
// to hold sets of neighbour nodes
Dictionary<int, List<Node>> relatedCollectionsDictionary = new Dictionary<int, List<Node>>();
int index = 0;
List<Node> nList;
while (nList.Any())
{
var relatedCollection = nList.Where(n => (Math.Sqrt(Math.Pow((n.x - nList.First().x), 2) + Math.Pow((n.y - nList.First().y), 2) + Math.Pow((n.z - nList.First().z), 2)) <= gap));
List<Node> relatedCollectionList = relatedCollection.ToList();
List<Node> relatedCollectionListForDictionary = relatedCollection.ToList();
relatedCollectionsDictionary.Add(index++, relatedCollectionListForDictionary);
while (relatedCollectionList.Any())
{
nList.Remove(relatedCollectionList.First());
relatedCollectionList.RemoveAt(0);
}
}
The idea is that you do a lot of processing and iterate through all nodes every time. But using this scenario you don't iterate through any item more than one time.
Source: stackoverflow.com
Related Articles
- Find close points to each other in a big List
- Comparing each element with each other element in a list
- Find all the common time from List of time provided by each user
- How to find the maximum value for each key in a List of Dictionaries using LINQ?
- Find the distance required to navigate a list of points using linq
- find list elements which are similar to other list elements by 3 properties and then add value from the second one to the first
- Find id from other list
- Linq find first value of list in other list
- C# LINQ Find List Inside Another List, Better way to code this than a foreach loop
- find item in list , and get other item from other list at same location using linq
- Find elements which aren't in other list
- FInding sum of values in a column for each identical other columns in a list
- list integers,for each index find the product of every integer except the that index
- List or Array of String Contain specific word in Html Source Code
- Grouping list items by class property proximity from each other with some threshold
- c# Linq or code to extract groups from a single list of source data
- Find strings with equal content in list avoiding strings where searching value is a merged part of other word
- LINQ : Checking against each other item in a list
- Returning one of each object based on list of Ids and other property using EF/Linq
- LINQ query to find items in a list from other list by item
- Comparing two lists and removing each item that contains an entry from the other list
- C# LINQ find duplicates in List
- Find an item in a list by LINQ
- How do I find the text within a div in the source of a web page using C#
- LINQ query to find if items in a list are contained in another list
- How to find List has duplicate values in List<string>
- LINQ - Find all items in one list that aren't in another list
- Check if list contains item from other list in EntityFramework
- Find items from a list which exist in another list
- Using LINQ to find item in a List but get "Value cannot be null. Parameter name: source"
- Custom Icomparer in Linq to Objects
- IQueryable parameters - how to view?
- Do database schema changes break linq to entities
- List<T> Concatenation for 'X' amount of lists
- Linq request with BETWEEN
- How to get files from a specific sub-directories using c#?
- INCLUDE in Linq but to include only some columns from the included object
- Not able to access fields with group by and multiple joins with linq
- How can I fix this LINQ function?
- How to Convert DateTime to string in linq query c#
- How can I use the Html.Action's result?
- Entity Framework 3.5 - How to load children
- How to use a dynamic LINQ join extension method for multiple conditions
- LINQ Project properties into a new anonymous type with Contains
- How to create a Dictionary from an Array
- English Dictionary word matching from a string
- linq combine results from two tables to one select new statment?
- LINQ with conditional where clause
- Convert string to LINQ query
- How to add a checkbox column to a ListView in WPF and get the state of it