예제 #1
0
 public void RemoveEdge(TwinVertex tvFrom, TwinVertex tvTo, bool inMatching)
 {
     if (inMatching)
     {
         if (!ArcHelper.DoesArcExist(tvFrom.A, tvTo.B, Arcs))
         {
             throw new NoArcException();
         }
         if (!ArcHelper.DoesArcExist(tvTo.A, tvFrom.B, Arcs))
         {
             throw new NoArcException();
         }
     }
     else
     {
         if (!ArcHelper.DoesArcExist(tvFrom.B, tvTo.A, Arcs))
         {
             throw new NoArcException();
         }
         if (!ArcHelper.DoesArcExist(tvTo.B, tvFrom.A, Arcs))
         {
             throw new NoArcException();
         }
     }
     Log.Info("Removing edge " + tvFrom + " <-> " + tvTo + " M?: " + inMatching + " from TwinGraph");
     RemoveArc(tvFrom, tvTo, inMatching);
     RemoveArc(tvTo, tvFrom, inMatching);
 }
예제 #2
0
        public void RevertFromTwin()
        {
            var twinArc = ArcHelper.FindArc(((ABVertex)End).Twin, ((ABVertex)Start).Twin, ((ABVertex)Start).Twin.InboundArcs);

            twinArc.Revert();

            /*if (((ABVertex)Start).Type == VertexType.A)
             * {
             *  var twinArc = ArcHelper.FindArc(((ABVertex)End).Twin, ((ABVertex)Start).Twin, ((ABVertex)Start).OutboundArcs);
             *  twinArc.Revert();
             * }
             * else
             * {
             *  var twinArc = ArcHelper.FindArc(((ABVertex)End).Twin, ((ABVertex)Start).Twin, ((ABVertex)Start).InboundArcs);
             *  twinArc.Revert();
             * }*/
            var tmp = Start;

            Start        = End;
            End          = tmp;
            IsInMatching = !IsInMatching;
            Log.Info("Reverted arc into " + this);
            Start.ArcReverted(this);
            End.ArcReverted(this);
        }
예제 #3
0
 public void RemoveArc(TwinVertex tvFrom, TwinVertex tvTo, bool inMatching)
 {
     Log.Info("Removing arc " + tvFrom + " -> " + tvTo + " M?: " + inMatching + " from TwinGraph");
     if (inMatching)
     {
         if (ArcHelper.DeleteArc(tvFrom.A, tvTo.B, Arcs))
         {
             tvFrom.A.RemoveArc(tvTo.B);
         }
         else
         {
             throw new NoArcException();
         }
     }
     else
     {
         if (ArcHelper.DeleteArc(tvFrom.B, tvTo.A, Arcs))
         {
             tvFrom.B.RemoveArc(tvTo.A);
         }
         else
         {
             throw new NoArcException();
         }
     }
 }
예제 #4
0
 public void EndVertexRemoved(IVertex endVertex)
 {
     if (!ArcHelper.DoesArcExist(this, endVertex, OutboundArcs))
     {
         throw new NoArcException();
     }
     ArcHelper.DeleteArc(this, endVertex, OutboundArcs);
 }
예제 #5
0
 public void RemoveInboundArc(IVertex startVertex)
 {
     Log.Info("Removing inbound arc from vertex " + Name);
     if (!ArcHelper.DoesArcExist(startVertex, this, InboundArcs))
     {
         throw new NoArcException();
     }
     ArcHelper.DeleteArc(startVertex, this, InboundArcs);
 }
예제 #6
0
 public void RemoveArc(IVertex vertex)
 {
     Log.Info("Removing outbound arc from vertex " + Name);
     if (!ArcHelper.DoesArcExist(this, vertex, OutboundArcs))
     {
         throw new NoArcException();
     }
     vertex.RemoveInboundArc(this);
     ArcHelper.DeleteArc(this, vertex, OutboundArcs);
 }
예제 #7
0
 public void RemoveArc(IVertex v1, IVertex v2)
 {
     if (ArcHelper.DeleteArc(v1, v2, Arcs))
     {
         Log.Info("Removed arc " + v1.Name + " -> " + v2.Name + " from graph");
         v1.RemoveArc(v2);
     }
     else
     {
         throw new NoArcException();
     }
 }
예제 #8
0
 public void RemoveEdge(Vertex v1, Vertex v2)
 {
     if (!ArcHelper.DoesArcExist(v1, v2, Arcs))
     {
         throw new NoArcException();
     }
     if (!ArcHelper.DoesArcExist(v2, v1, Arcs))
     {
         throw new NoArcException();
     }
     RemoveArc(v1, v2);
     RemoveArc(v2, v1);
 }
예제 #9
0
        public Arc AddOutboundArc(IVertex endVertex, bool inMatching, double weight)
        {
            if (ArcHelper.DoesArcExist(this, endVertex, OutboundArcs))
            {
                throw new NoMultiedgePermitedException();
            }
            var newArc = new Arc(Graph, this, endVertex, inMatching, weight);

            OutboundArcs.AddLast(newArc);
            if (inMatching)
            {
                AddToMatching();
            }
            Log.Info("Added outbound arc " + newArc + " to vertex " + Name + " with weight " + newArc.Weight);
            endVertex.AddInboundArc(newArc, inMatching);
            return(newArc);
        }
예제 #10
0
        public Arc AddArc(TwinVertex startVertex, TwinVertex endVertex, bool inMatching)
        {
            ABVertex start;
            ABVertex end;

            if (inMatching)
            {
                start = startVertex.A;
                end   = endVertex.B;
                bool arcExisted = ArcHelper.DeleteArc(StartVertex, startVertex.B, Arcs);
                if (arcExisted)
                {
                    StartVertex.RemoveArc(startVertex.B);
                }
                arcExisted = ArcHelper.DeleteArc(StartVertex, endVertex.B, Arcs);
                if (arcExisted)
                {
                    StartVertex.RemoveArc(endVertex.B);
                }
                arcExisted = ArcHelper.DeleteArc(startVertex.A, EndVertex, Arcs);
                if (arcExisted)
                {
                    startVertex.A.RemoveArc(EndVertex);
                }
                arcExisted = ArcHelper.DeleteArc(endVertex.A, EndVertex, Arcs);
                if (arcExisted)
                {
                    endVertex.A.RemoveArc(EndVertex);
                }
            }
            else
            {
                start = startVertex.B;
                end   = endVertex.A;
            }
            return(AddArc(start, end, inMatching));
        }
예제 #11
0
        private LinkedList <Arc> ReconstructQ(IStackableVertex uA, IStackableVertex wA, LinkedList <Arc> path)
        {
            var st    = wA;
            var p1St  = st.Value.P.Start;
            var p2St  = st.Value.P.End;
            var pathQ = Reconstruct(p1St, st, path);

            while (p2St != uA)
            {
                st = st.Value.P.End;
                var block = Reconstruct(st.Value.P.Start, st, path);
                pathQ.AppendRange(block);
            }
            if (uA.ArcFromAncestor == null)
            {
                var arc = ArcHelper.FindArc(st.Value.P.Start.Value, uA.Value, uA.Value.InboundArcs);
                pathQ.AddLast(arc);
            }
            else
            {
                pathQ.AddLast(uA.ArcFromAncestor);
            }
            return(path);
        }