public void Delete(ref AdjList adjList, ref Stack stack) { deletedDegree = degree; stack.Push(this); adjList.TraverseOnDelete(course); }
public void RandomPass(ref AdjList adjList, ref Stack stack) { int newColor = 0; while (adjList.IsAdjacentToColored(course, newColor)) { ++newColor; } color = newColor; stack.Push(this); }
public void WelshPowell(ref AdjList adjList, ref Stack stack) { Vertex curr; for (int i = maxDegree; i >= 0; i--) { curr = DL[i]; while (curr != null) { curr.WelshPowellPass(maxDegree, ref adjList, ref stack); curr = curr.degNext; } } }
public int GetMinColors(ref AdjList adjList, ref Stack stack) { Vertex curr; for (int i = 0; i <= maxDegree; i++) { curr = DL[i]; while (curr != null) { curr.Delete(ref adjList, ref stack); curr = curr.degNext; } } return(stack.GetMaxDegreeDeleted() + 1); }
public void WelshPowellPass(int numColors, ref AdjList adjList, ref Stack stack) { if (bannedColors == null) { bannedColors = new int[numColors]; } for (int i = 0; i < numColors; i++) { if (bannedColors[i] == 0) { color = i; break; } } adjList.BanColor(course, color, numColors); stack.Push(this); }
public int SmallestLastPass(int numColors, ref AdjList adjList) { if (bannedColors == null) { bannedColors = new int[numColors]; } for (int i = 0; i < numColors; i++) { if (bannedColors[i] == 0) { color = i; break; } } adjList.BanColor(course, color, numColors); return(color); }
public void BuildGraph() { StreamReader srP = new StreamReader(pathToP); StreamReader srE = new StreamReader(pathToE); //First line of P tells you the number of courses String pLine = srP.ReadLine(); int.TryParse(pLine, out numCourses); //Allocate memory adjList = new AdjList(numCourses + 1); degList = new DegreeList(numCourses + 1); verticies = new Vertex[numCourses + 1]; stack = new Stack(numCourses + 1); pLine = srP.ReadLine(); //First line of E is always 0 so skip it String eLine = srE.ReadLine(); eLine = srE.ReadLine(); int courseNumber = 1; int extra = 0; int parsed; int curr; int prev; int.TryParse(pLine, out prev); while (pLine != null) { pLine = srP.ReadLine(); while (pLine == "0") { ++extra; pLine = srP.ReadLine(); } if (pLine == null) { while (eLine != null) { int.TryParse(eLine, out parsed); AddVertex(parsed, courseNumber); eLine = srE.ReadLine(); } } else { int.TryParse(pLine, out curr); int difference = curr - prev; for (int i = 0; i < difference; i++) { int.TryParse(eLine, out parsed); AddVertex(parsed, courseNumber); eLine = srE.ReadLine(); } prev = curr; courseNumber = courseNumber + extra + 1; extra = 0; } } adjList.BuildDegreeList(ref verticies, ref degList); if (verbose) { adjList.Print(); degList.Print(); } graphBuilt = true; }