Ejemplo n.º 1
0
        /// <summary>
        /// Gets the <see cref="IVertex"/> parent.
        /// </summary>
        /// <param name="v">current vertex</param>
        /// <returns>
        /// parent vertex if any, null reference otherwize
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="v"/> is a null reference
        /// </exception>
        /// <exception cref="MultipleInEdgeException">
        /// <paramref name="v"/> has multiple in-edges
        /// </exception>
        public IVertex ParentVertex(IVertex v)
        {
            if (v == null)
            {
                throw new ArgumentNullException("v");
            }
            if (this.Wrapped.InDegree(v) > 1)
            {
                throw new MultipleInEdgeException(v.ID.ToString());
            }

            return(Traversal.FirstSourceVertex(this.Wrapped.InEdges(v)));
        }