ForceGraph

Struct ForceGraph 

Source
pub struct ForceGraph<UserNodeData = (), UserEdgeData = ()> {
    pub parameters: SimulationParameters,
    /* private fields */
}
Expand description

The main force graph structure.

Fields§

§parameters: SimulationParameters

Implementations§

Source§

impl<UserNodeData, UserEdgeData> ForceGraph<UserNodeData, UserEdgeData>

Source

pub fn new(parameters: SimulationParameters) -> Self

Constructs a new force graph.

Use the following syntax to create a graph with default parameters:

use force_graph::ForceGraph;
let graph = <ForceGraph>::new(Default::default());
Source

pub fn get_graph( &self, ) -> &StableUnGraph<Node<UserNodeData>, EdgeData<UserEdgeData>>

Provides access to the raw graph structure if required.

Source

pub fn add_node(&mut self, node_data: NodeData<UserNodeData>) -> DefaultNodeIdx

Adds a new node and returns an index that can be used to reference the node.

Source

pub fn remove_node(&mut self, idx: DefaultNodeIdx)

Removes a node by index.

Source

pub fn add_edge( &mut self, n1_idx: DefaultNodeIdx, n2_idx: DefaultNodeIdx, edge: EdgeData<UserEdgeData>, )

Adds or updates an edge connecting two nodes by index.

Source

pub fn clear(&mut self)

Removes all nodes from the force graph.

Source

pub fn update(&mut self, dt: f32)

Applies the next step of the force graph simulation.

The number of seconds that have elapsed since the previous update must be calculated and provided by the user as dt.

Source

pub fn visit_nodes<F: FnMut(&Node<UserNodeData>)>(&self, cb: F)

Processes each node with a user-defined callback cb.

Source

pub fn visit_nodes_mut<F: FnMut(&mut Node<UserNodeData>)>(&mut self, cb: F)

Mutates each node with a user-defined callback cb.

Source

pub fn visit_edges<F: FnMut(&Node<UserNodeData>, &Node<UserNodeData>, &EdgeData<UserEdgeData>)>( &self, cb: F, )

Processes each edge and its associated nodes with a user-defined callback cb.

Auto Trait Implementations§

§

impl<UserNodeData, UserEdgeData> Freeze for ForceGraph<UserNodeData, UserEdgeData>

§

impl<UserNodeData, UserEdgeData> RefUnwindSafe for ForceGraph<UserNodeData, UserEdgeData>
where UserEdgeData: RefUnwindSafe, UserNodeData: RefUnwindSafe,

§

impl<UserNodeData, UserEdgeData> Send for ForceGraph<UserNodeData, UserEdgeData>
where UserEdgeData: Send, UserNodeData: Send,

§

impl<UserNodeData, UserEdgeData> Sync for ForceGraph<UserNodeData, UserEdgeData>
where UserEdgeData: Sync, UserNodeData: Sync,

§

impl<UserNodeData, UserEdgeData> Unpin for ForceGraph<UserNodeData, UserEdgeData>
where UserEdgeData: Unpin, UserNodeData: Unpin,

§

impl<UserNodeData, UserEdgeData> UnwindSafe for ForceGraph<UserNodeData, UserEdgeData>
where UserEdgeData: UnwindSafe, UserNodeData: UnwindSafe,

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.