public static Dictionary <string, object> Connectivity( Visibility visGraph, [DefaultArgument("null")] List <DSCore.Color> colours, [DefaultArgument("null")] List <double> indices) { if (visGraph == null) { throw new ArgumentNullException("visGraph"); } VisibilityGraph visibilityGraph = visGraph.graph as VisibilityGraph; Visibility graph = new Visibility() { graph = visibilityGraph, Factors = visibilityGraph.ConnectivityFactor() }; if (colours != null && indices != null && colours.Count == indices.Count) { graph.colorRange = new Dictionary <double, DSCore.Color>(); // Create KeyValuePairs and sort them by index in case unordered. var pairs = indices.Zip(colours, (i, c) => new KeyValuePair <double, DSCore.Color>(i, c)).OrderBy(kv => kv.Key); // Adding values to colorRange dictionary foreach (KeyValuePair <double, DSCore.Color> kv in pairs) { graph.colorRange.Add(kv.Key, kv.Value); } } return(new Dictionary <string, object>() { { graphOutput, graph }, { factorsOutput, graph.Factors } }); }