## 5 Algorithmic Procedures
### Eulerian  
This algorithmic procedure allows us to determine whether a graph is Eulerian. Additionally, it identifies the Eulerian cycle or path if the graph is semi-Eulerian. We implement the procedure eulerianGraph, which takes a graph \(G\) as input. The output is either the Eulerian cycle (if the graph is Eulerian), the semi-Eulerian path (if the graph is semi-Eulerian), or a message indicating that the graph does not meet the necessary conditions. The implementation begins by verifying if the graph is Eulerian using the function _isEulerian_. If the graph is Eulerian, a message is displayed along with the trail \(T\), which represents the Eulerian cycle. If the graph is not Eulerian, we calculate the number of vertices with an odd degree, noting that a graph is semi-Eulerian if it has exactly two vertices with odd degrees. In such cases, we apply a depth-first search (DFS) algorithm to traverse the graph, construct a path that visits all vertices and edges, and output the semi-Eulerian path. If none of these conditions are satisfied, the procedure outputs a message stating that the graph is neither Eulerian nor semi-Eulerian. > eulerianGraph := proc(H) > local count, i, j, v, w, path, verts, N, vertices, edges, visited; > if IsEulerian(H, 'T') then > print(\"The graph is eulerian\"); > print(The eulerian cycle is T); > else > count := 0; > verts := []; > for v in Vertices(H) do > if type(Degree(H, v), odd) then > count := count + 1; > verts := [op(verts), v]; > fi; od; > if count = 2 then > print(\"'The graph is semieulerian\"); > vertices := Vertices(H); > edges := Edges(H); > visited := {op(vertices)}; > path := []; > for i to nopse(edges) do > if edges[i][1] = verts[1] and not edges[i] in visited then > visited := visited union {edges[i]}; > path := [op(path), verts[1], edges[i][2]]; > w := edges[i][2]; > break; > elif edges[i][2] = verts[1] and not edges[i] in visited then > visited := visited union {edges[i]}; > path := [op(path), verts[1], edges[i][1]]; > w := edges[i][1]; > break; > fi; od; > while nops(path) <= nops(edges) do > N := Neighbors(H, w); > for i to nops(N) do > for j to nops(edges) do > if edges[j][1] = w and edges[j][2] = N[i] and not edges[j] in visited then > visited := visited union {edges[j]}; > path := [op(path), N[i]]; > w := N[i]; > break; > elif edges[j][2] = w and edges[j][1] = N[i] and not edges[j] in visited then > visited := visited union {edges[j]}; > path := [op(path), N[i]]; > := N[i]; > break;> f1; od; od; od; od;  > print(\"Semiulerian Path::\", path);  > else > print(\"The graph isn't eulerian or semieulerian\");  > f1; fi;  > end proc:  
Now, we implement another algorithmic procedure, which studies if a graph is Eulerian or not based on Lemma 1. We have implemented four subroutines: createHullEdges, findOtherEdges, countElements, and isK3. The first subprocedure, called createHullEdges, receives as input the convex hull of the graph, \(ch\). The output is a list of the edges that belong to the convex hull. Concerning the implementation, it takes the list of vertices of the convex hull and create a list of the edges that join them. > createHullEdges := proc(hull)  > local edges, i;  > edges := [];  > for i to nope(hull) - 1 do  > edges := [op(edges), {hull[i + 1], hull[i]}];  > od;  > edges := [op(edges), {hull[-1], hull[1]}];  > return edges;  > end proc:  
The next subroutine is called findOtherEdges. It receives as input the list of edges of the graph and the edges that belong to the convex hull, which is the output of createHulledges. The output is the list of edges that do not belong to the convex hull. Concerning the implementation, it analizes if every edge is in the list of the edges that belong to the convex hull, and, if it is not there, it is added to a new list: \(otherEdges\).