This paper focuses on the development of a generalized method for describing and handling any type of heat exchange restrictions between subsets of thermal streams when dealing with automatic energy targeting. A graph theory representation of the heat exchange opportunities between stream subsets called heat integration graph is introduced. This graph is used to identify subsystems consisting of one or more stream subsets which can be treated as separate thermal cascades. These correspond to maximal subgraphs that are completely connected components of the heat integration graph, also called “cliques”. The stream subsets belonging to more than one clique, here called “pivot”, are those which thermal streams have to be optimally distributed to two or more cliques. The hot utility target of a system can then be found by solving a linear programming optimization in which the constraints that guarantee a feasible thermal cascade in all the maximal subgraphs are included. The procedure is applied here to a numerical example of a sugarcane mill in which some heat exchange restrictions are considered between process units.