mod private
{
use crate::prelude::*;
use indexmap::IndexSet;
use core::fmt;
pub struct Node< NodeId = crate::IdentityWithInt, EdgeId = crate::IdentityWithInt >
where
NodeId : IdentityInterface,
EdgeId : IdentityInterface,
{
pub out_nodes : IndexSet< NodeId >,
pub out_edges : IndexSet< EdgeId >,
pub id : NodeId,
}
impl< NodeId, EdgeId > Node< NodeId, EdgeId >
where
NodeId : IdentityInterface,
EdgeId : IdentityInterface,
{
pub fn _make_with_id< IntoId >( id : IntoId ) -> Self
where
IntoId : Into< < Self as HasId >::Id >,
{
let out_nodes = Default::default();
let out_edges = Default::default();
Node { out_nodes, out_edges, id : id.into() }
}
}
impl< NodeId, EdgeId > HasId
for Node< NodeId, EdgeId >
where
NodeId : IdentityInterface,
EdgeId : IdentityInterface,
{
type Id = NodeId;
fn id( &self ) -> Self::Id
{
self.id
}
}
impl< NodeId, EdgeId > NodeBasicInterface
for Node< NodeId, EdgeId >
where
NodeId : IdentityInterface,
EdgeId : IdentityInterface,
{
}
impl< NodeId, EdgeId > fmt::Debug
for Node< NodeId, EdgeId >
where
NodeId : IdentityInterface,
EdgeId : IdentityInterface,
{
fn fmt( &self, f : &mut fmt::Formatter<'_> ) -> fmt::Result
{
f.write_fmt( format_args!( "node::{:?}", self.id() ) )?;
for e in &self.out_nodes
{
f.write_fmt( format_args!( "\n - {:?}", e ) )?;
}
f.write_fmt( format_args!( "" ) )
}
}
impl< NodeId, EdgeId > PartialEq
for Node< NodeId, EdgeId >
where
NodeId : IdentityInterface,
EdgeId : IdentityInterface,
{
fn eq( &self, other : &Self ) -> bool
{
self.id() == other.id()
}
}
impl< NodeId, EdgeId > Eq
for Node< NodeId, EdgeId >
where
NodeId : IdentityInterface,
EdgeId : IdentityInterface,
{}
}
crate::mod_interface!
{
orphan use Node;
}