model.js | |
bbop. | Purpose: Basic edged graph and operations. |
Variables | |
default_predicate | The predicate we’ll use when none other is defined. |
bbop. | |
Functions | |
node | Contructor for a BBOP graph model node. |
id | Getter/setter for node id. |
type | Getter/setter for node type. |
label | Getter/setter for node label. |
metadata | Getter/setter for node metadata. |
clone | Get a fresh new copy of the current node (using bbop.core.clone for metadata object). |
bbop. | |
Functions | |
edge | Contructor for a BBOP graph model edge. |
subject_id | Getter/setter for edge subject id. |
object_id | Getter/setter for edge object id. |
predicate_id | Getter/setter for edge predicate id. |
type | Getter/setter for edge type. |
metadata | Getter/setter for edge metadata. |
clone | Get a fresh new copy of the current edge (using bbop.core.clone for metadata object). |
bbop. | |
Functions | |
graph | Contructor for a BBOP graph model graph. |
id | Getter/setter for the graph id. |
add_node | Add a node to the graph. |
add_edge | Add an edge to the graph. |
all_nodes | Returns an /original/ list of all added nodes. |
all_edges | Returns an /original/ list of all added edges. |
all_predicates | Returns an /original/ list of all added predicates. |
all_dangling | List all external nodes by referenced id. |
is_complete | Any bad parts in graph? |
get_node | Return a /copy/ of a node by id (not the original) if extant. |
get_edge | Return a /copy/ of an edge by ids (not the original) if extant. |
get_edges | Return all edges (copies) of given subject and object ids. |
get_predicates | Return all predicates of given subject and object ids. |
edges_to_nodes | Translate an edge array into extant (node) bodies, switching on either ‘subject’ or ‘object’. |
is_root_node | Roots are defined as nodes who are the subject of nothing, independent of predicate. |
get_root_nodes | Return a list of /copies/ of the root nodes. |
is_leaf_node | Leaves are defined as nodes who are the object of nothing, independent of predicate. |
get_leaf_nodes | Return a list of /copies/ of the leaf nodes. |
get_singleton_nodes | Find nodes that are roots and leaves over all relations. |
get_parent_edges | Return all parent edges; the /originals/. |
get_parent_nodes | Return all parent nodes; the /originals/. |
get_child_nodes | Return all child nodes; the /originals/. |
get_ancestor_subgraph | Return new ancestors subgraph. |
merge_in | Add a graph to the current graph, without sharing any of the merged in graph’s structure. |
load_json | Load the graph from the specified JSON object (not string). |
to_json | Dump out the graph into a JSON-able object. |
Purpose: Basic edged graph and operations.
NOTE: A model instance may not be the whole graph, just a subgraph--this is the difference between nodes and named_nodes. nodes are real things, while named_nodes are things referenced by edges.
Check TODOs, we would like everything as linear as possible.
TODO: memoize everything but add_*. Functional enough that it should work if we just empty the caches after every add_* op.
Required: bbop.core (core.js)
Variables | |
default_predicate | The predicate we’ll use when none other is defined. |
Functions | |
edge | Contructor for a BBOP graph model edge. |
subject_id | Getter/setter for edge subject id. |
object_id | Getter/setter for edge object id. |
predicate_id | Getter/setter for edge predicate id. |
type | Getter/setter for edge type. |
metadata | Getter/setter for edge metadata. |
clone | Get a fresh new copy of the current edge (using bbop.core.clone for metadata object). |
bbop.model.edge = function( subject, object, predicate )
Contructor for a BBOP graph model edge.
If no predicate is given, default_predicate is used. Predicates are currently treated as raw strings.
subject | node id string or node |
object | node id string or node |
predicate | [optional] a user-friendly description of the node |
bbop model edge
Functions | |
graph | Contructor for a BBOP graph model graph. |
id | Getter/setter for the graph id. |
add_node | Add a node to the graph. |
add_edge | Add an edge to the graph. |
all_nodes | Returns an /original/ list of all added nodes. |
all_edges | Returns an /original/ list of all added edges. |
all_predicates | Returns an /original/ list of all added predicates. |
all_dangling | List all external nodes by referenced id. |
is_complete | Any bad parts in graph? |
get_node | Return a /copy/ of a node by id (not the original) if extant. |
get_edge | Return a /copy/ of an edge by ids (not the original) if extant. |
get_edges | Return all edges (copies) of given subject and object ids. |
get_predicates | Return all predicates of given subject and object ids. |
edges_to_nodes | Translate an edge array into extant (node) bodies, switching on either ‘subject’ or ‘object’. |
is_root_node | Roots are defined as nodes who are the subject of nothing, independent of predicate. |
get_root_nodes | Return a list of /copies/ of the root nodes. |
is_leaf_node | Leaves are defined as nodes who are the object of nothing, independent of predicate. |
get_leaf_nodes | Return a list of /copies/ of the leaf nodes. |
get_singleton_nodes | Find nodes that are roots and leaves over all relations. |
get_parent_edges | Return all parent edges; the /originals/. |
get_parent_nodes | Return all parent nodes; the /originals/. |
get_child_nodes | Return all child nodes; the /originals/. |
get_ancestor_subgraph | Return new ancestors subgraph. |
merge_in | Add a graph to the current graph, without sharing any of the merged in graph’s structure. |
load_json | Load the graph from the specified JSON object (not string). |
to_json | Dump out the graph into a JSON-able object. |
bbop.model.graph.prototype.add_node = function( node )
Add a node to the graph.
node | node to add to the graph |
n/a
bbop.model.graph.prototype.add_edge = function( edge )
Add an edge to the graph.
edge | edge to add to the graph |
n/a
bbop.model.graph.prototype.get_edge = function( sub_id, obj_id, pred )
Return a /copy/ of an edge by ids (not the original) if extant.
sub_id | the subject_id of the edge we’re looking for |
obj_id | the object_id of the edge we’re looking for |
pred | [optional] the predicate of the edge we’re looking for |
bbop.model.graph.prototype.get_edges = function( sub_id, obj_id )
Return all edges (copies) of given subject and object ids. Returns entirely new edges.
sub_id | the subject_id of the edge we’re looking for |
obj_id | the object_id of the edge we’re looking for |
list of bbop.model.edge
bbop.model.graph.prototype.edges_to_nodes = function( in_edges, target )
Translate an edge array into extant (node) bodies, switching on either ‘subject’ or ‘object’.
This will return the /original/ nodes.
This will throw an error on any world issues that crop up.
in_edges | the edges we want the subjects or objects of |
target | ’subject’ or ‘object’ |
array of bbop.model.node
bbop.model.graph.prototype.get_root_nodes = function()
Return a list of /copies/ of the root nodes.
BUG/TODO: Could I speed this up by my moving some of the calculation into the add_node and add_edge methods? O(|#nodes|)
n/a
array of bbop.model.node
bbop.model.graph.prototype.get_leaf_nodes = function()
Return a list of /copies/ of the leaf nodes.
BUG/TODO: Could I speed this up by my moving some of the calculation into the add_node and add_edge methods? O(|#nodes|)
n/a
array of bbop.model.node
bbop.model.graph.prototype.get_singleton_nodes = function()
Find nodes that are roots and leaves over all relations. This returns the /original/ node.
Throws an error if there is a world issue.
n/a
array of bbop.model.node
bbop.model.graph.prototype.get_parent_edges = function( nb_id, in_pred )
Return all parent edges; the /originals/. If no predicate is given, use the default one.
TODO: it might be nice to memoize this since others depend on it.
nb_id | the node to consider |
in_pred | [optional] over this predicate |
array of bbop.model.edge
bbop.model.graph.prototype.get_parent_nodes = function( nb_id, in_pred )
Return all parent nodes; the /originals/. If no predicate is given, use the default one.
nb_id | the node to consider |
in_pred | [optional] over this predicate |
array of bbop.model.node
bbop.model.graph.prototype.get_child_nodes = function( nb_id, in_pred )
Return all child nodes; the /originals/. If no predicate is given, use the default one.
nb_id | the node to consider |
in_pred | [optional] over this predicate |
array of bbop.model.node
The predicate we’ll use when none other is defined.
bbop.model.default_predicate
Contructor for a BBOP graph model node.
bbop.model.node = function( new_id, new_label )
Getter/setter for node id.
bbop.model.node.prototype.id = function( value )
Getter/setter for node type.
bbop.model.node.prototype.type = function( value )
Getter/setter for node label.
bbop.model.node.prototype.label = function( value )
Getter/setter for node metadata.
bbop.model.node.prototype.metadata = function( value )
Get a fresh new copy of the current node (using bbop.core.clone for metadata object).
bbop.model.node.prototype.clone = function()
Contructor for a BBOP graph model edge.
bbop.model.edge = function( subject, object, predicate )
Getter/setter for edge subject id.
bbop.model.edge.prototype.subject_id = function()
Getter/setter for edge object id.
bbop.model.edge.prototype.object_id = function()
Getter/setter for edge predicate id.
bbop.model.edge.prototype.predicate_id = function()
Getter/setter for edge type.
bbop.model.edge.prototype.type = function( value )
Getter/setter for edge metadata.
bbop.model.edge.prototype.metadata = function( value )
Get a fresh new copy of the current edge (using bbop.core.clone for metadata object).
bbop.model.edge.prototype.clone = function()
Getter/setter for the graph id.
bbop.model.graph.prototype.id = function( value )
Add a node to the graph.
bbop.model.graph.prototype.add_node = function( node )
Add an edge to the graph.
bbop.model.graph.prototype.add_edge = function( edge )
Returns an /original/ list of all added nodes.
bbop.model.graph.prototype.all_nodes = function()
Returns an /original/ list of all added edges.
bbop.model.graph.prototype.all_edges = function()
Returns an /original/ list of all added predicates.
bbop.model.graph.prototype.all_predicates = function()
List all external nodes by referenced id.
bbop.model.graph.prototype.all_dangling = function()
Any bad parts in graph?
bbop.model.graph.prototype.is_complete = function()
Return a /copy/ of a node by id (not the original) if extant.
bbop.model.graph.prototype.get_node = function( nid )
Return a /copy/ of an edge by ids (not the original) if extant.
bbop.model.graph.prototype.get_edge = function( sub_id, obj_id, pred )
Return all edges (copies) of given subject and object ids.
bbop.model.graph.prototype.get_edges = function( sub_id, obj_id )
Return all predicates of given subject and object ids.
bbop.model.graph.prototype.get_predicates = function( sub_id, obj_id )
Translate an edge array into extant (node) bodies, switching on either ‘subject’ or ‘object’.
bbop.model.graph.prototype.edges_to_nodes = function( in_edges, target )
Roots are defined as nodes who are the subject of nothing, independent of predicate.
bbop.model.graph.prototype.is_root_node = function( nb_id )
Return a list of /copies/ of the root nodes.
bbop.model.graph.prototype.get_root_nodes = function()
Leaves are defined as nodes who are the object of nothing, independent of predicate.
bbop.model.graph.prototype.is_leaf_node = function( nb_id )
Return a list of /copies/ of the leaf nodes.
bbop.model.graph.prototype.get_leaf_nodes = function()
Find nodes that are roots and leaves over all relations.
bbop.model.graph.prototype.get_singleton_nodes = function()
Return all parent edges; the /originals/.
bbop.model.graph.prototype.get_parent_edges = function( nb_id, in_pred )
Return all parent nodes; the /originals/.
bbop.model.graph.prototype.get_parent_nodes = function( nb_id, in_pred )
Return all child nodes; the /originals/.
bbop.model.graph.prototype.get_child_nodes = function( nb_id, in_pred )
Return new ancestors subgraph.
bbop.model.graph.prototype.get_ancestor_subgraph = function( nb_id_or_list, pid )
Add a graph to the current graph, without sharing any of the merged in graph’s structure.
bbop.model.graph.prototype.merge_in = function( in_graph )
Load the graph from the specified JSON object (not string).
bbop.model.graph.prototype.load_json = function( json_object )
Dump out the graph into a JSON-able object.
bbop.model.graph.prototype.to_json = function()