コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        internal bool Remove(T node)
        {
            //check the node in lookup table
            if (node == null && !_lookupTable.Contains(node))
            {
                return(false);
            }

            // first remove the node from the nodeset
            var nodeToRemove = _nodeSet.Get(node);

            // node wasn't found
            if (nodeToRemove == null)
            {
                return(false);
            }

            var danglingNeighbors = nodeToRemove.Neighbors.Where(nab => nab.Weight == 0).ToDictionary(nab => nab.GraphNode);

            // otherwise, the node was found
            bool status = _nodeSet.Remove(nodeToRemove);

            // enumerate through each node in the nodeSet, removing edges to this node
            // if its neighbor is dangling node then
            // we remove the neighbor but if its neighbor is not dengling then then preserve it in graph.
            // if we not want forest.

            return(status);
        }