Struct cayley::path::Vertex [-]  [+] [src]

pub struct Vertex {
    // some fields omitted
}

An interface to a Path with the ability to be executed as a Query to a database. The main entry point to ask for GraphNodes from database using Graph as an interceptor.

To query for anything you might describe with Path from database, use this pattern: graph.find(Vertex::start(<NodeSelector>).<PathMethod>().<PathMethod>(<method_arg>).....<QueryMethod>()).

Example:

use cayley::graph::Graph;
use cayley::path::{Vertex, Path, Query}; // Query and Path trait imports are required
use cayley::selector::{Tags, AnyNode, Predicate};

let graph = Graph::default().unwrap();
graph.find(Vertex::start(AnyNode)
                  .As(Tags(vec!("tag-a", "tag-b")))
                  .OutP(Predicate("follows"))
                  .All()).unwrap();

Another example:

use cayley::{Graph, DefaultVersion};
use cayley::GraphNodes;
use cayley::path::{Vertex, Query}; // Query trait import is required
use cayley::selector::AnyNode;

let graph = Graph::new("localhost", 64210, DefaultVersion).unwrap();
match graph.find(Vertex::start(AnyNode).All()) {
   Ok(GraphNodes(nodes)) => assert!(nodes.len() > 0),
   Err(error) => fail!(error.to_string())
};

Sometimes it is wanted to separate a vertex instance from a query construction. Use prepare static method for this purpose, but then ensure to start a query with From call:

#![allow(unused_result)]
use cayley::Graph;
use cayley::path::{Vertex, Path, Query};
use cayley::selector::{Node, Predicate};

let graph = Graph::default().unwrap();
let mut v = Vertex::prepare();
// NB: Do not finalize the queries you plan to reuse!
v.From(Node("C")).OutP(Predicate("follows"));
let mut other_v = Vertex::prepare();
other_v.From(Node("D")).Union(&v).All();
graph.find(&other_v).unwrap();

Methods

impl Vertex

fn start(nodes: NodeSelector) -> Vertex

Create a Vertex instance and start a query from NodeSelector

fn prepare() -> Vertex

Prepare a vertex instance to specify a query later. Ensure to start a query with .From() method if you use prepare().

fn From(&mut self, nodes: NodeSelector) -> &mut Vertex

A method for postponed query creation, intended to be used after the prepare() method on the same Vertex instance.

Trait Implementations

impl Compile for Vertex

fn add_str(&mut self, str: &str) -> &mut Vertex

fn add_string(&mut self, str: String) -> &mut Vertex

fn compile(&self) -> Option<String>

impl Path for Vertex

fn Out(&mut self, predicates: PredicateSelector, tags: TagSelector) -> &mut Self

fn OutP(&mut self, predicates: PredicateSelector) -> &mut Self

fn OutT(&mut self, tags: TagSelector) -> &mut Self

fn In(&mut self, predicates: PredicateSelector, tags: TagSelector) -> &mut Self

fn InP(&mut self, predicates: PredicateSelector) -> &mut Self

fn InT(&mut self, tags: TagSelector) -> &mut Self

fn Both(&mut self, predicates: PredicateSelector, tags: TagSelector) -> &mut Self

fn BothP(&mut self, predicates: PredicateSelector) -> &mut Self

fn BothT(&mut self, tags: TagSelector) -> &mut Self

fn Is(&mut self, nodes: NodeSelector) -> &mut Self

fn Has(&mut self, predicates: PredicateSelector, nodes: NodeSelector) -> &mut Self

fn HasP(&mut self, predicates: PredicateSelector) -> &mut Self

fn HasN(&mut self, nodes: NodeSelector) -> &mut Self

fn Tag(&mut self, tags: TagSelector) -> &mut Self

fn As(&mut self, tags: TagSelector) -> &mut Self

fn Back(&mut self, tags: TagSelector) -> &mut Self

fn Save(&mut self, predicates: PredicateSelector, tags: TagSelector) -> &mut Self

fn SaveP(&mut self, predicates: PredicateSelector) -> &mut Self

fn SaveT(&mut self, tags: TagSelector) -> &mut Self

fn Intersect(&mut self, query: &Query) -> &mut Self

fn And(&mut self, query: &Query) -> &mut Self

fn Union(&mut self, query: &Query) -> &mut Self

fn Or(&mut self, query: &Query) -> &mut Self

fn Follow(&mut self, reusable: &Reuse) -> &mut Self

fn FollowR(&mut self, reusable: &Reuse) -> &mut Self

impl Query for Vertex

fn set_finalized(&mut self)

fn is_finalized(&self) -> bool

fn All(&mut self) -> &mut Self

fn GetLimit(&mut self, limit: int) -> &mut Self

impl Clone for Vertex

fn clone(&self) -> Vertex

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