pub fn add_edge(&mut self, from: NodeID, to: NodeID) -> Result<(), &'static str> {
        if !self.nodes.contains_key(&from) {
            return Err("Invalid Node ID for 'from' node");
        }
        if !self.nodes.contains_key(&to) {
            return Err("Invalid Node ID for 'to' node");
        }

        let from_pointing_to = self.nodes.get_mut(&from).unwrap().pointing_to();

        if from_pointing_to.contains(&to) {
            return Err("'from' node already contains an edge to 'to' node");
        }

        from_pointing_to.push(to);

        let to_pointed_to = self.nodes.get_mut(&to).unwrap().pointed_to();

        if to_pointed_to.contains(&from) {
            return Err("'to' node already contains an edge from 'from' node");
        }

        to_pointed_to.push(from);

        Ok(())
    }
/// Add an edge between two nodes by ID. Fails if the node IDs are not found.
/// It does allow a node to create an edge with itself.
Add an edge between two nodes by ID. Fails if the node IDs are not found.
It does allow a node to create an edge with itself.
Add an edge between two nodes by ID . Fails if the node IDs are not found . It does allow a node to create an edge with itself .
pub fn add_edge(&mut self, from: NodeID, to: NodeID) -> Result<(), &'static str> {
        if !self.nodes.contains_key(&from) {
            return Err("Invalid Node ID for 'from' node");
        }
        if !self.nodes.contains_key(&to) {
            return Err("Invalid Node ID for 'to' node");
        }
        let from_pointing_to = self.nodes.get_mut(&from).unwrap().pointing_to();
        if from_pointing_to.contains(&to) {
            return Err("'from' node already contains an edge to 'to' node");
        }
        from_pointing_to.push(to);
        let to_pointed_to = self.nodes.get_mut(&to).unwrap().pointed_to();
        if to_pointed_to.contains(&from) {
            return Err("'to' node already contains an edge from 'from' node");
        }
        to_pointed_to.push(from);
        Ok(())
    }
pub fn add_edge ( & mut self , from : NodeID , to : NodeID ) -> Result < ( ) , & ' static str > { if ! self . nodes . contains_key ( & from ) { return Err ( " " ) ; } if ! self . nodes . contains_key ( & to ) { return Err ( " " ) ; } let from_pointing_to = self . nodes . get_mut ( & from ) . unwrap ( ) . pointing_to ( ) ; if from_pointing_to . contains ( & to ) { return Err ( " " ) ; } from_pointing_to . push ( to ) ; let to_pointed_to = self . nodes . get_mut ( & to ) . unwrap ( ) . pointed_to ( ) ; if to_pointed_to . contains ( & from ) { return Err ( " " ) ; } to_pointed_to . push ( from ) ; Ok ( ( ) ) }
Add an edge between two nodes by ID.
Add an edge between two nodes by ID .
&mut self
from
NodeID
to
NodeID
&mut self
from
NodeID
to
NodeID