예제 #1
0
        /// <summary>
        /// Removes witnessed shortcuts.
        /// </summary>
        /// <param name="shortcuts"></param>
        /// <param name="witnesses"></param>
        /// <returns></returns>
        public static bool RemoveWitnessed <T>(this Shortcuts <T> shortcuts, WeightHandler <T> weightHandler, Dictionary <OriginalEdge, T> witnesses)
            where T : struct
        {
            bool witnessed = false;

            foreach (var witness in witnesses)
            {
                var edge = witness.Key;
                if (shortcuts.TryGetValue(edge, out Shortcut <T> shortcut))
                {
                    if (weightHandler.IsSmallerThan(witness.Value, shortcut.Forward))
                    {
                        shortcut.Forward = witness.Value;
                        shortcuts.AddOrUpdate(edge, shortcut, weightHandler);
                        witnessed = true;
                    }
                }
                // TODO: this should be 'else', in theory this extra check isn't needed.
                edge = edge.Reverse();
                if (shortcuts.TryGetValue(edge, out shortcut))
                {
                    if (weightHandler.IsSmallerThan(witness.Value, shortcut.Backward))
                    {
                        shortcut.Backward = witness.Value;
                        shortcuts.AddOrUpdate(edge, shortcut, weightHandler);
                        witnessed = true;
                    }
                }
            }
            return(witnessed);
        }
예제 #2
0
 /// <summary>
 /// Removes witnessed shortcuts.
 /// </summary>
 /// <param name="shortcuts"></param>
 /// <param name="witnesses"></param>
 /// <returns></returns>
 public static bool RemoveWitnessed <T>(this Shortcuts <T> shortcuts, WeightHandler <T> weightHandler, uint vertex, Dictionary <uint, Dictionary <OriginalEdge, T> > witnesses)
     where T : struct
 {
     if (witnesses.TryGetValue(vertex, out Dictionary <OriginalEdge, T> vertexWitnesses))
     {
         return(shortcuts.RemoveWitnessed(weightHandler, vertexWitnesses));
     }
     return(false);
 }
예제 #3
0
파일: VertexInfo.cs 프로젝트: amseet/Orion
 private VertexInfo(Shortcuts <T> shortcuts, int edgesCount, MetaEdge[] edges)
 {
     _shortcuts  = shortcuts;
     _edgesCount = edgesCount;
     _edges      = edges;
 }
예제 #4
0
파일: VertexInfo.cs 프로젝트: amseet/Orion
 /// <summary>
 /// Creates a new vertex info object.
 /// </summary>
 public VertexInfo()
 {
     _shortcuts = new Shortcuts <T>();
     _edges     = new MetaEdge[64];
 }