Skip to content

Commit

Permalink
Missing links fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
samdoctolero committed Mar 4, 2017
1 parent ae7bfbe commit 5a5292a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion inst/include/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Engine
//finds all the cells that create the link
Cell parseMap(LinkCell lc, Link & path);
//it looks for indirect path that's "cheaper" than the direct path and gives the new path the indirect path if found
void lookForIndirectPath(std::vector<Link> & path_list, Link & path);
bool lookForIndirectPath(std::vector<Link> & path_list, Link & path);

public:
//constructor that takes in a pointer to the input data, pointer to the output data,
Expand Down
14 changes: 9 additions & 5 deletions src/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,12 +723,15 @@ void Engine::findPath(LinkCell &ac1, LinkCell &ac2, std::vector<Link> & path_lis
lc_temp = iLinkMap[ac2.row][ac2.column]; //get the LinkCell from iLinkMap using ac2's location (row and column)
path.end = parseMap(lc_temp, path); //from ac2's location (or lc_temp's location) follow its connections until it reaches a path

//check if a cheaper indirect path is available
/*//check if a cheaper indirect path is available
lookForIndirectPath(path_list, path); //if a cheaper inderect path exists the
//function updates the Link called 'path'
//insert the new Link (path) in the path_list property of the Engine object
path_list.push_back(path);
path_list.push_back(path);*/

if(lookForIndirectPath(path_list, path))
path_list.push_back(path);
}

//' Parse a map
Expand Down Expand Up @@ -773,12 +776,12 @@ Cell Engine::parseMap(LinkCell lc, Link & path)
//' @author Sam Doctolero
//' @family C++ linking functions
//' @keywords internal
void Engine::lookForIndirectPath(std::vector<Link> & path_list, Link & path)
bool Engine::lookForIndirectPath(std::vector<Link> & path_list, Link & path)
{
//if path_list is empty then no indirect paths are available to search
if (path_list.size() <= 0)
{
return;
return true;
}

//otherwise parse through all the paths currently in the memory and check for
Expand Down Expand Up @@ -818,10 +821,11 @@ void Engine::lookForIndirectPath(std::vector<Link> & path_list, Link & path)
path.connection.push_back(connection[k].connection[m]);
}
}
return;
return false;
}
}
}
}
}
return true;
}

1 comment on commit 5a5292a

@achubaty
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

part of #32

Please sign in to comment.