Exemple #1
0
        /// <summary>
        /// Validates the nodes and links coming from a pipe function.
        /// </summary>
        /// <param name="nodes">List of Node objects.<see cref="Node"/></param>
        /// <param name="links">List of Link objects.<see cref="Link"/></param>
        public static void Validate(List <Node> nodes, List <Link> links)
        {
            validatedLinks = new Hashtable();
            validatedNodes = new Hashtable();
            for (int i = 0; i < nodes.Count; i++)
            {
                Node node = nodes[i];

                ValidateIdentifier(i, node);

                ValidateCoordinates(node);

                if (!validatedNodes.ContainsKey(node.Id))
                {
                    validatedNodes.Add(node.Id, node);
                }
            }

            foreach (Link link in links)
            {
                string linkIDRev = "";


                if (link.Id == null)
                {
                    List <string> generated = GenerateID(link, "Link_");
                    link.Id   = generated[0];
                    linkIDRev = generated[1];
                }
                if (!validatedLinks.ContainsKey(link.Id) && (!directedGraph && !validatedLinks.ContainsKey(linkIDRev) || directedGraph))
                {
                    ValidateLinkValues(link);
                    validatedLinks.Add(link.Id, link);
                }
            }
            GlobalVariables.AddGraphNodes(validatedNodes);
            GlobalVariables.AddGraphLinks(validatedLinks);
        }