Optimizing Connections: Mathematical Optimization within Graphs