private static void Visit(IVertex node, ColorsSet colors, TimestampSet discovery, TimestampSet finish, LinkedList list, ref int time) { colors.Set(node, VertexColor.Gray); discovery.Register(node, time++); foreach (IVertex child in node.Adjacencies) { if (colors.ColorOf(child) == VertexColor.White) { Visit(child, colors, discovery, finish, list, ref time); } } finish.Register(node, time++); #if DEBUG System.Diagnostics.Debug.Assert(discovery.TimeOf(node) < finish.TimeOf(node)); #endif list.AddFirst(node); colors.Set(node, VertexColor.Black); }
public async Task <IActionResult> GetCharts(int deviceId) { if (deviceId == 0) { var valueList0 = new List <double?>() { 0, 0, 0, 0, 0 }; var stringList0 = new List <string>() { "", "", "", "", "" }; var dataSets0 = new ChartDataSet("Sensör Verileri", new ChartColor() { Red = 72, Green = 192, Blue = 192, Alpha = 0.4 }, valueList0, stringList0); Charts = new List <Chart>() { GetChart(dataSets0) }; return(View()); } Charts = new List <Chart>(); var apiService = new ApiServices(); var accesstoken = await apiService.LoginAsync("*****@*****.**", "BioGuy2015"); var sensorDataList = await _apiService.SearchDevicesAsync(deviceId, accesstoken); var sensorTypeList = await _apiService.GetSensorTypesAsync(accesstoken); var colorClass = new ColorsSet(); var colorListForCharts = colorClass.Colors; for (int i = 0; i < sensorTypeList.Count; i++) { var sensorName = sensorTypeList[i].Name; var dataList = sensorDataList.Where(x => x.TypeId == sensorTypeList[i].Id); var groupDataList = dataList.Skip(6).Select(x => new { sValue = x.Value, sTime = DateTime.Parse(x.Time) }).GroupBy(x => x.sTime.Day).ToList(); var valueList = groupDataList.Select(x => x.Average(z => z.sValue)).ToList(); var stringList = (groupDataList.Select(x => (x.First().sTime.Date.Date).ToString("dd.MM.yyyy"))).ToList(); var colorIndex = i % (colorListForCharts.Count()); var color = colorListForCharts[colorIndex]; var datasets = new ChartDataSet(sensorName, color, valueList, stringList); var chart = GetChart(datasets); Charts.Add(chart); break; } return(View()); }
public static IVertex[] Sort(IVertex[] graphNodes) { ColorsSet colors = new ColorsSet(graphNodes); TimestampSet discovery = new TimestampSet(); TimestampSet finish = new TimestampSet(); LinkedList list = new LinkedList(); int time = 0; foreach (IVertex node in graphNodes) { if (colors.ColorOf(node) == VertexColor.White) { Visit(node, colors, discovery, finish, list, ref time); } } return((IVertex[])list.ToArray(typeof(IVertex))); }