Exemple #1
0
        /// <summary>
        /// </summary>
        /// <param name="initialVertex">the initial vertex - usually 0</param>
        /// <param name="mustEdges">the edge considered as must in Chinese Postman route</param>
        /// <param name="optionalEdges">the edges considered as optional in Chinese Postman route</param>
        /// <param name="closureInstruction">this instruction will shuffle some optional edges to must ones. </param>
        internal Graph(int initialVertex, Edge[] mustEdges, Edge[] optionalEdges, WeakClosureEnum closureInstruction)
        {
            if (Environment.GetEnvironmentVariable("graphtraversaldebug") == "on")
            {
                StreamWriter sw = new StreamWriter("c:/tmp/inputForGraph");
                sw.WriteLine("start vertex");
                sw.WriteLine(initialVertex.ToString());
                sw.WriteLine("must");
                foreach (Edge l in mustEdges)
                {
                    sw.WriteLine(l.source.ToString() + " " + l.label + " " + l.target + " " + l.weight);
                }
                sw.WriteLine("optional");
                foreach (Edge l in optionalEdges)
                {
                    sw.WriteLine(l.source.ToString() + " " + l.label + " " + l.target + " " + l.weight);
                }

                sw.WriteLine("nond vertices");

                sw.Close();
            }
            int n = getMaxVertex(-1, mustEdges, optionalEdges);

            this.initVertex = initialVertex;

            //this can change the must edges and optional edges arrays
            if (closureInstruction == WeakClosureEnum.Close)
            {
                CreateWeakClosureForMustEdges(
                    ref mustEdges,
                    ref optionalEdges,
                    n + 1);
            }



            this.graph = new CHPP_N_M_logN(initialVertex, mustEdges, optionalEdges, n + 1);
        }
Exemple #2
0
        /// <summary>
        /// </summary>
        /// <param name="initialVertex">the initial vertex - usually 0</param>
        /// <param name="mustEdges">the edge considered as must in Chinese Postman route</param>
        /// <param name="optionalEdges">the edges considered as optional in Chinese Postman route</param>
        /// <param name="closureInstruction">this instruction will shuffle some optional edges to must ones. </param>
        internal Graph(int initialVertex, Edge[] mustEdges,Edge[] optionalEdges, WeakClosureEnum closureInstruction)
        {
            if( Environment.GetEnvironmentVariable("graphtraversaldebug")=="on"){
            StreamWriter sw=new StreamWriter("c:/tmp/inputForGraph");
            sw.WriteLine("start vertex");
            sw.WriteLine(initialVertex.ToString());
            sw.WriteLine("must");
            foreach(Edge l in mustEdges){
              sw.WriteLine(l.source.ToString()+" "+l.label+" "+l.target+" "+l.weight);
            }
            sw.WriteLine("optional");
            foreach(Edge l in optionalEdges){
              sw.WriteLine(l.source.ToString()+" "+l.label+" "+l.target+" "+l.weight);
            }

            sw.WriteLine("nond vertices");

            sw.Close();
              }
              int n=getMaxVertex(-1,mustEdges,optionalEdges);

              this.initVertex=initialVertex;

              //this can change the must edges and optional edges arrays
              if(closureInstruction==WeakClosureEnum.Close)
            CreateWeakClosureForMustEdges(
                                      ref mustEdges,
                                      ref optionalEdges,
                                      n+1);

              this.graph=new CHPP_N_M_logN(initialVertex, mustEdges,optionalEdges,n+1);
        }