Graph Coloring Program of Exam Scheduling Modeling Based on Bitwise Coloring Algorithm Using Python

Corresponding Author: Samsul Arifin Department of Statistics, School of Computer Science, Bina Nusantara University, Jakarta, 11480, Indonesia Email: VanDerMerwe@nwu.ac.za Abstract: A graph coloring is the process of assigning labels to the vertices of a graph in such a way that no two adjacent vertices have the same color. The chromatic number of a graph G is the smallest number of colors that can be assigned to it. Graph coloring has a wide range of applications and is commonly used to solve scheduling issues. In this article, the researchers design an algorithm and apply it to a computer program (Python) to solve graph coloring and to visualize the variation of exam scheduling modeling at Binus University in graphs based on the Bitwise Graph Coloring Algorithm. The researchers develop a graph coloring algorithm by considering some of the graph vertices to be binary numbers. Bitwise operations make this algorithm run very fast. The algorithm constructed by the researcher is a modification of Komosko, etc.’s algorithm in 2015 and it is the key result of this research. The researchers try to offer an alternative method in the process of making the final semester exam schedule. Next, the researcher tested the program on the data of subjects and students who took it at the Study program of TI-StatMath in Binus University. Our results show that from the program created and the simulations performed, 8 schedule slots are generated in about 0.675 sec.


Introduction
In the world of education, exams are very important. With the examination, it will be known to what extent the level of understanding of the _eld of study is being studied. For elementary, junior high, or high school levels, determining the exam schedule is not too di_cult, because each student gets the same subject. It's di_er-ent at university. Every student has the right to take the courses they want, as long as they have taken the prerequisite courses. This makes it possible for students to take several courses that can conflict with their exam schedules. Academic office staff must determine an exact exam schedule and avoid all exam schedules colliding. It is possible that he can make a schedule with each course having a different exam time, but it will take a very long examination period. This will be detrimental to many parties, both lecturers, students and all university employees. For this reason, the officer certainly wants to make the exam period as short as possible without a collision schedule (Budiman, 2007).
In the Binus University, TI-Stat department, scheduling semester exams sometimes still have problems. Students with a collision schedule are allowed to contact academic officers. Then the officer changed the schedule to a revised schedule and announced it again through the Binusmaya website. If there are still reports of collisions from students, then another revision will be held and so on until the final schedule where there is no collision exam schedule. This was done in a relatively long interval. However, this problem can be solved easily if using the graph coloring concept. One of the advantages of graph coloring is that the existing schedules do not collide with each other (Rosen, 2019). Besides, by using the concept of Graph Coloring, the researcher believes that the time required to compile a schedule is also much shorter when compared to the usual method (Komosko et al., 2016).
Several studies that have used graph coloring for scheduling have been carried out by Muktyas (2010;Firdaus, 2020;Bustan and Salim, 2019). Furthermore, there is a very good method used in making schedules using the concept of graph coloring, which the researchers call the bitwise graph coloring method (Komosko et al., 2016). On the other hand, the Python programming language has supported several functions and libraries that the researcher can use to make scheduling using the concept of graph coloring with the help of the bitwise graph coloring method (Oliphant, 2007). For that, from some of the literature, the researchers want to study the Graph coloring program of exam scheduling modeling at Binus University based on a bitwise coloring algorithm using Python. Furthermore, the researcher would like to show an alternative algorithm in the application of graph coloring techniques, one of which is the process of making an exam schedule at Binus University.

Materials and Methods
The research style employed here is one of investigation and application of previously obtained results, as evidenced by a review of the literature (Gravetter and Forzano, 2012). This section examines the theories that were utilize in this investigation.

