From e93735903e6ac2e184d7aa5fa8da986e9dc4a60e Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Mon, 18 Jul 2011 15:50:08 +0000 Subject: [PATCH] Util function --- DataStructures/StaticGraph.h | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/DataStructures/StaticGraph.h b/DataStructures/StaticGraph.h index 686863b29..158864f42 100644 --- a/DataStructures/StaticGraph.h +++ b/DataStructures/StaticGraph.h @@ -116,20 +116,26 @@ public: EdgeIterator FindEdge( const NodeIterator &from, const NodeIterator &to ) const { EdgeIterator smallestEdge = SPECIAL_EDGEID; EdgeWeight smallestWeight = UINT_MAX; - for ( EdgeIterator edge = BeginEdges( from ); edge < EndEdges(from); edge++ ) - { + for ( EdgeIterator edge = BeginEdges( from ); edge < EndEdges(from); edge++ ) { const NodeID target = GetTarget(edge); const EdgeWeight weight = GetEdgeData(edge).distance; - { - if(target == to && weight < smallestWeight) - { - smallestEdge = edge; smallestWeight = weight; - } + if(target == to && weight < smallestWeight) { + smallestEdge = edge; smallestWeight = weight; } } return smallestEdge; } + EdgeIterator FindEdgeIndicateIfReverse( const NodeIterator &from, const NodeIterator &to, bool & result ) const { + EdgeIterator tmp = FindEdge( from, to ); + if(UINT_MAX == tmp) { + tmp = FindEdge( to, from ); + if(UINT_MAX != tmp) + result = true; + } + return tmp; + } + private: struct _StrNode {