use crate::agent::AgentId;
#[derive(Debug, Clone)]
pub enum Topology {
Parallel {
critics: Vec<AgentId>,
},
Rounds {
critics: Vec<AgentId>,
max_rounds: usize,
},
}
impl Topology {
pub fn parallel(critics: Vec<AgentId>) -> Self {
Self::Parallel { critics }
}
pub fn rounds(critics: Vec<AgentId>, max_rounds: usize) -> Self {
Self::Rounds {
critics,
max_rounds,
}
}
}
impl From<Topology> for InteractionGraph {
fn from(topology: Topology) -> Self {
match topology {
Topology::Parallel { critics } => InteractionGraph::Parallel { critics },
Topology::Rounds {
critics,
max_rounds,
} => InteractionGraph::Rounds {
critics,
max_rounds,
},
}
}
}
#[derive(Debug, Clone)]
pub enum InteractionGraph {
Parallel {
critics: Vec<AgentId>,
},
Rounds {
critics: Vec<AgentId>,
max_rounds: usize,
},
}
impl InteractionGraph {
pub fn critics(&self) -> &[AgentId] {
match self {
InteractionGraph::Parallel { critics } | InteractionGraph::Rounds { critics, .. } => {
critics
}
}
}
pub fn max_rounds(&self) -> Option<usize> {
match self {
InteractionGraph::Parallel { .. } => None,
InteractionGraph::Rounds { max_rounds, .. } => Some(*max_rounds),
}
}
}