graph_algo_ptas/data_structure/graph_dcel.rs
1//! Contains the traits used to represent a doubly connected edge list
2
3/// Trait to mark a dart type
4pub trait Dart {}
5
6/// Trait to mark a face
7pub trait Face {}
8
9/// Trait to mark a vertex
10pub trait Vertex {}
11
12/// Trait to be implemented by every vertex implementation
13pub trait GraphDCEL<
14 V: Vertex,
15 D: Dart,
16 F: Face,
17 VI: Iterator<Item = V>,
18 DI: Iterator<Item = D>,
19 FI: Iterator<Item = F>,
20>
21{
22 /// Returns all vertex in the graph as an iterator
23 fn get_vertexes(&self) -> VI;
24 /// Returns all darts in the graph as an iterator
25 fn get_darts(&self) -> DI;
26 /// Returns all faces in the graph as an iterator
27 fn get_faces(&self) -> FI;
28 /// Returns the number of vertexes in the graph
29 fn vertex_count(&self) -> usize;
30 /// Returns the number of darts in the graph
31 fn dart_count(&self) -> usize;
32 /// Returns the number of edges in the graph
33 fn edge_count(&self) -> usize;
34 /// Returns the number of faces in the graph
35 fn face_count(&self) -> usize;
36 /// Returns the number of vertexes adjacent to the given face
37 fn face_vertex_count(&self, face: &F) -> usize;
38 /// Returns the amount of vertex neighboring the given vertex
39 fn neighbors_count(&self, vertex: &V) -> usize;
40 /// Returns a vector of neighbors of the given vertex
41 fn neighbors(&self, vertex: &V) -> Vec<V>;
42 /// Returns a vertex specified by this id
43 fn vertex_by_id(&self, id: usize) -> Option<V>;
44
45 /// Returns the dart between to vertexes
46 fn get_dart(&self, vertex: &V, target: &V) -> Option<D>;
47 /// Returns the dart linked to the given vertex
48 fn dart_vertex(&self, vertex: &V) -> D;
49 /// Returns the the dart linked to the given face
50 fn dart_face(&self, face: &F) -> D;
51 /// Returns the twin dart of the given dart
52 fn twin(&self, dart: &D) -> D;
53 /// Returns the target vertex of the given dart
54 fn dart_target(&self, dart: &D) -> V;
55 /// Return the face adjacent to the given dart
56 fn face(&self, dart: &D) -> F;
57 /// Returns the next dart in the dart order
58 fn next(&self, current: &D) -> D;
59 /// Returns the previous dart in the dart order
60 fn prev(&self, current: &D) -> D;
61
62 /// Adds a new vertex
63 fn add_vertex(&mut self) -> V;
64 /// Adds a new dart
65 fn add_dart(
66 &mut self,
67 from: V,
68 to: V,
69 prev: Option<D>,
70 next: Option<D>,
71 twin: Option<D>,
72 face: Option<F>,
73 ) -> D;
74 /// Adds a new face
75 fn add_face(&mut self, dart: D) -> F;
76
77 /// Sets the face for the given Dart
78 fn set_face(&self, dart: &D, face: F);
79}