Skip to main content

Graph

Struct Graph 

Source
pub struct Graph {
    pub ports: HashMap<PortId, Port>,
    pub edges: HashMap<EdgeId, Edge>,
    pub selected_edge: HashSet<EdgeId>,
    pub selected_node: HashSet<NodeId>,
    /* private fields */
}

Fields§

§ports: HashMap<PortId, Port>§edges: HashMap<EdgeId, Edge>§selected_edge: HashSet<EdgeId>§selected_node: HashSet<NodeId>

Implementations§

Source§

impl Graph

Source

pub fn new() -> Self

Examples found in repository?
examples/extension.rs (line 9)
7fn main() {
8    Application::new().run(|cx| {
9        let mut graph = Graph::new();
10
11        graph
12            .create_node("number")
13            .position(100.0, 100.0)
14            .size(300.0, 150.0)
15            .output()
16            .build(&mut graph);
17
18        graph
19            .create_node("")
20            .position(300.0, 400.0)
21            .input()
22            .build(&mut graph);
23
24        cx.open_window(WindowOptions::default(), |_, cx| {
25            cx.new(|fc| {
26                let mut flow = FlowCanvas::new(graph, fc)
27                    .plugin(SelectionPlugin::new())
28                    .plugin(NodeInteractionPlugin::new())
29                    .plugin(ViewportPlugin::new())
30                    .plugin(Background::new())
31                    .plugin(NodePlugin::new().register_node("number", NumberNode {}));
32                flow.init_plugins();
33                flow
34            })
35        })
36        .unwrap();
37    });
38}
More examples
Hide additional examples
examples/bench.rs (line 6)
4fn main() {
5    Application::new().run(|cx| {
6        let mut graph = Graph::new();
7
8        for j in 0..100 {
9            for i in 0..100 {
10                graph
11                    .create_node("")
12                    .position(200.0 * i as f32, 200.0 * j as f32)
13                    .input()
14                    .output()
15                    .build(&mut graph);
16            }
17        }
18
19        cx.open_window(WindowOptions::default(), |_, cx| {
20            cx.new(|fc| {
21                let mut flow = FlowCanvas::new(graph, fc)
22                    .plugin(SelectionPlugin::new())
23                    .plugin(NodeInteractionPlugin::new())
24                    .plugin(ViewportPlugin::new())
25                    .plugin(Background::new())
26                    .plugin(NodePlugin::new())
27                    .plugin(PortInteractionPlugin::new())
28                    .plugin(EdgePlugin::new())
29                    .plugin(DeletePlugin::new())
30                    .plugin(HistoryPlugin::new());
31                flow.init_plugins();
32                flow
33            })
34        })
35        .unwrap();
36    });
37}
examples/basic.rs (line 6)
4fn main() {
5    Application::new().run(|cx| {
6        let mut graph = Graph::new();
7
8        graph
9            .create_node("")
10            .position(100.0, 100.0)
11            .output()
12            .build(&mut graph);
13
14        graph
15            .create_node("")
16            .position(300.0, 400.0)
17            .input()
18            .output()
19            .build(&mut graph);
20
21        graph
22            .create_node("")
23            .position(500.0, 500.0)
24            .input()
25            .output()
26            .build(&mut graph);
27
28        cx.open_window(WindowOptions::default(), |_, cx| {
29            cx.new(|fc| {
30                let mut flow = FlowCanvas::new(graph, fc)
31                    .plugin(SelectionPlugin::new())
32                    .plugin(NodeInteractionPlugin::new())
33                    .plugin(ViewportPlugin::new())
34                    .plugin(Background::new())
35                    .plugin(NodePlugin::new())
36                    .plugin(PortInteractionPlugin::new())
37                    .plugin(EdgePlugin::new())
38                    .plugin(DeletePlugin::new())
39                    .plugin(HistoryPlugin::new());
40                flow.init_plugins();
41                flow
42            })
43        })
44        .unwrap();
45    });
46}
Source

pub fn create_node(&self, node_type: &str) -> NodeBuilder

