/* create tree */
        public CreateTreeControl(int depth, int splitsize, LinkedList<PlannerPath.Utility.Attribute> vertexesAttributes, LinkedList<PlannerPath.Utility.Attribute> edgesAttributes, String path, String treetype)
        {
            String messageBoxTitle = "Create Tree";

            this.Path = path;

            this.TempTree = new Tree(depth, splitsize, vertexesAttributes, edgesAttributes, true);
            this.TempTree.type = treetype;


            //Generate tree file and...
            if (this.generateTreeFile() == false)
            {
                MessageBox.Show("Problems while storing file into file. Please click 0K and wait for upload to DB", messageBoxTitle);
            }
            else
            {
                MessageBox.Show("Your tree is in the file. Please click 0K and wait for upload to DB", messageBoxTitle);

                var Engine = new Process
                {
                    StartInfo = new ProcessStartInfo
                    {
                        FileName = "engine.exe",
                        Arguments = "upload " + this.TempTree.getXMLPath(),
                        UseShellExecute = false,
                        RedirectStandardOutput = true,
                        CreateNoWindow = true
                    }
                };

                // uploaded to DB using Engine
                Engine.Start();

                String Output = "";

                while (!Engine.StandardOutput.EndOfStream)
                {
                    Output = Output + Environment.NewLine + Engine.StandardOutput.ReadLine();
                }
                MessageBox.Show(Output, messageBoxTitle);
            }

        }
Exemple #2
0
        /// <summary>
        /// Generates a random Tree with your parameters.
        /// Before to call this function you must set VertexAttributes and EdgeAttributes
        /// </summary>
        public void randomGenerateTree() {

            for (int j = 0; j < this.SplitSize && this.Depth > 0; j++) {
                    
                Vertex childVertex = new Vertex(GetRandomAttributes(true, VertexAttributes, EdgeAttributes).ToArray(), new LinkedList<Edge>(), root.Depth+1);
                this.root.append(new Edge(this.root, childVertex, GetRandomAttributes(false, VertexAttributes, EdgeAttributes)));
                Tree subTree = new Tree(this.Depth-1,this.SplitSize,this.VertexAttributes,this.EdgeAttributes,childVertex);
                subTree.randomGenerateTree();
                //Console.WriteLine(j+". Depth: "+this.Depth+" - SplitSize: "+this.SplitSize);
            }

        }
Exemple #3
0
        private XmlTextWriter generateTreeXML(bool first) {

            if (this.root == null)
                return this.fileWriter;

            if (this.root.OutgoingEdges == null)
                return this.fileWriter;

            //Prima esecuzione
            if (first) {
            
                this.fileWriter.WriteStartElement("Vertex");
                this.fileWriter.WriteElementString("Name", root.Name.ToString());
                this.fileWriter.WriteElementString("Depth", root.Depth.ToString());

                //Console.WriteLine("Io sono il primo: "+root.Name);
                
                this.fileWriter.WriteStartElement("Attributes");
                    foreach (Attribute a in root.Attributes)
                    {
                        this.fileWriter.WriteElementString(a.Name,
                            a.type == Attribute.AttributeType.STRING ?
                            a.value_string : a.value_int.ToString());
                    }
                    this.fileWriter.WriteEndElement(); //Attribute
                
                
                this.fileWriter = this.generateTreeXML(false);
                this.fileWriter.WriteEndElement(); //Vertex
            
            } else {

                foreach (Edge e in this.root.OutgoingEdges) {

                    this.fileWriter.WriteStartElement("Edge");

                    this.fileWriter.WriteElementString("Name", e.Name.ToString());
                    this.fileWriter.WriteStartElement("Attributes");

                        foreach (Attribute a in e.Attributes)
                        {
                            this.fileWriter.WriteElementString(a.Name,
                                a.type == Attribute.AttributeType.STRING ?
                                a.value_string : a.value_int.ToString());
                        }

                    this.fileWriter.WriteEndElement(); //Attributes
                    

                    this.fileWriter.WriteStartElement("Vertex");
                    this.fileWriter.WriteElementString("Name", e.Bottom.Name.ToString());
                    this.fileWriter.WriteElementString("Depth", e.Bottom.Depth.ToString());
                    
                                  
                    this.fileWriter.WriteStartElement("Attributes");

                        foreach (Attribute a in e.Bottom.Attributes)
                        {
                            this.fileWriter.WriteElementString(a.Name,
                                a.type == Attribute.AttributeType.STRING ?
                                a.value_string : a.value_int.ToString());
                        }

                    this.fileWriter.WriteEndElement(); //Attributes
                    
    
                    Tree subtree = new Tree(this.Depth-1,this.SplitSize,this.VertexAttributes,this.EdgeAttributes,this.type,e.Bottom,fileWriter);

                    //Console.WriteLine(e.Top.Name+" -> "+e.Name+" -> "+subtree.root.Name);

                    this.fileWriter = subtree.generateTreeXML(false);

                    this.fileWriter.WriteEndElement(); //Vertex
                    this.fileWriter.WriteEndElement(); //Edge

                }
            }

            return this.fileWriter;
        }
