public void Graph_Delone() { List <Edge> All_Edges = new List <Edge>(); for (int i = 0; i < Vertexes.Count - 1; i++) { for (int j = i + 1; j < Vertexes.Count; j++) { var v_from = Vertexes[i]; var v_to = Vertexes[j]; All_Edges.Add(new Edge(v_from, v_to, All_Slots)); All_Edges.Add(new Edge(v_to, v_from, All_Slots)); } } var Heap_Priority = new BinaryHeap(); foreach (var edge in All_Edges) { Heap_Priority.Add_To_Heap(new Edge_Distance(edge, edge.Weight)); } while (true) { Edge pointer = Heap_Priority.Get_Min().Edge; bool check_all_cross = false; foreach (var edge in Edges) { check_all_cross = Check_Cross(edge, pointer); if (check_all_cross == true) { break; } } if (check_all_cross == false) { Edges.Add(pointer); } if (Heap_Priority.Edges_Sort.Count == 0) { break; } } }
public void Algo(Vertex start, Vertex end, double max_distance, int min_diaposon) { Reset_Label(); bool check; BinaryHeap Heap_Priority = new BinaryHeap(); Vertex pointer_vertex = start; var edge_start = new Edge(start, start, All_Slots); var pointer_heap = new Edge_Distance(edge_start, 0); Heap_Priority.Add_To_Heap(pointer_heap); List <int[]> list_range = new List <int[]>(); start.Labels.Add(new Label(0, edge_start, All_Slots)); while (Heap_Priority.Edges_Sort.Count != 0) { pointer_heap = Heap_Priority.Get_Min(); pointer_vertex = pointer_heap.Edge.To; list_range = new List <int[]>(); foreach (var label in pointer_vertex.Labels) { if (label.Distance == pointer_heap.Distance && label.Previous_Edge.From == pointer_heap.Edge.From && label.Previous_Edge.To == pointer_heap.Edge.To) { list_range.Add(label.Slots); } } foreach (var range in list_range) { foreach (var outedge in pointer_vertex.OutEdge) { if (outedge.Slots.Length == 0) { continue; } int[] cross = Cross_Range(range, outedge.Slots); double distance = pointer_heap.Distance + outedge.Weight; if (distance < max_distance && Max_Diaposon(cross).Length >= min_diaposon) { var vertex = outedge.To; var label_add = new Label(distance, outedge, cross); var remove_label = new List <Label>(); check = true; foreach (var label_vertex in vertex.Labels) { if (distance >= label_vertex.Distance && Comparison_Mas(cross, Cross_Range(cross, label_vertex.Slots)) == true) { check = false; break; } if (distance <= label_vertex.Distance && Comparison_Mas(label_vertex.Slots, Cross_Range(cross, label_vertex.Slots)) == true) { remove_label.Add(label_vertex); } } if (check) { foreach (var label_del in remove_label) { vertex.Labels.Remove(label_del); } vertex.Labels.Add(label_add); Heap_Priority.Add_To_Heap(new Edge_Distance(outedge, distance)); } } } } } }