Examples found in repository?
examples/extension.rs (line 12)
7fn main() {
8    Application::new().run(|cx| {
9        let mut graph = Graph::new();
10
11        graph
12            .create_node("number")
13            .position(100.0, 100.0)
14            .size(300.0, 150.0)
15            .output()
16            .build(&mut graph);
17
18        graph
19            .create_node("")
20            .position(300.0, 400.0)
21            .input()
22            .build(&mut graph);
23
24        cx.open_window(WindowOptions::default(), |_, cx| {
25            cx.new(|fc| {
26                let mut flow = FlowCanvas::new(graph, fc)
27                    .plugin(SelectionPlugin::new())
28                    .plugin(NodeInteractionPlugin::new())
29                    .plugin(ViewportPlugin::new())
30                    .plugin(Background::new())
31                    .plugin(NodePlugin::new().register_node("number", NumberNode {}));
32                flow.init_plugins();
33                flow
34            })
35        })
36        .unwrap();
37    });
38}
More examples
Hide additional examples
examples/bench.rs (line 11)
4fn main() {
5    Application::new().run(|cx| {
6        let mut graph = Graph::new();
7
8        for j in 0..100 {
9            for i in 0..100 {
10                graph
11                    .create_node("")
12                    .position(200.0 * i as f32, 200.0 * j as f32)
13                    .input()
14                    .output()
15                    .build(&mut graph);
16            }
17        }
18
19        cx.open_window(WindowOptions::default(), |_, cx| {
20            cx.new(|fc| {
21                let mut flow = FlowCanvas::new(graph, fc)
22                    .plugin(SelectionPlugin::new())
23                    .plugin(NodeInteractionPlugin::new())
24                    .plugin(ViewportPlugin::new())
25                    .plugin(Background::new())
26                    .plugin(NodePlugin::new())
27                    .plugin(PortInteractionPlugin::new())
28                    .plugin(EdgePlugin::new())
29                    .plugin(DeletePlugin::new())
30                    .plugin(HistoryPlugin::new());
31                flow.init_plugins();
32                flow
33            })
34        })
35        .unwrap();
36    });
37}
examples/basic.rs (line 9)
4fn main() {
5    Application::new().run(|cx| {
6        let mut graph = Graph::new();
7
8        graph
9            .create_node("")
10            .position(100.0, 100.0)
11            .output()
12            .build(&mut graph);
13
14        graph
15            .create_node("")
16            .position(300.0, 400.0)
17            .input()
18            .output()
19            .build(&mut graph);
20
21        graph
22            .create_node("")
23            .position(500.0, 500.0)
24            .input()
25            .output()
26            .build(&mut graph);
27
28        cx.open_window(WindowOptions::default(), |_, cx| {
29            cx.new(|fc| {
30                let mut flow = FlowCanvas::new(graph, fc)
31                    .plugin(SelectionPlugin::new())
32                    .plugin(NodeInteractionPlugin::new())
33                    .plugin(ViewportPlugin::new())
34                    .plugin(Background::new())
35                    .plugin(NodePlugin::new())
36                    .plugin(PortInteractionPlugin::new())
37                    .plugin(EdgePlugin::new())
38                    .plugin(DeletePlugin::new())
39                    .plugin(HistoryPlugin::new());
40                flow.init_plugins();
41                flow
42            })
43        })
44        .unwrap();
45    });
46}
Source

pub fn next_node_id(&self) -> NodeId

Source

pub fn next_port_id(&self) -> PortId

Source

pub fn next_edge_id(&self) -> EdgeId

Source

pub fn add_node(&mut self, node: Node)

Source

pub fn add_point(&mut self, port: Port)

Source

pub fn nodes(&self) -> &HashMap<NodeId, Node>

Source

pub fn node_order(&self) -> &Vec<NodeId>

Source

pub fn node_order_mut(&mut self) -> &mut Vec<NodeId>

Source

pub fn new_edge(&self) -> Edge

Source

pub fn add_edge(&mut self, edge: Edge)

Source

pub fn remove_edge(&mut self, edge_id: EdgeId)

Source

pub fn get_node(&self, id: &NodeId) -> Option<&Node>

Source

pub fn get_node_mut(&mut self, id: &NodeId) -> Option<&mut Node>

Source

pub fn remove_node(&mut self, id: &NodeId)

Source

pub fn add_selected_node(&mut self, id: NodeId, shift: bool)

Source

pub fn clear_selected_node(&mut self)

Source

pub fn remove_selected_node(&mut self) -> bool

Source

pub fn add_selected_edge(&mut self, id: EdgeId, shift: bool)

Source

pub fn clear_selected_edge(&mut self)

Source

pub fn remove_selected_edge(&mut self) -> bool

Source

pub fn selection_bounds(&self) -> Option<Bounds<Pixels>>

Source

pub fn selected_nodes_with_positions(&self) -> HashMap<NodeId, Point<Pixels>>

Source

pub fn hit_node(&self, mouse: Point<Pixels>) -> Option<NodeId>

Source

pub fn bring_node_to_front(&mut self, node_id: NodeId)

Trait Implementations§

Source§

impl Clone for Graph

Source§

fn clone(&self) -> Graph

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Graph

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Graph

§

impl RefUnwindSafe for Graph

§

impl Send for Graph

§

impl Sync for Graph

§

impl Unpin for Graph

§

impl UnsafeUnpin 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more