Exemple #4
0
        private XmlTextWriter generateTreeXML(bool first)
        {
            if (this.root == null)
            {
                return(this.fileWriter);
            }

            if (this.root.OutgoingEdges == null)
            {
                return(this.fileWriter);
            }

            //Prima esecuzione
            if (first)
            {
                this.fileWriter.WriteStartElement("Vertex");
                this.fileWriter.WriteElementString("Name", root.Name.ToString());
                this.fileWriter.WriteElementString("Depth", root.Depth.ToString());

                //Console.WriteLine("Io sono il primo: "+root.Name);

                this.fileWriter.WriteStartElement("Attributes");
                foreach (Attribute a in root.Attributes)
                {
                    this.fileWriter.WriteElementString(a.Name,
                                                       a.type == Attribute.AttributeType.STRING ?
                                                       a.value_string : a.value_int.ToString());
                }
                this.fileWriter.WriteEndElement();     //Attribute


                this.fileWriter = this.generateTreeXML(false);
                this.fileWriter.WriteEndElement(); //Vertex
            }
            else
            {
                foreach (Edge e in this.root.OutgoingEdges)
                {
                    this.fileWriter.WriteStartElement("Edge");

                    this.fileWriter.WriteElementString("Name", e.Name.ToString());
                    this.fileWriter.WriteStartElement("Attributes");

                    foreach (Attribute a in e.Attributes)
                    {
                        this.fileWriter.WriteElementString(a.Name,
                                                           a.type == Attribute.AttributeType.STRING ?
                                                           a.value_string : a.value_int.ToString());
                    }

                    this.fileWriter.WriteEndElement(); //Attributes


                    this.fileWriter.WriteStartElement("Vertex");
                    this.fileWriter.WriteElementString("Name", e.Bottom.Name.ToString());
                    this.fileWriter.WriteElementString("Depth", e.Bottom.Depth.ToString());


                    this.fileWriter.WriteStartElement("Attributes");

                    foreach (Attribute a in e.Bottom.Attributes)
                    {
                        this.fileWriter.WriteElementString(a.Name,
                                                           a.type == Attribute.AttributeType.STRING ?
                                                           a.value_string : a.value_int.ToString());
                    }

                    this.fileWriter.WriteEndElement(); //Attributes


                    Tree subtree = new Tree(this.Depth - 1, this.SplitSize, this.VertexAttributes, this.EdgeAttributes, this.type, e.Bottom, fileWriter);

                    //Console.WriteLine(e.Top.Name+" -> "+e.Name+" -> "+subtree.root.Name);

                    this.fileWriter = subtree.generateTreeXML(false);

                    this.fileWriter.WriteEndElement(); //Vertex
                    this.fileWriter.WriteEndElement(); //Edge
                }
            }

            return(this.fileWriter);
        }