[][src]Trait zamm_yin::graph::Graph

pub trait Graph {
    fn size(&self) -> usize;
fn add_node(&mut self) -> usize;
fn set_node_value(&mut self, id: usize, value: Box<dyn KBValue>);
fn set_node_name(&mut self, id: usize, name: String);
fn node_name(&self, id: usize) -> Option<Rc<String>>;
fn node_value(&self, id: usize) -> Option<Rc<Box<dyn KBValue>>>;
fn lookup(&self, name: &str) -> Vec<usize>;
fn add_edge(&mut self, from: usize, edge_type: usize, to: usize);
fn has_edge(&self, from: usize, edge_type: usize, to: usize) -> bool;
fn outgoing_nodes(&self, from: usize, edge_type: usize) -> Vec<usize>;
fn incoming_nodes(&self, to: usize, edge_type: usize) -> Vec<usize>;
fn all_outgoing_nodes(&self, from: usize) -> Vec<usize>;
fn all_incoming_nodes(&self, to: usize) -> Vec<usize>;
fn into_dot(&self) -> String; }

A classic directed Graph with nodes and labeled links.

Required methods

fn size(&self) -> usize

The number of nodes in the graph.

fn add_node(&mut self) -> usize

Adds a new node to the graph, and returns the node's ID.

fn set_node_value(&mut self, id: usize, value: Box<dyn KBValue>)

Sets the value for a given node. Values can only be set once.

fn set_node_name(&mut self, id: usize, name: String)

Sets the name for a given node. Names can only be set once.

fn node_name(&self, id: usize) -> Option<Rc<String>>

Retrieve's a node's name from the graph, or None if the node does not exist or is unnamed.

fn node_value(&self, id: usize) -> Option<Rc<Box<dyn KBValue>>>

Retrieve's a node's name from the graph, or None if the node does not exist or does not have a value.

fn lookup(&self, name: &str) -> Vec<usize>

Look up a node ID based on name. A vec is returned because there are no constraints on name uniqueness.

fn add_edge(&mut self, from: usize, edge_type: usize, to: usize)

Add a labeled edge between two nodes. The label should be the ID of an existing node.

fn has_edge(&self, from: usize, edge_type: usize, to: usize) -> bool

Checks for a labeled edge between two nodes. The label should be the ID of an existing node.

fn outgoing_nodes(&self, from: usize, edge_type: usize) -> Vec<usize>

Retrieve all node IDs that are on the other end of an outgoing edge of the given type.

fn incoming_nodes(&self, to: usize, edge_type: usize) -> Vec<usize>

Retrieve all node IDs that are on the other end of an incoming edge of the given type.

fn all_outgoing_nodes(&self, from: usize) -> Vec<usize>

Retrieve all node IDs that are on the other end of outgoing edges.

fn all_incoming_nodes(&self, to: usize) -> Vec<usize>

Retrieve all node IDs that are on the other end of incoming edges.

fn into_dot(&self) -> String

Outputs the entire graph in DOT format.

Loading content...

Implementors

impl Graph for InjectionGraph[src]

Loading content...