CodeReclaimers / neat-python

Python implementation of the NEAT neuroevolution algorithm
BSD 3-Clause "New" or "Revised" License
1.42k stars 493 forks source link

Cycle check function returns incorrect boolean #159

Closed oneturkmen closed 5 years ago

oneturkmen commented 5 years ago

https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/graphs.py#L3

If I run the function above with the following inputs:

connections = [(2, 4), (1, 5), (4, 6), (5, 6), (6, 3)] test = (5, 4)

it returns False. I think it should return True instead since (5,4) creates a cycle and the network previously hasn't had any cycles. Is it working correctly?

CodeReclaimers commented 5 years ago

The functions in the graphs module assume the graphs are directed; for an undirected graph (5,4) would create a cycle, but not in a directed graph.

oneturkmen commented 5 years ago

@CodeReclaimers makes sense now. Thanks!