Notion of Graph
The researcher will start by looking at the concept of graphs (Rosen, 2019). v2,v3,v4,v5,...,vn} which is called a set of vertex/points and a collection of E = {e1,e2,e3,e4,e5,e6,...,en} which is a collection of edge such that each edge of the ek is associated with an unordered pair (vi, vj).
The points vi, vj concerning ek are called the endpoints of the edge ek. If a point vi is the endpoint of an edge ek, then vi and ek are called incidences, or the point vi is related/attached/incident to the edge ek. Two nonparallel edges are called neighboring/adjacent if both sides are attached to the same point. Two points are called neighboring if the two points are endpoints of the same side (Rosen, 2019). The most common way to present a graph is with a diagram. Points are represented by dots and sides are represented by a simple curve connecting each of the two points. G is called a simple graph if G contains no loops and doubles. The number of edges associated with the point v is called the degree of v, denoted by d (v). Any graph G corresponds to a matrix of size n×n which is called the adjacency matrix of G. Adjacency matrix A(G) = [aij], where aij is the number of edges associated with the pair of points vi and vj (Widodo, 2016).

Notion of Coloring Graph
Vertex coloring on a graph is the giving of colors to the vertex of a graph so that no two adjacent vertexes on the graph have the same color (Malkawi et al., 2008). Definition 2.2 is the definition of graph coloring (Klotz, 2002).

Definition
A vertex coloring of graph G = (V, E) is an F: V → N mapping where neighboring points are different colors in N, i.e., if uv is in E, then F(u) is not equal to F(v).
A graph G can be colored with a different color at each point, however, in its application, coloring the graph with as little color as possible is very necessary. The minimum number required by graph G so that all points are colored without a pair of neighboring points of the same color is called the chromatic number of graph G, denoted χ(G). A graph G is called k -chromatic if χ (G) = k (Klotz, 2002).
A well-known combinatorial optimization problem is the Vertex Colouring Problem (VCP). It's one of Karp's twenty-one NP-complete issues. It is impossible to discover an exact solution in a reasonable amount of time for this class of problems because the solution space grows exponentially in proportion to the size of the input data. The VCP entails determining the smallest number of colors required to color all of a graph's vertices in such a way that any two neighboring vertices have distinct colors. The VCP is useful in a variety of situations. provide an excellent survey. It can be used to solve a variety of scheduling issues. The graph vertices in this case represent courses that should be included in the timetable and the colors represent time gaps during which many courses are held simultaneously. If the related courses cannot be held at the same time, an edge is put between them (Komosko et al., 2016).
The Bitwise graph coloring algorithm is one of the algorithms used to color graphs. Komosko et al., (2016) developed a graph coloring technique based on bitwise operations on the adjacency matrix (A) and a special matrix known as the forbidden matrix C A fast greedy sequential heuristic for the vertex coloring problem is described in their work. The proposed approach colors the graph in the same way as the well-known greedy sequential heuristic, which colors the current vertex in the smallest possible color at each step. The development of a special prohibited colors matrix and the use of efficient bitwise operations on bit representations of the adjacency and forbidden colors matrices are two of their primary contributions. (Komosko et al., 2016).
The researchers see that there is a deficiency in the algorithm proposed by Komosko, there is no order of degrees from the point. Note that in graph theory, the order of the degree of points will affect the number of coloring results. If not sorted, it will usually result in a large staining result. Furthermore, the number of coloring results corresponds to the number of schedule slots formed. To overcome this weakness, in this study the degrees of points are ordered in descending order. By ordering the vertices in descending order, the resulting graph color is equal to the upper limit of the chromatic number, which will ensure that the number of colors in the graph is small. Thus, the resulting schedule slots are also few. The researcher feel that this weakness needs to be addressed, it is related to the optimization of schedule results. The researchers believe that if the degrees of the points are not ordered, then the scheduling results obtained are not the best results. Theorem 2.3 is very useful in making the main program.

