示例#1
0
 //METHODS
 public void AddPreviousNode(ref DNode prev)
 {
     this.previousNode = prev;
 }
示例#2
0
 public bool IsNeighborOf(ref DNode other)
 {
     return(this.neighborsList.Contains(other));
 }
示例#3
0
        public static void MakeArraysForTable(DNode node, int discovery)
        {
            foreach (DNode neighbor in node.GetNeighbors())
            {
                String name1   = neighbor.GetNodeName();
                String weight1 = neighbor.GetWeight().ToString();
                if (!neighbor.IsVisited())
                {
                    String prev = neighbor.GetPreviousNode().GetNodeName();
                    weight1 = weight1 + ", " + prev;
                }


                switch (name1)
                {
                //case "u": break;
                case "v": dv[discovery] = weight1; break;

                case "w": dw[discovery] = weight1; break;

                case "x": dx[discovery] = weight1; break;

                case "y": dy[discovery] = weight1; break;

                case "z": dz[discovery] = weight1; break;
                }
            }

            foreach (DNode nd in network.nodesList)
            {
                String name   = nd.GetNodeName();
                String weight = nd.GetWeight().ToString();

                //unreachable nodes //∞
                if (weight == "999999999")
                {
                    weight = "∞";
                    switch (name)
                    {
                    //case "u": break;
                    case "v": dv[discovery] = weight; break;

                    case "w": dw[discovery] = weight; break;

                    case "x": dx[discovery] = weight; break;

                    case "y": dy[discovery] = weight; break;

                    case "z": dz[discovery] = weight; break;
                    }
                }

                //already visited nodes
                else if (nd.IsVisited())
                {
                    weight = "-";
                    switch (name)
                    {
                    //case "u": break;
                    case "v": dv[discovery] = weight; break;

                    case "w": dw[discovery] = weight; break;

                    case "x": dx[discovery] = weight; break;

                    case "y": dy[discovery] = weight; break;

                    case "z": dz[discovery] = weight; break;
                    }
                }

                //nodes that stay the same weight
                else
                {
                    switch (name)
                    {
                    //case "u": break;
                    case "v":
                        if (dv[discovery] == "#")
                        {
                            dv[discovery] = dv[discovery - 1];
                        }
                        break;

                    case "w":
                        if (dw[discovery] == "#")
                        {
                            dw[discovery] = dw[discovery - 1];
                        }
                        break;

                    case "x":
                        if (dx[discovery] == "#")
                        {
                            dx[discovery] = dx[discovery - 1];
                        }
                        break;

                    case "y":
                        if (dy[discovery] == "#")
                        {
                            dy[discovery] = dy[discovery - 1];
                        }
                        break;

                    case "z":
                        if (dz[discovery] == "#")
                        {
                            dz[discovery] = dz[discovery - 1];
                        }
                        break;
                    }
                }
            }

            /*
             * //D(v), D(w), D(x), D(y), D(z)
             * foreach (DNode neighbor in node.GetNeighbors())
             * {
             *  Debug.WriteLine("TEST");
             *  String name = neighbor.GetNodeName();
             *  String weight = neighbor.GetWeight().ToString();
             *  if (neighbor.IsVisited())
             *  {
             *      weight = "-";
             *  }
             *  else {
             *      String prev = neighbor.GetPreviousNode().GetNodeName();
             *      weight = weight + ", " + prev;
             *  }
             *
             *  switch (name)
             *  {
             *      //case "u": break;
             *      case "v": dv[discovery] = weight; break;
             *      case "w": dw[discovery] = weight; break;
             *      case "x": dx[discovery] = weight; break;
             *      case "y": dy[discovery] = weight; break;
             *      case "z": dz[discovery] = weight; break;
             *  }
             * }*/
        }