Implement grpah creation
Complete implementation of optimization routines