Direction flip counter

image

I think I just created a functional direction-flips counter for the directed graph that my SPARQL-powered ontology-pathFinder produces :)).


>>> path = [['drie','>','vijf'],['vijf','>','negen'],['zeven','>','negen'],['zeven','>','acht'],['acht','>','twaalf'],['negentien','>','twaalf']]
>>> findFlips(path,'drie','negentien')
drie vijf
vijf negen
up
zeven negen
down
zeven acht
acht twaalf
up
negentien twaalf
down
3 flips

It seems to work correctly on this incredibly tricky test-path I gave it ;).

Leave a Reply