Struct Graph

Source
pub struct Graph {
    pub nodes: Vec<Node>,
    pub graph_desc: GraphDesc,
}

Fields§

§nodes: Vec<Node>§graph_desc: GraphDesc

Implementations§

Source§

impl Graph

Source

pub fn new() -> Graph

Examples found in repository?
examples/graph.rs (line 4)
3fn main() {
4    let mut graph = Graph::new();
5    graph.graph_desc = GraphDesc {
6        node_color: RED,
7        outer_ring: (Color::new(1., 0.5, 0.8, 1.), 3.5),
8        ..Default::default()
9    };
10    let a = graph.add_node(vec![]);
11    let b = graph.add_node(vec![]);
12    let c = graph.add_node(vec![]);
13    
14    let d = graph.add_node(vec![a.idx, b.idx]);
15    let e = graph.add_node(vec![a.idx, c.idx]);
16
17    let _f = graph.add_node(vec![d.idx, e.idx, b.idx]);
18
19    graph.show();
20}
More examples
Hide additional examples
examples/graph_modified.rs (line 4)
3fn main() {
4    let mut graph = Graph::new();
5    graph.graph_desc = GraphDesc {
6        title: String::from("Graph"),
7        node_color: RED,
8        egde_color: EdgeColor::Use(MAGENTA),
9        ..Default::default()
10    };
11    let a = graph.add_node(vec![]);
12    let b = graph.add_node(vec![]);
13    let c = graph.add_node(vec![]);
14    
15    let d = graph.add_node(vec![a.idx, b.idx]);
16    let e = graph.add_node(vec![a.idx, c.idx]);
17
18    let _f = graph.add_node(vec![d.idx, e.idx, b.idx]);
19
20    graph.show();
21}
Source

pub fn set_graph_desc(&mut self, graph_desc: GraphDesc)

Source

pub fn add_node(&mut self, deps: Vec<usize>) -> Node

Examples found in repository?
examples/graph.rs (line 10)
3fn main() {
4    let mut graph = Graph::new();
5    graph.graph_desc = GraphDesc {
6        node_color: RED,
7        outer_ring: (Color::new(1., 0.5, 0.8, 1.), 3.5),
8        ..Default::default()
9    };
10    let a = graph.add_node(vec![]);
11    let b = graph.add_node(vec![]);
12    let c = graph.add_node(vec![]);
13    
14    let d = graph.add_node(vec![a.idx, b.idx]);
15    let e = graph.add_node(vec![a.idx, c.idx]);
16
17    let _f = graph.add_node(vec![d.idx, e.idx, b.idx]);
18
19    graph.show();
20}
More examples
Hide additional examples
examples/graph_modified.rs (line 11)
3fn main() {
4    let mut graph = Graph::new();
5    graph.graph_desc = GraphDesc {
6        title: String::from("Graph"),
7        node_color: RED,
8        egde_color: EdgeColor::Use(MAGENTA),
9        ..Default::default()
10    };
11    let a = graph.add_node(vec![]);
12    let b = graph.add_node(vec![]);
13    let c = graph.add_node(vec![]);
14    
15    let d = graph.add_node(vec![a.idx, b.idx]);
16    let e = graph.add_node(vec![a.idx, c.idx]);
17
18    let _f = graph.add_node(vec![d.idx, e.idx, b.idx]);
19
20    graph.show();
21}
Source

pub fn set_node_color(&mut self, node_color: Color)

Source

pub fn layers(&self) -> Vec<Layer<'_>>

Source

pub fn show(self)

Examples found in repository?
examples/graph.rs (line 19)
3fn main() {
4    let mut graph = Graph::new();
5    graph.graph_desc = GraphDesc {
6        node_color: RED,
7        outer_ring: (Color::new(1., 0.5, 0.8, 1.), 3.5),
8        ..Default::default()
9    };
10    let a = graph.add_node(vec![]);
11    let b = graph.add_node(vec![]);
12    let c = graph.add_node(vec![]);
13    
14    let d = graph.add_node(vec![a.idx, b.idx]);
15    let e = graph.add_node(vec![a.idx, c.idx]);
16
17    let _f = graph.add_node(vec![d.idx, e.idx, b.idx]);
18
19    graph.show();
20}
More examples
Hide additional examples
examples/graph_modified.rs (line 20)
3fn main() {
4    let mut graph = Graph::new();
5    graph.graph_desc = GraphDesc {
6        title: String::from("Graph"),
7        node_color: RED,
8        egde_color: EdgeColor::Use(MAGENTA),
9        ..Default::default()
10    };
11    let a = graph.add_node(vec![]);
12    let b = graph.add_node(vec![]);
13    let c = graph.add_node(vec![]);
14    
15    let d = graph.add_node(vec![a.idx, b.idx]);
16    let e = graph.add_node(vec![a.idx, c.idx]);
17
18    let _f = graph.add_node(vec![d.idx, e.idx, b.idx]);
19
20    graph.show();
21}

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

Source§

fn default() -> Graph

Returns the “default value” for a type. Read more
Source§

impl From<Vec<Node>> for Graph

Source§

fn from(nodes: Vec<Node>) -> Self

Converts to this type from the input type.

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.