a slightly different approach to traversing the graph by also checking
bidirected edges