1use serde::{Serialize, Deserialize};
2use std::cmp::Ordering;
3
4#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
5pub struct Node {
6 pub id: usize,
7 pub x: f32,
8 pub y: f32,
9 pub z: f32,
10}
11
12impl Node {
13 pub fn new(id: usize, x: f32, y: f32, z: f32) -> Self {
14 Node { id, x, y, z }
15 }
16}
17
18impl PartialEq for Node {
19 fn eq(&self, other: &Self) -> bool {
20 self.id == other.id
21 }
22}
23
24impl Eq for Node {}
25
26impl PartialOrd for Node {
27 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
28 Some(self.cmp(other))
29 }
30}
31
32impl Ord for Node {
33 fn cmp(&self, other: &Self) -> Ordering {
34 self.id.cmp(&other.id)
35 }
36}