pub struct Edges<'a> {
pub all: Vec<&'a Edge>,
}Expand description
Defines an array of edges
Fields§
§all: Vec<&'a Edge>Holds a set of edges
Implementations§
Source§impl<'a> Edges<'a>
impl<'a> Edges<'a>
Sourcepub fn any_path(&self) -> (Vec<usize>, Vec<usize>)
pub fn any_path(&self) -> (Vec<usize>, Vec<usize>)
Finds a sequence of edges by following connected points to create a path
§Returns
Returns a tuple (path, points) where:
path– List of indices intoself.allrepresenting edges along the pathpoints– List of all points along the path. The list includes the middle points of high-order edges.
§Path Finding Algorithm
-
Start point selection:
- First tries to find points connected to only one edge (endpoints)
- If no endpoints exist (e.g., in a loop), uses point with lowest ID
- If multiple endpoints exist, uses endpoint with lowest ID
-
Path construction:
- Starts from selected point and follows connected edges
- At each step, takes first available edge not yet used
- Stops when no more edges can be followed or a loop is detected
§Notes
- Does not guarantee finding the longest path (NP-hard problem)
- For simple connected paths (no branches), will find the only possible path
- For branching paths, result depends on edge order in
self.all - For loops, starts at lowest numbered point and follows first available edge
- For disconnected components, follows path until no more connected edges
§Special Cases
- Empty edge list returns
(Vec::new(), Vec::new()) - Single edge returns path with just that edge
- Loop starts from lowest numbered point
- Branching paths follow first available edge at each step
- Disconnected edges follow path until component ends
§Examples
use gemlab::mesh::{Edge, Edges};
use gemlab::shapes::GeoKind;
// Create some sample edges (a simple path 1-2-3)
let e1 = Edge { kind: GeoKind::Lin2, points: vec![1, 2], marker: 0 };
let e2 = Edge { kind: GeoKind::Lin2, points: vec![2, 3], marker: 0 };
let edges = Edges { all: vec![&e1, &e2] };
// Get path through edges
let (path, points) = edges.any_path();
assert_eq!(path, vec![0, 1]); // Edge indices
assert_eq!(points, vec![1, 2, 3]); // Point indicesTrait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Edges<'a>
impl<'a> RefUnwindSafe for Edges<'a>
impl<'a> Send for Edges<'a>
impl<'a> Sync for Edges<'a>
impl<'a> Unpin for Edges<'a>
impl<'a> UnwindSafe for Edges<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more