feat: Added method to get a single clique given a starting node

This commit is contained in:
Austin Noska
2019-06-26 11:39:50 -04:00
parent 3a2fc0eef7
commit 65c50e8e90
2 changed files with 32 additions and 0 deletions

View File

@@ -32,6 +32,20 @@ namespace ICD.Common.Utils
.Select(node => GetClique(map, visited, node));
}
/// <summary>
/// Gets the clique containing the given node.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="nodes"></param>
/// <param name="node"></param>
/// <param name="getAdjacent"></param>
/// <returns></returns>
public static IEnumerable<T> GetClique<T>(IEnumerable<T> nodes, T node, Func<T, IEnumerable<T>> getAdjacent)
{
Dictionary<T, IEnumerable<T>> map = nodes.ToDictionary(n => n, getAdjacent);
return GetClique(map, node);
}
/// <summary>
/// Gets the clique containing the given node.
/// </summary>