Skip to main content

Graph

Struct Graph 

Source
pub struct Graph { /* private fields */ }
Expand description

Opaque handle to an interactive graph.

Create with Graph::new(). The graph can be used programmatically to build and inspect node/edge structures.

This type implements Drop to release the underlying SDK resource. It is move-only (not cloneable).

Implementations§

Source§

impl Graph

Source

pub fn new() -> Self

Create a new empty graph.

Source

pub fn add_node(&mut self) -> NodeId

Add a node to the graph. Returns the new node ID.

Source

pub fn remove_node(&mut self, node: NodeId) -> Status

Remove a node and all its incident edges.

Source

pub fn total_node_count(&self) -> i32

Total number of nodes (including group/hidden nodes).

Source

pub fn visible_node_count(&self) -> i32

Number of visible (non-hidden) nodes.

Source

pub fn node_exists(&self, node: NodeId) -> bool

Check if a node exists and is visible.

Source

pub fn add_edge(&mut self, source: NodeId, target: NodeId) -> Status

Add a directed edge from source to target.

Source

pub fn add_edge_with_info( &mut self, source: NodeId, target: NodeId, info: EdgeInfo, ) -> Status

Add a directed edge with visual properties.

Source

pub fn remove_edge(&mut self, source: NodeId, target: NodeId) -> Status

Remove a directed edge.

Source

pub fn replace_edge( &mut self, from: NodeId, to: NodeId, new_from: NodeId, new_to: NodeId, ) -> Status

Replace edge (from, to) with (new_from, new_to).

Source

pub fn successors(&self, node: NodeId) -> Result<Vec<NodeId>>

Get successor node IDs for a node.

Source

pub fn predecessors(&self, node: NodeId) -> Result<Vec<NodeId>>

Get predecessor node IDs for a node.

Source

pub fn visible_nodes(&self) -> Result<Vec<NodeId>>

Get all visible node IDs.

Source

pub fn edges(&self) -> Result<Vec<Edge>>

Get all edges.

Source

pub fn path_exists(&self, source: NodeId, target: NodeId) -> bool

Check if a path exists from source to target.

Source

pub fn create_group(&mut self, nodes: &[NodeId]) -> Result<NodeId>

Create a group containing the given nodes.

Source

pub fn delete_group(&mut self, group: NodeId) -> Status

Delete a group node but keep its member nodes.

Source

pub fn set_group_expanded(&mut self, group: NodeId, expanded: bool) -> Status

Expand (show contents) or collapse (hide contents) a group.

Source

pub fn is_group(&self, node: NodeId) -> bool

Check if a node is a group node.

Source

pub fn is_collapsed(&self, group: NodeId) -> bool

Check if a group node is collapsed.

Source

pub fn group_members(&self, group: NodeId) -> Result<Vec<NodeId>>

Get the member nodes of a group.

Source

pub fn set_layout(&mut self, layout: Layout) -> Status

Set the layout algorithm and recompute.

Source

pub fn current_layout(&self) -> Layout

Return the currently selected layout algorithm.

Source

pub fn redo_layout(&mut self) -> Status

Recompute the current layout.

Source

pub fn clear(&mut self) -> Status

Clear all nodes and edges.

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() -> Self

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

impl Drop for Graph

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Graph

Auto Trait Implementations§

§

impl Freeze for Graph

§

impl RefUnwindSafe 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> 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.