示例#1
0
/*	@brief return a path from s to vertex v
 *	@param v	vertex
 */
deque<int> BFSDirectedPaths::pathTo(int v){
	deque<int> dc;
	if( !isValidVertex(v) ){
		return dc;
	}
	while( distTo[v] != 0 ){
		dc.push_front(v);
		v = edgeTo[v];
	}
	dc.push_front(v);
	return dc;
}
VertexType getVertexType(VertexLocation location) {
    assert(isValidVertex(location));
    // From examining the coordinate system, if there is only a single highest value of x,
    // it's a left vertex. Otherwise, it's a right vertex.

    int highestX = location.region0.x;
    if (location.region1.x > highestX) {
        highestX = location.region1.x;
    }
    if (location.region2.x > highestX) {
        highestX = location.region2.x;
    }

    VertexType result = VERTEX_RIGHT;
    if ((highestX == location.region0.x && highestX != location.region1.x && highestX != location.region2.x) ||
        (highestX != location.region0.x && highestX == location.region1.x && highestX != location.region2.x) ||
        (highestX != location.region0.x && highestX != location.region1.x && highestX == location.region2.x)) {
        result = VERTEX_LEFT;
    }
    return result;
}
示例#3
0
/*	@brief is reachable
 *		true if there exists a path from source(s) to v
 *		false otherwise
 *	@param v	vertex 
 *				if v is not a valid vertex return false
 */
bool BFSDirectedPaths::reachable(int v) const {
	if( !isValidVertex(v) ){
		return false;
	}
	return distTo[v] < INT_MAX;
}