Example #1
0
        public void RemoveEdge(int u, int v)
        {
            EdgePair pair = LocateEdge(u, v);

            if (pair == null)
            {
                return;
            }

            Edge e1 = pair.E1;
            Edge e2 = pair.E2;

            if (pair.E2.key == v)
            {
                e2.marked        = true; // remove logically
                e2.markedVersion = version;

                if (cleanup)
                {
                    e1.next = e2.next;  // remove physically
                }
            }

            Unlock(e1, e2);
        }
Example #2
0
        public void AddEdge(int u, int v)
        {
            EdgePair pair = LocateEdge(u, v);

            if (pair != null)
            {
                Edge e1 = pair.E1;
                Edge e2 = pair.E2;

                if (e2.key != v)
                {
                    Edge e3 = new Edge(v, version);
                    e3.next = e2;
                    e1.next = e3;
                }
                Unlock(e1, e2);
            }
        }