Esempio n. 1
0
        private void CreateEdgesFor(EulerVertex vertex)
        {
            var targets = Incidents(vertex.value);

            if (targets != null)
            {
                if (Incremental)
                {
                    var incTargets = targets.AsNotifiable();
                    vertex.IncIncidents = incTargets;
                    foreach (var target in incTargets)
                    {
                        if (target != null)
                        {
                            vertex.AddEdgeTo(target);
                        }
                    }
                    incTargets.Successors.Set(vertex);
                    vertex.Successors.Set(this);
                }
                else
                {
                    foreach (var target in targets)
                    {
                        if (target != null)
                        {
                            vertex.AddEdgeTo(target);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
            public EulerHalfEdge Link(EulerVertex other)
            {
                //Create half edges and link them to each other
                var st = new EulerHalfEdge(this, other, null, null);
                var ts = new EulerHalfEdge(other, this, null, st);

                st.opposite = ts;

                // check whether the nodes are
                if (!this.AreConnected(other))
                {
                    //Move both vertices to root
                    this.MakeRoot();
                    other.MakeRoot();

                    //Insert entries in Euler tours
                    st.node = this.node.Insert(st);
                    ts.node = other.node.Insert(ts);

                    //Link tours together
                    this.node.Concat(other.node);
                }
                //Return half edge
                return(st);
            }
Esempio n. 3
0
 public void CleanUp()
 {
     node.Remove();
     node.val = null;
     node     = null;
     opposite = null;
     source   = null;
     dest     = null;
 }
Esempio n. 4
0
        public static EulerVertex <T> Create(T value)
        {
            var v = new EulerVertex <T>()
            {
                value = value
            };

            v.node = new TreapNode <EulerNode <T> >(v);
            return(v);
        }
Esempio n. 5
0
        private EulerVertex GetOrCreate(T value, bool createIfNecessary)
        {
            EulerVertex vertex = null;

            if (!nodes.TryGetValue(value, out vertex) && createIfNecessary)
            {
                vertex = new EulerVertex(value, this);
                nodes.Add(value, vertex);

                CreateEdgesFor(vertex);
            }
            return(vertex);
        }
Esempio n. 6
0
            public EulerHalfEdge(EulerVertex s, EulerVertex t, TopTreeNode node, EulerHalfEdge opposite)
            {
                if (s == null)
                {
                    throw new ArgumentNullException("s");
                }
                if (t == null)
                {
                    throw new ArgumentNullException("t");
                }

                this.s        = s;
                this.t        = t;
                this.node     = node;
                this.opposite = opposite;
                this.count    = 1;
            }
Esempio n. 7
0
        public EulerHalfEdge <T> Link(EulerVertex <T> other, T value)
        {
            // Move both vertices to root
            MakeRoot();
            other.MakeRoot();

            // Create half edges and link them to each other
            var st = new EulerHalfEdge <T>(value, this, other);
            var ts = new EulerHalfEdge <T>(value, other, this);

            ts.opposite = st;
            st.opposite = ts;

            // Insert entries in Euler tours
            st.node = node.Insert(st);
            ts.node = other.node.Insert(ts);

            // Link tours together
            node.Merge(other.node);

            // Return half edge
            return(st);
        }
Esempio n. 8
0
 public bool AreConnected(EulerVertex other)
 {
     return(this.node.Root() == other.node.Root());
 }
Esempio n. 9
0
 public bool IsConnected(EulerVertex <T> other)
 {
     return(node.GetRoot() == other.node.GetRoot());
 }
Esempio n. 10
0
 public EulerHalfEdge(T value, EulerVertex <T> source, EulerVertex <T> dest)
 {
     this.value  = value;
     this.source = source;
     this.dest   = dest;
 }