Theorem
The forbidden matrix C is a square matrix of size n × n with Cij = 1 if the color i is forbidden by point j, because one of its neighbors is already colored by i.
One row of the adjacency matrix is directly operated with a bitwise OR operation with one of the rows of the forbidden matrix C. In its implementation using Python, one row of the adjacency matrix A is considered a binary number. This number is then operated with another binary number obtained from one of the rows in the forbidden matrix C. The result of the coloring is the matrix C. Each point j in matrix C is defined as the minimum color i which is not forbidden for point j (Cij = 0) (Komosko et al., 2016). Thus, this algorithm is more effective because if the Greedy algorithm is usually done one by one, but in this algorithm, it is done at once for each row. The researchers make some modifications by sorting the adjacency matrix A by degrees in descending order. The complete algorithm is presented in Algorithm 1. Definition 2.4 is the notion of an operation of bit (Rosen and Krithivasan, 2012).

Definition
A bit string is a sequence of zero or more bits. The length of this string is the number of bits in the string. Bit operations can be extended to bit string operations, i.e., bitwise. Bitwise OR and of two strings of the same length can be obtained by operating OR and on each corresponding bit.
From Definition of 2.4, the researcher will get a perspective on graph coloring contained in the 2.5, which describes one of the graph coloring algorithms, namely Greedy coloring. Please see Table 1 for more details.

Theorem
Greedy coloring can be viewed as a series of bitwise operations OR and SHIFT operators.

Generate Code
From Theorem 2.5, a graph coloring algorithm can be constructed which is contained in Algorithm 1. Algorithm 1. Bitwise Graph Coloring 1. Input: A_nxn 2. Sort the matrix A by degrees in descending order, also save the order index 3. Assume that each row in matrix A is a binary.
for j in range(n): # j -> row of C 9.
cek From Algorithm 1, it will be applied to a small graph as stated in the Example 2.6 (Komosko et al., 2016).
Example 2.6 Look at the picture below. A graph with 7 vertices is represented in the adjacency matrix A. The initial forbidden matrix C is a zero matrix of size 7×7.
Matrix C on the right is the final result of the graph coloring. The coloring of each point i is determined by looking at the zero values in column i of matrix C. Based on the forbidden matrix C, the graph coloring from points 1,2,3,4,5,6,7 is 1,2,3,1,2,1,2.
The algorithm above is proven to be able to run well in graph coloring and is able to produce an efficient scheduling process. On the other hand, the concept of bitwise graph coloring has also been applied in several ways, namely in the topic TDMA schedule and Congestion Game Analysis (Xiaoying, 2019;Jioudi et al., 2019). Algorithm 2 is about converting some dataset into an adjacency matrix.
Algorithm 2. Convert The Dataset into Adjacency Matrix 1. Arrange the raw data into two columns, the first column is for the course id, the second column is for the student id or student name 2. mk = the list containing unique course ids. Also create a separator index from the data already in the group 3. n = len(mk) 4. adj = zero-matriks of size n x n 5. mk_pisah = list of second column data separatedby separator index 6. for i in range(0,n): 7.

Python
After studying graph theory and the concept of coloring a graph, the researcher will discuss the programming language that the researcher use. The researcher will go over the Python scripts that employed in the next few paragraphs. The researcher used Python 2.7.14 to generate some code. The main outcome of this article is the Python program code. The things mentioned in Algorithm 1 become the foundation for creating the software. However, it should be emphasized that the Python program in question must have the "NumPy" plugin installed. The procedures for installing NumPy in Windows OS are simple (Project Teams, 2020). Python is a widely used programming language. Python is a computer language that is considerably easier to learn and use than other programming languages (Chollet, 2021). Because the idea of python itself promotes readability, the syntax is straightforward, easy to comprehend and remember. Python code is simple to develop and read, making it simple to debug and maintain .
Python is not only easier to read, but it is also more efficient than languages like C, C++ and Java. With another language, 5 lines of code may be required; but, in Python, only one line of code may be required. As a result, Python programs are more concise and faster to write than programs written in other languages (Rahman et al., 2019). Python is a multipurpose programming language. Python can be used for a wide range of tasks, including text processing, website development, network programming, robotics, data mining, artificial intelligence and more . We can make desktop and smartphone applications with Python. Python has a lot of built-in library support. You can utilize a variety of modules and software extensions to customize the application to meet your specific requirements. Python's community is very active in developing the language so that it becomes a very trustworthy language. Python has the ability to communicate with other languages. Python code can be called from C, C++ and other programming languages and vice versa (Arifin et al., 2012).
In short, the reason the researcher use Python is that Python is a powerful language and can be run on multiple platforms, but it's also very easy to understand. After that, the researcher will do a simple simulation using huge data (2803 rows) located in the TI-Mat-Stat Study Program, Bina Nusantara University. The first thing to do is create a table containing the courses and NIM students who take them. Table 3 is a table view of courses and NIM students. Furthermore, the complete code of our Python program is as follows, which will close this session: https://github.com/muktyas/bit-graph-coloring.

