TLDR: This research explores applying Generative Flow Networks (GFlowNets) to solve fundamental graph optimization problems: Shortest Path, Minimum Spanning Tree, and Traveling Salesperson Problem. GFlowNets learn to generate solutions by sampling actions based on a reward function, effectively finding optimal solutions that match classical algorithms for small instances. While classical methods are faster for small problems, GFlowNets offer a learning-based approach with potential for computational scalability and amortization of training costs for larger, more complex instances where traditional exact methods become infeasible. The study demonstrates a unified framework for these problems and highlights the importance of local constraint handling.
Graph optimization problems are fundamental challenges in computer science, impacting fields like logistics, network design, and resource allocation. Traditionally, these problems, such as finding the Shortest Path, constructing a Minimum Spanning Tree (MST), or solving the Traveling Salesperson Problem (TSP), have been tackled by classical algorithms like Dijkstra’s, Kruskal’s, or sophisticated exact solvers for TSP. These algorithms are known for their deterministic execution, optimality guarantees for tractable problems, and fixed computational complexity.
However, classical methods face limitations, especially with NP-hard problems like TSP, where exact solutions become computationally infeasible as problem sizes grow. This has opened the door for new approaches, particularly from the realm of artificial intelligence.
A New Approach: Generative Flow Networks
Recent advancements in deep learning have introduced generative models, which are neural networks capable of creating complex structured outputs. Generative Flow Networks (GFlowNets), a specific type of generative model, are designed to sample structured objects in proportion to a given reward function. This means that objects with higher rewards (e.g., lower costs in optimization problems) are sampled more frequently.
The core idea is to shift from predetermined, step-by-step procedures to a learned probabilistic policy. Instead of following fixed rules, GFlowNets learn to generate solutions by sampling actions based on probabilities they’ve learned during training. This introduces a different computational trade-off: a significant upfront training cost in exchange for the ability to generate solutions through learned heuristics.
How GFlowNets Tackle Optimization
The research paper, “Exploration through Generation: Applying GFlowNets to Structured Search” by Mark Phillip Matovic, explores the application of GFlowNets to three canonical graph optimization problems: Shortest Path, Minimum Spanning Tree, and Traveling Salesperson Problem. These problems represent a spectrum of computational complexity, from polynomial-time solvable to NP-hard.
For each problem, the GFlowNet framework adapts to its unique characteristics:
- Shortest Path: Path-finding is seen as a sequence of node selections, where the model learns to navigate from a source to a target by picking low-cost edges.
- Minimum Spanning Tree: MST construction involves sequentially adding edges. The model uses a Disjoint Set Union (DSU) structure to efficiently prevent cycles, guiding it towards low-weight trees.
- Traveling Salesperson Problem: Tour generation is framed as visiting cities one by one, with explicit constraints to avoid revisiting cities. The model learns to create short tours that visit every city exactly once.
The models are trained using a technique called Trajectory Balance loss, which ensures that the probability of generating a complete solution is proportional to its reward (inverse of its cost). This allows the GFlowNet to learn policies that favor optimal or near-optimal solutions.
Key Findings and Performance
Experiments on benchmark instances of varying sizes demonstrated that GFlowNets successfully learn to find optimal solutions. For all three problem types, the generated solutions matched those found by classical algorithms. This validates that GFlowNets can discover optimal configurations through reward-guided training.
Crucially, the framework effectively integrates combinatorial constraints. For example, in MST, the DSU structure prevents cycles, and in TSP, a visited mask ensures each city is visited only once. These mechanisms ensure that the generated solutions are always valid.
The research also highlighted the computational trade-offs. For small problem instances, classical algorithms are significantly faster, providing solutions in milliseconds. GFlowNets, however, require an upfront training investment (minutes for these small instances). The advantage of GFlowNets lies in their potential scalability: this training cost can be amortized if the learned policies can be applied to many similar problems or if they can tackle much larger instances where classical exact methods become infeasible. The inference process (generating solutions after training) can also be highly parallelized.
Also Read:
- Deconstructing Vehicle Routing: A Modular Approach to Multi-Task Optimization
- Simplifying Complex Logistics: A Graph Coarsening Approach for Vehicle Routing with Time Windows
Challenges and Future Outlook
While promising, the current work focused on small problem instances (e.g., 5-10 nodes for shortest path, 4-8 cities for TSP). Scaling to real-world problem sizes (hundreds or thousands of nodes) remains a significant challenge, requiring more training time, larger network capacities, and potentially more sophisticated architectures like Graph Neural Networks (GNNs).
An attempt to apply GFlowNets to the Maximum Flow problem was unsuccessful, revealing an important lesson: GFlowNets work best when constraints can be checked and enforced locally at each step. Problems with complex global constraints that couple many variables simultaneously are more difficult to formulate effectively for this approach.
This research establishes GFlowNets as a viable proof-of-concept for combinatorial graph optimization. It demonstrates that generative modeling principles can be applied to optimization tasks, offering a complementary approach to traditional deterministic methods. Future work will likely explore architectural improvements, systematic scaling studies, and hybrid approaches that combine the strengths of both learned policies and classical algorithms. You can read the full paper here: Exploration through Generation: Applying GFlowNets to Structured Search.


