Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion include/Graph/Graph_TS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,20 @@ namespace CXXGRAPH
* case if target is not reachable from source or there is error in the computation.
*/
const DijkstraResult dijkstra(const Node<T> &source, const Node<T> &target) const override;
/**
* @brief Function runs the bellmanford algorithm for some source node and
* target node in the graph and returns the shortest distance of target
* from the source if there is no negative cycle in the graph.
* Note: Thread Safe
*
* @param source source vertex
* @param target target vertex
*
* @return shortest distance if target is reachable from source else ERROR in
* case if target is not reachable from source or there is negative cycle or
* there is error in the computation.
*/
const BellmanFordResult bellmanford(const Node<T> &source, const Node<T> &target) const override;
/**
* \brief
* Function performs the breadth first search algorithm over the graph
Expand Down Expand Up @@ -304,6 +318,15 @@ namespace CXXGRAPH
releaseLock();
return dij;
}

template <typename T>
const BellmanFordResult Graph_TS<T>::bellmanford(const Node<T> &source, const Node<T> &target) const
{
getLock();
auto bellford = Graph<T>::bellmanFord(source, target);
releaseLock();
return bellford;
}

template <typename T>
const std::vector<Node<T>> Graph_TS<T>::breadth_first_search(const Node<T> &start) const
Expand Down Expand Up @@ -386,4 +409,4 @@ namespace CXXGRAPH
return partitions;
}
}
#endif // __GRAPH_TS_H__
#endif // __GRAPH_TS_H__