mirror of https://codeberg.org/topola/topola.git
52 lines
989 B
Rust
52 lines
989 B
Rust
use enum_dispatch::enum_dispatch;
|
|
use petgraph::stable_graph::StableDiGraph;
|
|
|
|
use crate::{graph::GenericIndex, layout::dot::FixedDotIndex};
|
|
|
|
#[enum_dispatch]
|
|
pub trait GetNet {
|
|
fn net(&self) -> i64;
|
|
}
|
|
|
|
pub type ConnectivityGraph = StableDiGraph<ConnectivityWeight, ConnectivityLabel, usize>;
|
|
|
|
#[enum_dispatch(GetNet)]
|
|
#[derive(Debug, Clone, Copy)]
|
|
pub enum ConnectivityWeight {
|
|
Component(ComponentWeight),
|
|
Band(BandWeight),
|
|
}
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
pub struct ComponentWeight {
|
|
pub net: i64,
|
|
}
|
|
|
|
impl GetNet for ComponentWeight {
|
|
fn net(&self) -> i64 {
|
|
self.net
|
|
}
|
|
}
|
|
|
|
pub type ComponentIndex = GenericIndex<ComponentWeight>;
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
pub struct BandWeight {
|
|
pub net: i64,
|
|
pub width: f64,
|
|
pub from: FixedDotIndex,
|
|
}
|
|
|
|
impl GetNet for BandWeight {
|
|
fn net(&self) -> i64 {
|
|
self.net
|
|
}
|
|
}
|
|
|
|
pub type BandIndex = GenericIndex<BandWeight>;
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
pub enum ConnectivityLabel {
|
|
Band,
|
|
}
|