pub struct Graph {
pub bit_vec: Vec<usize>,
pub n: usize,
}
Expand description
Creates an undirected graph from a graph6 representation
Fields§
§bit_vec: Vec<usize>
§n: usize
Implementations§
Source§impl Graph
impl Graph
Sourcepub fn from_adj(adj: &[usize]) -> Result<Self, IOError>
pub fn from_adj(adj: &[usize]) -> Result<Self, IOError>
Creates a new undirected graph from a flattened adjacency matrix. The adjacency matrix must be square. The adjacency matrix will be forced into a symmetric matrix.
§Arguments
adj
- A flattened adjacency matrix
§Errors
Returns an error if the adjacency matrix is invalid (i.e. not square)
§Example
use graph6_rs::Graph;
let graph = Graph::from_adj(&[0, 0, 1, 0]).unwrap();
assert_eq!(graph.n, 2);
assert_eq!(graph.bit_vec, &[0, 1, 1, 0]);
Trait Implementations§
Source§impl GraphConversion for Graph
impl GraphConversion for Graph
Source§impl WriteGraph for Graph
impl WriteGraph for Graph
fn write_graph(&self) -> String
Auto Trait Implementations§
impl Freeze for Graph
impl RefUnwindSafe for Graph
impl Send for Graph
impl Sync for Graph
impl Unpin for Graph
impl UnwindSafe for Graph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more