switch to NodePointer alias

This commit is contained in:
Zynh0722 2024-04-24 08:37:11 -07:00
parent 876aa735dc
commit 3d14f3b3e1

View file

@ -9,20 +9,19 @@ use std::{
cell::RefCell, cell::RefCell,
collections::{hash_map::Entry, HashMap}, collections::{hash_map::Entry, HashMap},
env, env,
f64::INFINITY,
rc::Rc, rc::Rc,
}; };
use parse::Record; use parse::Record;
type Graph = HashMap<usize, Rc<RefCell<Node>>>; type NodePointer = Rc<RefCell<Node>>;
type Graph = HashMap<usize, NodePointer>;
type Airports = HashMap<usize, Rc<airport::Airport>>; type Airports = HashMap<usize, Rc<airport::Airport>>;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
struct Node { struct Node {
origin: Rc<airport::Airport>, origin: Rc<airport::Airport>,
destinations: Vec<Destination>, destinations: Vec<Destination>,
source_distance: f64,
visited: bool, visited: bool,
} }
@ -31,7 +30,6 @@ impl Node {
Node { Node {
destinations, destinations,
origin, origin,
source_distance: INFINITY,
visited: false, visited: false,
} }
} }
@ -39,7 +37,7 @@ impl Node {
#[derive(Clone)] #[derive(Clone)]
struct Destination { struct Destination {
node: Rc<RefCell<Node>>, node: NodePointer,
distance: f64, distance: f64,
} }