unobtanium-graph-algorithms 0.1.0

Graph ranking algorithms for the unobtanium search engine
Documentation
// SPDX-FileCopyrightText: 2025 Slatian 2025
//
// SPDX-License-Identifier: LGPL-3.0-only

use iddqd::BiHashItem;
use iddqd::bi_upcast;

use core::hash::Hash;

#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct NodeId(pub usize);

pub struct Node<T: Eq + Hash> {
	pub id: NodeId,
	pub data: T,
}

impl<T: Eq + Hash + Clone> BiHashItem for Node<T> {
	type K1<'a>
		= &'a NodeId
	where
		T: 'a;
	type K2<'a>
		= &'a T
	where
		T: 'a;

	fn key1(&self) -> Self::K1<'_> {
		&self.id
	}

	fn key2(&self) -> Self::K2<'_> {
		&self.data
	}

	bi_upcast!();
}