Struct DiGraph

Source
pub struct DiGraph {
    pub bit_vec: Vec<usize>,
    pub n: usize,
}
Expand description

Creates a directed graph from a graph6 representation

Fields§

§bit_vec: Vec<usize>§n: usize

Implementations§

Source§

impl DiGraph

Source

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

Creates a new DiGraph from a graph6 representation string

§Arguments
  • repr - A graph6 representation string
§Errors

Returns an error if the graph6 representation is invalid (i.e. missing digraph header ‘&’)

§Examples
use graph6_rs::DiGraph;
let graph = DiGraph::from_d6("&AG").unwrap();
assert_eq!(graph.n, 2);
assert_eq!(graph.bit_vec, &[0, 0, 1, 0]);
Source

pub fn from_adj(adj: &[usize]) -> Result<Self, IOError>

Creates a new DiGraph from a flattened adjacency matrix

§Arguments
  • adj - A flattened adjacency matrix
§Errors

Returns an error if the adjacency matrix is invalid (i.e. not square)

§Examples
use graph6_rs::DiGraph;
let graph = DiGraph::from_adj(&[0, 0, 1, 0]).unwrap();
assert_eq!(graph.n, 2);
assert_eq!(graph.bit_vec, &[0, 0, 1, 0]);

Trait Implementations§

Source§

impl Debug for DiGraph

Source§

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

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

impl GraphConversion for DiGraph

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 DiGraph

Auto Trait Implementations§

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.