Exemplo n.º 1
0
        /// <summary>
        /// Adds the connection.
        /// </summary>
        /// <param name="a">a.</param>
        /// <param name="b">The b.</param>
        public void AddConnection(UV a, UV b)
        {
            JGVertex A = null;
            JGVertex B = null;

            dict.TryGetValue(a.GetHashCode(), out A);
            dict.TryGetValue(b.GetHashCode(), out B);
            if (A != null && B != null)
            {
                A.AddToConnections(B);
                B.AddToConnections(A);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a deep copy of this instance.
        /// </summary>
        /// <returns>JGGraph.</returns>
        public JGGraph DeepCopy()
        {
            JGGraph copied = new JGGraph();

            //copying vertices
            foreach (JGVertex item in this.Vertices)
            {
                JGVertex newJGV = new JGVertex(item.Point.Copy());
                copied.AddVertex(newJGV);
            }
            //copying connections
            foreach (JGVertex item in this.Vertices)
            {
                JGVertex current = copied.Find(item.Point);
                foreach (JGVertex connection in item.Connections)
                {
                    JGVertex next = copied.Find(connection.Point);
                    current.AddToConnections(next);
                    next.AddToConnections(current);
                }
            }
            return(copied);
        }