Struct Graph

Source
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

Source

pub fn from_g6(repr: &str) -> Result<Self, IOError>

Creates a new undirected graph from a graph6 representation

§Arguments
  • repr - A graph6 representation of the graph
§Example
use graph6_rs::Graph;
let graph = Graph::from_g6("A_").unwrap();
assert_eq!(graph.n, 2);
assert_eq!(graph.bit_vec, &[0, 1, 1, 0]);
Source

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 Debug for Graph

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl GraphConversion for Graph

Source§

fn bit_vec(&self) -> &[usize]

Returns the bitvector representation of the graph

Source§

fn size(&self) -> usize

Returns the number of vertices in the graph

Source§

fn is_directed(&self) -> bool

Returns true if the graph is directed

Source§

fn to_dot(&self, id: Option<usize>) -> String

Returns the graph in the DOT format
Source§

fn to_undirected_dot(&self, dot: &mut String, bit_vec: &[usize], n: usize)

Source§

fn to_directed_dot(&self, dot: &mut String, bit_vec: &[usize], n: usize)

Source§

fn to_adjmat(&self) -> String

Returns the graph as an adjacency matrix
Source§

fn to_flat(&self) -> String

Returns the graph in a flat adjacency matrix
Source§

fn to_net(&self) -> String

Returns the graph in the Pajek NET format
Source§

impl WriteGraph for Graph

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.