Hi all,

I have written recurisve pathfinding fuction from matrix*[j] to matrix[x][y].
however, it's not returning the right values. It is supposed to return the minimal cost from 2 points using any possible path.
all ".value" are the cost to use this Node
all ".bestFromStart" are the max of long int field.
all ".status" are "CLOSED"
any help would be appriciated!!*

the function all first called with

father==NULL

```
/* a brief breakdown of this algorithm:
We have defined a high value (currently the limit of "long int") as the "error"
return.
We start searching the matrix. If at any point it we find that the way we are
trying is longer allredy that the best existing way through specific node, we
return LARGE, meaning do not continue searching throuh this node.
We make sure we dont recourse though a node that has allready been included in
the current path by setting it's status to OPEN upon enterting the recusrive
part of the program. If we now will reach any node which is OPEN, we return
LARGE- an ending value.
We then search in all derections for any result that doesnt return large and
return to the main fuction the smallest of all directions.
This way is not entirely fault tolerent because it does not deal with the case
of value=LARGE, but on the other hand it's not meant to deal with value>LARGE
either.
*/
long int GetMin(Node** matrix,int currentR,int currentC,int endR,int endC,
int rows,int columns,Node* father)
{
long int result;
//if out of bounds return max of field
if (currentR==rows || currentC==columns || currentR<0 || currentC<0)
return LARGE;
//if reached end
if (currentC==endC && currentR==endR)
return (matrix[currentR][currentC].value);
//if already checked here
if (matrix[currentR][currentC].status==OPEN)
return LARGE;
/*record distance from beggining*/
//if first node
if (father==NULL)
//assign first value as best value
matrix[currentR][currentC].bestFromStart=
matrix[currentR][currentC].value;
//if not first node
else
{
//if bestFromStart old value higher than current value
if ( (matrix[currentR][currentC].value +
father->bestFromStart ) <
matrix[currentR][currentC].bestFromStart )
//then...
matrix[currentR][currentC].bestFromStart=
matrix[currentR][currentC].value+
father->bestFromStart;
else
/*this is a bad path -
this way is not shorter than previously found way*/
return LARGE;
}
//if not reached end
matrix[currentR][currentC].status=OPEN;
result=Smallest4(
GetMin(matrix,currentR,currentC+1,endR,endC,rows,columns,
&(matrix[currentR][currentC])),
GetMin(matrix,currentR,currentC-1,endR,endC,rows,columns,
&(matrix[currentR][currentC])),
GetMin(matrix,currentR+1,currentC,endR,endC,rows,columns,
&(matrix[currentR][currentC])),
GetMin(matrix,currentR-1,currentC,endR,endC,rows,columns,
&(matrix[currentR][currentC])));
//set current status to closes- can try here again
matrix[currentR][currentC].status=CLOSED;
//if was blocked all directions
if (result==LARGE)
return LARGE;
return matrix[currentR][currentC].value+result;
}
```