adjacency_matrix/static_full/
display.rs

1use super::*;
2#[cfg(feature = "wolfram")]
3use graph_types::{ToWolfram, WolframValue};
4
5impl Display for StaticDirected {
6    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
7        let size = self.max_degree().to_string().len();
8        let max = self.nodes();
9        for i in 0..max {
10            for j in 0..max {
11                let index = i * max + j;
12                let edge = unsafe { self.edges.get_unchecked(index) };
13                write!(f, "{:width$} ", edge, width = size)?;
14            }
15            writeln!(f)?;
16        }
17        Ok(())
18    }
19}
20
21#[cfg(feature = "wolfram")]
22impl ToWolfram for StaticDirected {
23    fn to_wolfram(&self) -> WolframValue {
24        let rows = self
25            .edges
26            .chunks_exact(self.nodes())
27            .map(|row| WolframValue::list(row.iter().map(|edge| WolframValue::Integer64(*edge as i64)).collect()))
28            .collect();
29        WolframValue::function("AdjacencyGraph", vec![WolframValue::list(rows)])
30    }
31}