pub fn from_old_json(json: impl AsRef<str>) -> Graph {
        use std::convert::TryInto;

        #[derive(serde::Deserialize, serde::Serialize)]
        struct SqliteGraph {
            atoms: Vec<(u16, usize)>,
            bonds: Vec<(u16, u16, u8)>,
        };

        let graph: SqliteGraph = serde_json::from_str(json.as_ref()).unwrap();
        let n = graph.atoms.len().try_into().unwrap();
        let mut atoms = vec![0usize; n];
        let mut bonds: Matrix<u8> = Matrix::new(n);

        for (i, a) in graph.atoms {
            let j = i as usize - 1;
            atoms[j] = crate::Atoms::encode(a as u8, 0);
        }

        for (i, j, k) in graph.bonds {
            let i = i as usize - 1;
            let j = j as usize - 1;
            let k = k as u8;
            *bonds.get_mut(i, j) = k;
            *bonds.get_mut(j, i) = k;
        }

        let edge_possible: Matrix<bool> = Matrix::new(n);

        Graph {
            n,
            atoms,
            bonds,
            edge_possible,
        }
    }
/// Parses the given JSON and transforms it into a graph object.
/// The JSON format is documented in JSON_FORMAT.MD
Parses the given JSON and transforms it into a graph object.
The JSON format is documented in JSON_FORMAT.MD
Parses the given JSON and transforms it into a graph object . The JSON format is documented in JSON_FORMAT . MD
pub fn from_old_json(json: impl AsRef<str>) -> Graph {
        use std::convert::TryInto;
        #[derive(serde::Deserialize, serde::Serialize)]
        struct SqliteGraph {
            atoms: Vec<(u16, usize)>,
            bonds: Vec<(u16, u16, u8)>,
        };
        let graph: SqliteGraph = serde_json::from_str(json.as_ref()).unwrap();
        let n = graph.atoms.len().try_into().unwrap();
        let mut atoms = vec![0usize; n];
        let mut bonds: Matrix<u8> = Matrix::new(n);
        for (i, a) in graph.atoms {
            let j = i as usize - 1;
            atoms[j] = crate::Atoms::encode(a as u8, 0);
        }
        for (i, j, k) in graph.bonds {
            let i = i as usize - 1;
            let j = j as usize - 1;
            let k = k as u8;
            *bonds.get_mut(i, j) = k;
            *bonds.get_mut(j, i) = k;
        }
        let edge_possible: Matrix<bool> = Matrix::new(n);
        Graph {
            n,
            atoms,
            bonds,
            edge_possible,
        }
    }
pub fn from_old_json ( json : impl AsRef < str > ) -> Graph { use std :: convert :: TryInto ; # [ derive ( serde Deserialize serde Serialize ) ] struct SqliteGraph { atoms : Vec < ( u16 , usize ) > , bonds : Vec < ( u16 , u16 , u8 ) > , } ; let graph : SqliteGraph = serde_json :: from_str ( json . as_ref ( ) ) . unwrap ( ) ; let n = graph . atoms . len ( ) . try_into ( ) . unwrap ( ) ; let mut atoms = vec ! [ 0usize n ] ; let mut bonds : Matrix < u8 > = Matrix :: new ( n ) ; for ( i , a ) in graph . atoms { let j = i as usize - 1 ; atoms [ j ] = crate :: Atoms :: encode ( a as u8 , 0 ) ; } for ( i , j , k ) in graph . bonds { let i = i as usize - 1 ; let j = j as usize - 1 ; let k = k as u8 ; * bonds . get_mut ( i , j ) = k ; * bonds . get_mut ( j , i ) = k ; } let edge_possible : Matrix < bool > = Matrix :: new ( n ) ; Graph { n , atoms , bonds , edge_possible , } }
Parses the given JSON and transforms it into a graph object.
Parses the given JSON and transforms it into a graph object .
json
impl AsRef<str>