private void FixEdges(ShortestPathsTable paths)
 {
     foreach (var key in paths.PotentialShortestPaths.Keys)
     {
         if (paths.PotentialShortestPaths[key].Count > 0)
         {
             AddEdge(key, paths.PotentialShortestPaths[key][0].Item1, paths.PotentialShortestPaths[key][0].Item2);
         }
     }
 }
        private void JakesAlgorithm(NodeDroppedEvent e)
        {
            var droppedNode = e.DroppedNodeInformation;

            Console.WriteLine($"Node {droppedNode.Value} dropped, starting recovery process...");

            TimingStatistic.Start();

            var paths = new ShortestPathsTable();

            foreach (var neighbor in droppedNode.Neighbors)
            {
                foreach (var otherNeighbor in droppedNode.Neighbors)
                {
                    //Console.WriteLine($"{neighbor.Value} {otherNeighbor.Value}");
                    if (neighbor == otherNeighbor)
                    {
                        continue;
                    }

                    if (!EdgeAlreadyExists(neighbor.Value, otherNeighbor.Value))
                    {
                        var shortestPath = ShortestPath <DijkstraSearch>(neighbor, otherNeighbor);
                        paths.AddPath(otherNeighbor.Value, neighbor.Value, shortestPath.CalculatePathCost());
                    }
                }
            }

            RemoveRedundantEdges(droppedNode.Neighbors, droppedNode);
            _nodes.RemoveAll(n => n.Value == droppedNode.Value);

            paths.TrimExcessPaths();
            FixEdges(paths);

            //PrintGraph();

            TimingStatistic.Stop();
            TimingStatistic.NodeInformation.NodeName      = droppedNode.Value;
            TimingStatistic.NodeInformation.NumberOfEdges = droppedNode.Edges.Count;
            Console.WriteLine($"Dropped Node had {droppedNode.Neighbors.Count} neighbors");
            Console.WriteLine($"----- Graph recovered in {TimingStatistic.ElapsedTime} msecs, {paths.GetSize()} edges added");
        }