예제 #1
0
        /// <summary>
        /// Determine if the graph specified with list of nodes and list of nodes is partial
        /// Graph of the Graph that called the method on.
        /// </summary>
        /// <param name="nodes">List of nodes that specify the nodes of the graph that we want to exam.</param>
        /// <param name="lines">List of lines that specify the lines of the graph that we want to exam.</param>
        /// <returns>Return true if the graph is Partial , Otherwise , false.</returns>
        public bool IsPartialGraph(SortedList <int, Node> nodes, SortedList <string, Line> lines)
        {
            // Check if all nodes in parameter in the Primary graph.
            foreach (Node node in nodes.Values)
            {
                if (NodesList.ContainsValue(node) == false) // node not found in NodesList
                {
                    return(false);
                }
            }

            // Check if all lines in paramter in the Primary graph.
            foreach (Line line in lines.Values)
            {
                if (LinesList.ContainsValue(line) == false) // line not found in lineslist
                {
                    return(false);
                }
            }
            foreach (Line line in LinesList.Values)
            {
                if ((nodes.ContainsValue(line.FirstNode) && nodes.ContainsValue(line.SecondNode)) && (lines.ContainsValue(line) == false))
                {
                    return(false);
                }
            }

            return(true);
        }