[][src]Struct pathfinder::Node

pub struct Node {
    pub hash: u64,
    pub geo: Coordinate,
    pub color: Rgba<u8>,
    pub radius: Option<u32>,
    // some fields omitted
}

A Location object that can be drawn on an image, along with set size and color.

Fields

hash: u64geo: Coordinatecolor: Rgba<u8>radius: Option<u32>

Methods

impl Node
[src]

pub fn new(name: &str, geo: Coordinate) -> Self
[src]

Constructs a Node struct.

pub fn from_file(path: &str) -> Result<Vec<Self>, Error>
[src]

Retrive coordinate from a csv format.

pub fn center(&self) -> Coordinate
[src]

Gets the center position of the node accounting for size.

pub fn from_list(list: &[(i16, i16)]) -> Vec<Self>
[src]

Converts a list of tuples (x,y) to a Vector of Nodes. Names are assigned from "A" and upwards automatically.

use pathfinder::Node;
let list = [(0, 0), (10, 10), (15, 15)];
let nodes = Node::from_list(&list);
assert_eq!(nodes.len(), 3);

pub fn is_directly_connected(&self, other: &Node) -> bool
[src]

Looks through all connected Nodes and returns if they are connected.

pub fn linked_list(list: Vec<Node>) -> Vec<Self>
[src]

Links a list of nodes together in the order they are indexed. A list of A, B, C. Will result in them being linked as: A -> B -> C.

let nodes = Node::from_list(&[(0, 0), (20, 20)]);
let linked_list = Node::linked_list(nodes);

pub fn hl(&self, index: usize) -> Result<&HL>
[src]

Returns a specific link if it exists. Returns none if not.

let node = Node::new("", Coordinate::new(0, 0));
let hl = node.hl(0);
assert!(hl.is_err());
let a = Node::new("A", Coordinate::new(0, 0));
let mut b = Node::new("B", Coordinate::new(50, 50));
b.link(&a);
assert!(b.hl(0).is_ok());

pub fn hl_mut(&mut self, index: usize) -> Result<&mut HL>
[src]

See Node::hl for examples. Returns a mutable variant.

pub fn linked_list_predicate(
    list: Vec<Node>,
    f: &dyn Fn(Coordinate, Coordinate) -> bool
) -> Vec<Self>
[src]

Links a list of nodes together in the order they are indexed. A list of A, B, C. Will result in them being linked as: A -> B -> C.

use pathfinder::Node;
let nodes = Node::from_list(&[(0, 0), (20, 20)]);
let linked_list = Node::linked_list(nodes);

Returns the next point which is available to link.

let a = Node::new("A", Coordinate::new(0, 0));
let mut b = Node::new("B", Coordinate::new(50, 50));
assert_eq!(b.get_link_avail_index(), 0);
b.link(&a);
assert_eq!(b.get_link_avail_index(), 1);

pub fn disconnect(&mut self)
[src]

Removes all connects leaving this node. This still leaves connections going towards this node.

let a = Node::new("A", Coordinate::new(0, 0));
let mut b = Node::new("B", Coordinate::new(50, 50));
b.link(&a);
assert!(b.hl(0).is_ok());
b.disconnect();
assert!(b.hl(0).is_err());

Links Node self to another point that has Hash and Location implemented.

let b: Node = Node::new("B", Coordinate::new(100, 100));
let mut a: Node = Node::new("A", Coordinate::new(0, 0));
a.link(&b);
assert!(a.is_directly_connected(&b));

Trait Implementations

impl Hash for Node
[src]

impl Find for Node
[src]

fn find<H: Hash>(&self, hash: H) -> Option<Coordinate>
[src]

Matches the Hashes and returns Some if it matches.

impl MinMax for Node
[src]

impl Location for Node
[src]

fn eq<L: Location>(&self, other: &L) -> bool
[src]

Returns if the positions are equal or not.

fn x(&self) -> i16
[src]

Retrieves the X coordinate.

fn y(&self) -> i16
[src]

Retrieves the Y coordinate.

fn sum(&self) -> i16
[src]

Returns the sum of the x and y value.

impl Draw for Node
[src]

impl From<Coordinate> for Node
[src]

impl From<Group> for Node
[src]

impl From<Node> for Group
[src]

impl From<Node> for Coordinate
[src]

impl Copy for Node
[src]

impl Clone for Node
[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl<'a> PartialEq<Node> for Node
[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

impl Debug for Node
[src]

Auto Trait Implementations

impl Send for Node

impl Sync for Node

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> SetParameter for T
[src]

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
    T: Parameter<Self>, 
[src]

Sets value as a parameter of self.