Dijkstra Path generic, Closeness Centrality, Iterate Edge with directionality #20
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Development Workflow
make format
make test
make lint
dijkstra_path_impl
this function is basically a copy of
dijkstra
, I didn't changedijkstra
since it is used heavily in other part of the codebase, you can decide how to refactor later.what's difference
cutoff
for maximum cost for path when pathfinding, inline withnetworkx
's apieval_cost
for evaluating cost base on given edge typeimpl Fn(&W) -> Option<f64>
type callbackSome(f64)
for edge's costNone
for impassable edge(Vec<Option<f64>>, Vec<Option<NodeId>>)
ordered_float::NotNan
forBinaryHeap
, instead of making user useOrderedFloat
.cleaner interface for edge type
f64
Example
Closeness Centrality
GraphinaGraph
traitWhy
since direction is accounted for in
BaseGraph::edges(&self)
, when iterating through edge when direction matter, a check is needed.previous
now
doesn't need to check directionality when iterating edges.
flow_edges
account for backward edge for undirected graph and just use forward edge for directed graph.Todo
Linter Error
the return type for
dijkstra_path_impl
is too complex for lintermaybe a custom result type