-
Notifications
You must be signed in to change notification settings - Fork 5
Simple Graphs
topofocus edited this page Apr 26, 2019
·
8 revisions
The basic setup: A basic-node-class and an ExtraNode class. The connection is realized through Connects-Edges.
V.create_class :base, :node
Node.create_class :extra_node
c= E.create_class :connects
c.uniq_indexBase --> Connects --> ExtraNode ---> Connects ---> ExtraNode ...
def linear_elements start, count
new_vertex = ->(n) { ExtraNode.create( note_count: n ) }
e= Connects.create from: start, to: new_vertex[1]
(2..count).each { |m| e= Connects.create from: e.first.in , to: new_vertex[m] }
end
# call with
start = Base.create some_label: 'some_value'
linear_elements start, 200 # for 200 list-elementsIts elements (vertices) an be accessed through
vertex.traverse in_or_out, via: /pattern/, depth: some_value`, start_at: 1
### Receive a List of Nodes
> start.traverse :out, via: /con/ , depth: 100
returns a list with 100 connected vertices. The set can be narrowed by specifying a start_vertex.
Then the following query is fired:
> select from ( traverse outE('connects').in from #{vertex} while $depth <= #{depth} )
> where $depth >= #{start_at} The database offers some functions, which can applied to the resultset.
Vertex.traverse can return the query to fetch all list-elements. This is input to a OrientQuery
> the_collection = start_point.traverse :out, via: /con/, depth: 100, execute: false
> the_query = OrientSupport::OrientQuery.new from: the_collecion,
projection: 'median(note_count)',
where: '$depth>=50 '
> Base.query_dataset the_query
=> [75]Overview
Data Management
- Joining Tables, embedded Lists
- Links and Link Lists
- Relations
- Bidirectional Connections
- Working with Hashes
Public API
- Database
- Model CRUD
Misc