Exemplo n.º 1
0
        public bool HasConflicts(ref Vertex[] vertices)
        {
            bool result = false;

            for (int i = 0; i < AL.Length && !result; i++)
            {
                if (AL[i] == null)
                {
                    continue;
                }

                AdjVertex curr = AL[i];
                while (curr != null)
                {
                    if (vertices[i].color == curr.target.color)
                    {
                        result = true;
                        break;
                    }
                    curr = curr.next;
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        public void TraverseOnDelete(int course)
        {
            AdjVertex curr = AL[course];

            while (curr != null)
            {
                --curr.target.degree;
                curr = curr.next;
            }
        }
Exemplo n.º 3
0
        public void BanColor(int course, int color, int numColors)
        {
            AdjVertex curr = AL[course];

            while (curr != null)
            {
                if (curr.target.bannedColors == null)
                {
                    curr.target.bannedColors = new int[numColors];
                }
                curr.target.bannedColors[color] = 1;
                curr = curr.next;
            }
        }
Exemplo n.º 4
0
        public void Insert(int courseNumber, Vertex v)
        {
            AdjVertex temp = new AdjVertex(v);

            if (AL[courseNumber] == null)
            {
                AL[courseNumber] = temp;
            }
            else
            {
                temp.next        = AL[courseNumber];
                AL[courseNumber] = temp;
            }
        }
Exemplo n.º 5
0
        public bool IsAdjacentToColored(int course, int newColor)
        {
            AdjVertex curr = AL[course];

            while (curr != null)
            {
                if (curr.target.color == newColor)
                {
                    return(true);
                }
                curr = curr.next;
            }
            return(false);
        }
Exemplo n.º 6
0
        public void BuildDegreeList(ref Vertex[] verticies, ref DegreeList degList)
        {
            for (int i = 0; i < AL.Length; i++)
            {
                if (AL[i] == null)
                {
                    continue;
                }

                int       count = 0;
                AdjVertex curr  = AL[i];
                while (curr != null)
                {
                    ++count;
                    curr = curr.next;
                }
                verticies[i].degree = count;
                degList.Insert(verticies[i]);
            }
        }
Exemplo n.º 7
0
        public void Print()
        {
            for (int i = 0; i < AL.Length; i++)
            {
                if (AL[i] == null)
                {
                    continue;
                }

                AdjVertex curr   = AL[i];
                string    result = i.ToString() + ": ";
                while (curr != null)
                {
                    result += " " + curr.target.course.ToString();
                    curr    = curr.next;
                }

                Console.WriteLine(result);
            }
        }