-
Avoid .unwrap().
Where .unwrap() appears as a result of comparing distances, it may be necessary to impose additional restrictions on the types used.
-
Add MetricCalculator type with methods
weighted(bool)
center()
diameter()
radius()
periphery()
eccentricity()
At now, each of the metric functions calculates a distance matrix at the beginning of its work. The MetricsCalculator will lazily calculate the distance matrix once, and then use it when calling metric methods.
For a weighted graph, the distance matrix will be calculated using the Floyd-Warshall algorithm, for an unweighted graph, BFS will be used.
- Additionally, the
MetricCalculator will have the
with_distance_mapping(mut self, distances: FnMut(G::NodeId, G::NodeId) -> FloatMeasure) -> Self
method, which allows you to specify the working distance map/matrix in advance.
This can be useful if you already have a distance matrix and don't want to calculate it again.
- Add function
fn floyd_wharshall_distances(...) -> FnMut((G::NodeId, G::NodeID)) -> K,
for simple getting distance mapping.
- The currently available functions for finding metrics should remain unchanged, but they will call the
MetricCalculator inside themselves.
P.s. I will be very glad to suggestions on how to further improve the API or optimize calculations.
Avoid
.unwrap().Where
.unwrap()appears as a result of comparing distances, it may be necessary to impose additional restrictions on the types used.Add
MetricCalculatortype with methodsweighted(bool)center()diameter()radius()periphery()eccentricity()At now, each of the metric functions calculates a distance matrix at the beginning of its work. The
MetricsCalculatorwill lazily calculate the distance matrix once, and then use it when calling metric methods.For a weighted graph, the distance matrix will be calculated using the Floyd-Warshall algorithm, for an unweighted graph, BFS will be used.
MetricCalculatorwill have themethod, which allows you to specify the working distance map/matrix in advance.
This can be useful if you already have a distance matrix and don't want to calculate it again.
for simple getting distance mapping.
MetricCalculatorinside themselves.P.s. I will be very glad to suggestions on how to further improve the API or optimize calculations.