-
Notifications
You must be signed in to change notification settings - Fork 441
Closed
Labels
F-trait-reworkFeature: Trait ReworkFeature: Trait Rework
Description
The problem is that there are currently multiple ids, there are NodeIndex / (NodeId) and NodeIndexable, which is kind of the same, but different, even tho it is sharing a strikingly similar name. (The same applies to NodeCompactIndexable and EdgeIndexable)
NodeIndexable is used to map a NodeId into a primitive number, therefore I propose (based on Graph Fundamentals - link missing):
// used in graphs that operate on slices or a memory region, e.g. Graph
pub unsafe trait SliceIndex {
const MIN: Self;
const MAX: Self;
fn to_index(self) -> usize;
fn from_index(index: usize) -> Self;
}
// ^ could also require Numeric/Integral/Unsigned
// ^ no new() as it can be very confusing.
// ^ default impl on Unsigned/Integral
// this **could** also allow negative indices, I dont think thats a good idea tho.
// This would replace IndexType and type NodeIndex would never implement this, in nightly we could likely ensure this using a negative impl
pub trait GraphSliceIndex<G>: GraphIndex<G> {
const CONTINOUS: bool = false; // would replace the `Compact` variant
type Index; // in theory we could use `funty` here (https://docs.rs/funty/latest/funty/trait.Unsigned.html) or just use usize
fn bounds(graph: &G) -> Range<usize>; // might need to be `RangeTo` instead if we want to ensure `0` is always included.
fn to_index(self, graph: &G) -> usize;
fn from_index(index: usize, graph: &G) -> Self;
}
// ^ GraphPrimitiveIndex as alternative, which would have a type Index: ConvertGraphIndex
// this could allow somewhat easier conversion. Experimentation (on dag_to_toposort) is likely needed . Once something implements GraphPrimitiveIndex we can just default impl GraphSliceIndex
// my gut feeling is that we do not need it.
// we could also add direct access on the graph itself, if we wanted to, don't know if that is needed.
// in that case we can default implReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
F-trait-reworkFeature: Trait ReworkFeature: Trait Rework