Sorry there is no silver bullet. It's not easy to come up with a solution that is satisfactory in all cases, since it is not easy to come up with a good definition of side compounds in the first place.
Most people just apply a threshold on the degree, defining highly connected compounds as probable cofactors. Since you want to remove them most of the time but keep them in the few special cases, you might want to filter edges rather than nodes in your networks, considering side "transitions" rather than side compounds (the way KEGG was doing with RPARIS).
From a compound graph, where each node is a compound and reactions represented by several edges connecting them, you can use atom-mapping data to filter connections between compounds without any shared carbons, which is a good heuristic to define side transitions. Reactions like A + ATP -> B + ADP become the edge set A->B, ATP->ADP, putting the side compounds apart by removing A->ADP and ATP->B edges.
Inorganic carbon compounds and Coenzymes might still have spurious connections though.
Models like recon3D provide atom-mappings in SMILES format, otherwise it can be computed with tools like ReactionDecoderToolkit, if you have InChI or other representation of compound structures. If you have structure and don't want to bother computing atom-mapping, you might also compute chemical similarities between substrates and products and filter low-similarity edges...