small refactor
This commit is contained in:
@ -1,32 +1,24 @@
|
||||
#ifndef __DISTANCE_HPP_
|
||||
#define __DISTANCE_HPP_
|
||||
|
||||
#include "config.hpp"
|
||||
#ifndef DISTANCE_HPP_
|
||||
#define DISTANCE_HPP_
|
||||
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
|
||||
struct DistanceResult {
|
||||
// distances[n] = distance from n to target
|
||||
std::vector<int> distances;
|
||||
class graph_distances
|
||||
{
|
||||
public:
|
||||
std::vector<int> distances; // distances[n] = distance from node n to target
|
||||
std::vector<size_t> parents; // parents[n] = next node on the path from node n to target
|
||||
std::vector<size_t> nearest_targets; // nearest_target[n] = closest target node to node n
|
||||
|
||||
// parents[n] = next node on the path from n to target
|
||||
std::vector<std::size_t> parents;
|
||||
public:
|
||||
auto clear() -> void;
|
||||
[[nodiscard]] auto empty() const -> bool;
|
||||
|
||||
// nearest_target[n] = closest target node to n
|
||||
std::vector<std::size_t> nearest_targets;
|
||||
auto calculate_distances(size_t node_count, const std::vector<std::pair<size_t, size_t>>& edges,
|
||||
const std::vector<size_t>& targets) -> void;
|
||||
|
||||
auto Clear() -> void;
|
||||
|
||||
auto Empty() -> bool;
|
||||
[[nodiscard]] auto get_shortest_path(size_t source) const -> std::vector<size_t>;
|
||||
};
|
||||
|
||||
auto CalculateDistances(
|
||||
std::size_t node_count,
|
||||
const std::vector<std::pair<std::size_t, std::size_t>> &edges,
|
||||
const std::vector<std::size_t> &targets) -> DistanceResult;
|
||||
|
||||
auto GetPath(const DistanceResult &result, std::size_t source)
|
||||
-> std::vector<std::size_t>;
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user