Пример #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);
        }
Пример #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);
        }
Пример #3
0
        internal Graph(int initialVertex, Edge[] mustEdges,Edge[] optionalEdges, int [] nondetVertices,bool builtNondNeigh,WeakClosureEnum closerInstuction)
            : this(initialVertex,mustEdges,optionalEdges,closerInstuction)
        {
            if(builtNondNeigh==true)
            {
              this.nondNeighbours=new RBMap();

              foreach(int p in nondetVertices)
            {
              if(p<this.NumberOfVertices)
                {
                  HSet s=(this.nondNeighbours[p]=new HSet()) as HSet;
                  foreach( Edge l in this.graph.EdgesAtVertex(p))
                    s.Insert(l.target);
                }
            }
            }
              else
            this.nondNeighbours=null;
        }
Пример #4
0
        internal Graph(int initialVertex, Edge[] mustEdges, Edge[] optionalEdges, int [] nondetVertices, bool builtNondNeigh, WeakClosureEnum closerInstuction)
            : this(initialVertex, mustEdges, optionalEdges, closerInstuction)
        {
            if (builtNondNeigh == true)
            {
                this.nondNeighbours = new RBMap();

                foreach (int p in nondetVertices)
                {
                    if (p < this.NumberOfVertices)
                    {
                        HSet s = (this.nondNeighbours[p] = new HSet()) as HSet;
                        foreach (Edge l in this.graph.EdgesAtVertex(p))
                        {
                            s.Insert(l.target);
                        }
                    }
                }
            }
            else
            {
                this.nondNeighbours = null;
            }
        }