I am currently trying to find the longest cycle in a !directed! graph G = (V,E). For that, I first want to (have to) formulate an integer linear program (ILP). The objective function is in my opinion quite clear: min sum_{e in E} -w_e * x_e (I formulate it as a minimization problem for future work). Here, x_e is a binary variable which is 1 if I use this specific edge (/arc) and zero otherwise; w_e is the weight of edge e. To assure that the solution is a simple cycle, I thought about having deg_{in}^{i} = deg_{out}^{i} = 1 for all nodes i in the solution set, i.e. there is exactly one arc entering node i and exactly one arc leaving node i, given that node i is part of the cycle. Those constraints, however, are not enough to solve this problem, as it could still happen that the solution is a set of disjoint cycles, instead of one single cycle. Does somebody have an idea how to solve the problem? Thank you!!
Asked
Active
Viewed 102 times
1 Answers
0
You need to add TSP-like subtour-elimination constraints. See: https://yetanothermathprogrammingconsultant.blogspot.com/2020/02/longest-path-problem.html.

Erwin Kalvelagen
- 15,677
- 2
- 14
- 39
-
Yes, I also thought about this one, but I don't know the number of vertices (n) used in the longest (weighted) cycle, such that the formulation of the constraints is quite hard – umhk25 Apr 28 '22 at 08:39
-
You only know after solving the problem. Just as in the model in the link. (No assumption you need to know this in advance). – Erwin Kalvelagen Apr 28 '22 at 20:33