Exemplo n.º 1
0
        /// <summary>
        /// Adds a directed edge between the nodes identified by the specified values.
        /// </summary>
        /// <param name="from">Value identifying the node that will spawn the edge.</param>
        /// <param name="to">Value identifying the node on the 'to' end of the edge.</param>
        /// <returns>The edge between the targeted nodes.</returns>
        public Edge <EdgeListNode <T> > AddDirectedEdge(T from, T to)
        {
            EdgeListNode <T> fromTarget = FindNode(from);
            EdgeListNode <T> toTarget   = FindNode(to);

            if (fromTarget == null)
            {
                throw new ArgumentException("The 'from' node is not part of this graph.");
            }
            if (toTarget == null)
            {
                throw new ArgumentException("The 'to' node is not part of this graph.");
            }
            return(fromTarget.AddEdgeTo(to));
        }