first version, faulty results for more complex graphs