Results and Discussion
The specifications of the computer used are Intel Core i3-2310M CPU @ 2.10GHz x 2 ram 7.7 GiB with Linux Mint 20.2 Cinnamon Operating System. The raw data obtained from the academic section in the form of course id and student names are arranged into two columns. The first column contains course id, while the second column contains the student's name. The table is sorted by the first column. After that, the raw data is converted into an adjacency matrix. The raw data obtained from the academic section of Binus University at TI-Math-Stat program in all batches consisted of 59 different subjects. If it is arranged into two columns, then 2802 rows are formed, which can be seen in the Fig. 1. This is our main program, which is the main result of this study: The Main Program import numpy as np import time The next process, Algorithm 2 is applied to Python program to convert raw data into adjacency matrix. The result is on Table 2. Moreover, the average time required is 1.198271608352 seconds. After sorting the adjacency matrix based on the degree of the point in descending order, then graph coloring is carried out using Algorithm 1. This program produces a matrix C in the form of decimal numbers as follows.
The Output of Matrix C c = [287878360632130526, 396312094275534822, 484135860426505643, 562378202004053948, 575194045616614992, 576407408675319809, 571950546240339968, 408587686408880128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] From the Result 1, there are 8 non-zero numbers in matrix C. This means that only 8 colors are needed to color the graph. Each number in the C matrix is then interpreted into a binary number so that it can be read easily. So the new matrix C can be viewed as a matrix with a size of i×j. The zero bits in column i,j in the new matrix C indicate that the j points can be colored with the color i. There are two outputs from this program, the first is output based on courses, while the second is output based on color. This is one of the advantages of coloring using bitwise. The resulting output is two columns with 59 rows. The number of rows indicates the number of courses. The first column shows the sequence of dots (the course code), while the second column shows the color (time slot), as follow. From the Result 2, the researcher can immediately see the time slots for each course code index. If the researchers want more slot variations, then the researcher can see it in the second output, namely the output based on color.

Result 2. The Course Code and Time Slot
The Result 3 is the output of the program that has been made.
Note that in this paper the researchers try to offer an alternative method in the process of making the final semester exam schedule. The algorithm that the researcher proposed is the development of Komosko et al. (2016), which still has some weaknesses. The researcher think that this method has more benefits if applied on a smaller scale at Binus University or other universities. However, this method still needs to be developed so that it can generate schedule variations for users, so that they can choose one of the schedule variations provided by the algorithm.

Conclusion and Open Problem
The conclusion of this research is as follows. Bitwise coloring can be used for scheduling semester exams. From the program, 8 time slots are needed. The time used to run this program is 0.675 sec. With this short time, these results can be used as consideration for the scheduling officer at Binus University in preparing the semester exam schedule. The results in this study can also be used and developed in other institutions. The open problem of this research is how to produce output in the form of schedule variations according to what the researchers want. The researchers believe that if the researcher can generate permutations of vertices of the same degree, then our problem can be shed light on. These two pieces of information will close this study.