#![no_std]
#[cfg(kani)]
extern crate kani;
pub use oxgraph_topology::{
CanonicalElementIdentity, CanonicalIncidenceIdentity, CanonicalRelationIdentity,
ContainsElement, ContainsIncidence, ContainsRelation, ElementIncidenceCount, ElementIncidences,
ElementIndex, ElementPredecessors, ElementSuccessors, ElementWeight, IncidenceBase,
IncidenceCounts, IncidenceElement, IncidenceIndex, IncidenceRelation, IncidenceRole,
IncidenceWeight, LocalElementIdentity, LocalIncidenceIdentity, LocalRelationIdentity,
RelationIncidenceCount, RelationIncidences, RelationIndex, RelationWeight, TopologyBase,
TopologyCounts, TopologyId,
};
pub type VertexId<H> = <H as TopologyBase>::ElementId;
pub type HyperedgeId<H> = <H as TopologyBase>::RelationId;
pub type ParticipantId<H> = <H as IncidenceBase>::IncidenceId;
pub type ParticipantRole<H> = <H as IncidenceBase>::Role;
pub trait HypergraphBase: TopologyBase {}
impl<T> HypergraphBase for T where T: TopologyBase {}
pub trait ParticipantBase: IncidenceBase {}
impl<T> ParticipantBase for T where T: IncidenceBase {}
pub trait HypergraphCounts: TopologyCounts {
fn vertex_count(&self) -> usize {
self.element_count()
}
fn hyperedge_count(&self) -> usize {
self.relation_count()
}
}
pub trait ParticipantCounts: IncidenceCounts {
fn participant_count(&self) -> usize {
self.incidence_count()
}
}
impl<T> ParticipantCounts for T where T: IncidenceCounts {}
pub trait VertexIndex: ElementIndex {
fn vertex_bound(&self) -> usize {
self.element_bound()
}
fn vertex_index(&self, vertex: Self::ElementId) -> usize {
self.element_index(vertex)
}
}
impl<T> VertexIndex for T where T: ElementIndex {}
pub trait HyperedgeIndex: RelationIndex {
fn hyperedge_bound(&self) -> usize {
self.relation_bound()
}
fn hyperedge_index(&self, hyperedge: Self::RelationId) -> usize {
self.relation_index(hyperedge)
}
}
impl<T> HyperedgeIndex for T where T: RelationIndex {}
pub trait ParticipantIndex: IncidenceIndex {
fn participant_bound(&self) -> usize {
self.incidence_bound()
}
fn participant_index(&self, participant: Self::IncidenceId) -> usize {
self.incidence_index(participant)
}
}
impl<T> ParticipantIndex for T where T: IncidenceIndex {}
pub trait ContainsVertex: ContainsElement {
fn contains_vertex(&self, vertex: Self::ElementId) -> bool {
self.contains_element(vertex)
}
}
impl<T> ContainsVertex for T where T: ContainsElement {}
pub trait ContainsHyperedge: ContainsRelation {
fn contains_hyperedge(&self, hyperedge: Self::RelationId) -> bool {
self.contains_relation(hyperedge)
}
}
impl<T> ContainsHyperedge for T where T: ContainsRelation {}
pub trait ContainsParticipant: ContainsIncidence {
fn contains_participant(&self, participant: Self::IncidenceId) -> bool {
self.contains_incidence(participant)
}
}
impl<T> ContainsParticipant for T where T: ContainsIncidence {}
pub trait HyperedgeIncidences: RelationIncidences {
type ParticipantIds<'view>: Iterator<Item = ParticipantId<Self>>
where
Self: 'view;
fn hyperedge_incidences(&self, hyperedge: HyperedgeId<Self>) -> Self::ParticipantIds<'_>;
}
impl<T> HyperedgeIncidences for T
where
T: RelationIncidences,
{
type ParticipantIds<'view>
= <T as RelationIncidences>::Incidences<'view>
where
T: 'view;
fn hyperedge_incidences(&self, hyperedge: HyperedgeId<Self>) -> Self::ParticipantIds<'_> {
<Self as RelationIncidences>::relation_incidences(self, hyperedge)
}
}
pub trait VertexIncidences: ElementIncidences {
type ParticipantIds<'view>: Iterator<Item = ParticipantId<Self>>
where
Self: 'view;
fn vertex_incidences(&self, vertex: VertexId<Self>) -> Self::ParticipantIds<'_>;
}
impl<T> VertexIncidences for T
where
T: ElementIncidences,
{
type ParticipantIds<'view>
= <T as ElementIncidences>::Incidences<'view>
where
T: 'view;
fn vertex_incidences(&self, vertex: VertexId<Self>) -> Self::ParticipantIds<'_> {
<Self as ElementIncidences>::element_incidences(self, vertex)
}
}
pub trait ParticipantVertex: IncidenceElement {
fn participant_vertex(&self, participant: ParticipantId<Self>) -> VertexId<Self> {
self.incidence_element(participant)
}
}
impl<T> ParticipantVertex for T where T: IncidenceElement {}
pub trait ParticipantHyperedge: IncidenceRelation {
fn participant_hyperedge(&self, participant: ParticipantId<Self>) -> HyperedgeId<Self> {
self.incidence_relation(participant)
}
}
impl<T> ParticipantHyperedge for T where T: IncidenceRelation {}
pub trait ParticipantRoleOf: IncidenceRole {
fn participant_role_of(&self, participant: ParticipantId<Self>) -> ParticipantRole<Self> {
self.incidence_role(participant)
}
}
impl<T> ParticipantRoleOf for T where T: IncidenceRole {}
pub trait HyperedgeParticipants: HyperedgeIncidences + ParticipantVertex {
type Participants<'view>: Iterator<Item = Self::ElementId>
where
Self: 'view;
fn hyperedge_participants(&self, hyperedge: Self::RelationId) -> Self::Participants<'_>;
}
pub trait IncidentHyperedges: VertexIncidences + ParticipantHyperedge {
type IncidentHyperedges<'view>: Iterator<Item = Self::RelationId>
where
Self: 'view;
fn incident_hyperedges(&self, vertex: Self::ElementId) -> Self::IncidentHyperedges<'_>;
}
pub trait HyperedgeParticipantCount: IncidenceBase {
fn hyperedge_participant_count(&self, hyperedge: Self::RelationId) -> usize;
}
pub trait IncidentHyperedgeCount: IncidenceBase {
fn incident_hyperedge_count(&self, vertex: Self::ElementId) -> usize;
}
pub trait DirectedHyperedgeParticipants: TopologyBase {
type SourceParticipants<'view>: Iterator<Item = Self::ElementId>
where
Self: 'view;
type TargetParticipants<'view>: Iterator<Item = Self::ElementId>
where
Self: 'view;
fn source_participants(&self, hyperedge: Self::RelationId) -> Self::SourceParticipants<'_>;
fn target_participants(&self, hyperedge: Self::RelationId) -> Self::TargetParticipants<'_>;
}
pub trait DirectedHyperedgeIncidences: IncidenceBase {
type SourceIncidences<'view>: Iterator<Item = Self::IncidenceId>
where
Self: 'view;
type TargetIncidences<'view>: Iterator<Item = Self::IncidenceId>
where
Self: 'view;
fn source_incidences(&self, hyperedge: Self::RelationId) -> Self::SourceIncidences<'_>;
fn target_incidences(&self, hyperedge: Self::RelationId) -> Self::TargetIncidences<'_>;
}
pub trait DirectedVertexHyperedges: TopologyBase {
type OutgoingHyperedges<'view>: Iterator<Item = Self::RelationId>
where
Self: 'view;
type IncomingHyperedges<'view>: Iterator<Item = Self::RelationId>
where
Self: 'view;
fn outgoing_hyperedges(&self, vertex: Self::ElementId) -> Self::OutgoingHyperedges<'_>;
fn incoming_hyperedges(&self, vertex: Self::ElementId) -> Self::IncomingHyperedges<'_>;
}
pub trait DirectedVertexSuccessors: ElementSuccessors {
type VertexSuccessors<'view>: Iterator<Item = VertexId<Self>>
where
Self: 'view;
fn successor_vertices(&self, vertex: VertexId<Self>) -> Self::VertexSuccessors<'_>;
}
impl<T> DirectedVertexSuccessors for T
where
T: ElementSuccessors,
{
type VertexSuccessors<'view>
= <T as ElementSuccessors>::Successors<'view>
where
T: 'view;
fn successor_vertices(&self, vertex: VertexId<Self>) -> Self::VertexSuccessors<'_> {
<Self as ElementSuccessors>::element_successors(self, vertex)
}
}
pub trait DirectedVertexPredecessors: ElementPredecessors {
type VertexPredecessors<'view>: Iterator<Item = VertexId<Self>>
where
Self: 'view;
fn predecessor_vertices(&self, vertex: VertexId<Self>) -> Self::VertexPredecessors<'_>;
}
impl<T> DirectedVertexPredecessors for T
where
T: ElementPredecessors,
{
type VertexPredecessors<'view>
= <T as ElementPredecessors>::Predecessors<'view>
where
T: 'view;
fn predecessor_vertices(&self, vertex: VertexId<Self>) -> Self::VertexPredecessors<'_> {
<Self as ElementPredecessors>::element_predecessors(self, vertex)
}
}
pub trait Hypergraph: HyperedgeParticipants + IncidentHyperedges {}
impl<T> Hypergraph for T where T: HyperedgeParticipants + IncidentHyperedges {}
pub trait DirectedHypergraph:
Hypergraph
+ DirectedHyperedgeParticipants
+ DirectedHyperedgeIncidences
+ DirectedVertexHyperedges
+ DirectedVertexSuccessors
+ DirectedVertexPredecessors
{
}
impl<T> DirectedHypergraph for T where
T: Hypergraph
+ DirectedHyperedgeParticipants
+ DirectedHyperedgeIncidences
+ DirectedVertexHyperedges
+ DirectedVertexSuccessors
+ DirectedVertexPredecessors
{
}