SparkseePython  6.0.2
Public Member Functions | List of all members
sparksee.Context Class Reference

Context class. More...

Public Member Functions

def exclude_nodes (self, nodes)
 Set which nodes can't be used. More...
 
def __init__ (self, session, node)
 Creates a new instance. More...
 
def exclude_edges (self, edges)
 Set which edges can't be used. More...
 
def compute (self)
 Gets the resulting collection of nodes. More...
 
def add_edge_type (self, t, d)
 Allows for traversing edges of the given type. More...
 
def compute (self, session, node, node_types, edge_types, dir, maxhops, include)
 Helper method to easily compute a context from a node. More...
 
def set_maximum_hops (self, maxhops, include)
 Sets the maximum hops restriction. More...
 
def add_node_type (self, t)
 Allows for traversing nodes of the given type. More...
 
def close (self)
 Closes the Context instance. More...
 
def add_all_edge_types (self, d)
 Allows for traversing all edge types of the graph. More...
 
def add_all_node_types (self)
 Allows for traversing all node types of the graph.
 
def is_closed (self)
 Gets if Context has been closed or not. More...
 

Detailed Description

Context class.

It provides a very similar functionality than the Traversal classes. The main difference is Context returns a resulting collection whereas Traversal provides an iterator behaviour.

Check out the 'Algorithms' section in the SPARKSEE User Manual for more details on this.

Author
Sparsity Technologies http://www.sparsity-technologies.com

Constructor & Destructor Documentation

def sparksee.Context.__init__ (   self,
  session,
  node 
)

Creates a new instance.

Parameters
session[in] Session to get the graph from and perform operation.
node[in] Node to start traversal from.

Member Function Documentation

def sparksee.Context.add_all_edge_types (   self,
  d 
)

Allows for traversing all edge types of the graph.

Parameters
d[in] Edge direction.
def sparksee.Context.add_edge_type (   self,
  t,
  d 
)

Allows for traversing edges of the given type.

Parameters
t[in] Edge type.
d[in] Edge direction.
def sparksee.Context.add_node_type (   self,
  t 
)

Allows for traversing nodes of the given type.

Parameters
tnull
def sparksee.Context.close (   self)

Closes the Context instance.

It must be called to ensure the integrity of all data.

def sparksee.Context.compute (   self)

Gets the resulting collection of nodes.

Returns
The resulting collection of nodes.

Referenced by sparksee.Context.compute().

def sparksee.Context.compute (   self,
  session,
  node,
  node_types,
  edge_types,
  dir,
  maxhops,
  include 
)

Helper method to easily compute a context from a node.

Parameters
session[in] Session to get the graph from and perform operation.
node[in] Node to start traversal from.
node_types[in] Allowed node type list. NULL means all node types are allowed.
edge_types[in] Allowed edge type list. NULL means all edge types are allowed.
dir[in] Allowed direction for the allowed edge types.
maxhops[in] The maximum hops restriction. It must be positive or zero. Zero, the default value, means unlimited.
include[in] If TRUE, the resulting collection will include those nodes at distance less or equal than the given one, otherwise it will just include those nodes at distance equal than the given one. This parameter just makes sense if maxhops is different from 0; in that case it includes all nodes no matters the distance.
Returns
Returns an Objects with the computed context of a node.

References sparksee.Context.compute().

def sparksee.Context.exclude_edges (   self,
  edges 
)

Set which edges can't be used.

This will replace any previously specified set of excluded edges. Should only be used to exclude the usage of specific edges from allowed edge types because it's less efficient than not allowing an edge type.

Parameters
edges[in] A set of edge identifiers that must be kept intact until the destruction of the class.
def sparksee.Context.exclude_nodes (   self,
  nodes 
)

Set which nodes can't be used.

This will replace any previously specified set of excluded nodes. Should only be used to exclude the usage of specific nodes from allowed node types because it's less efficient than not allowing a node type.

Parameters
nodes[in] A set of node identifiers that must be kept intact until the destruction of the class.
def sparksee.Context.is_closed (   self)

Gets if Context has been closed or not.

See also
close()
Returns
TRUE if the Context instance has been closed, FALSE otherwise.
def sparksee.Context.set_maximum_hops (   self,
  maxhops,
  include 
)

Sets the maximum hops restriction.

All paths longer than the maximum hops restriction will be ignored.

Parameters
maxhops[in] The maximum hops restriction. It must be positive or zero. Zero, the default value, means unlimited.
include[in] If TRUE, the resulting collection will include those nodes at distance less or equal than the given one, otherwise it will just include those nodes at distance equal than the given one. This parameter just makes sense if maxhops is different from 0; in that case it includes all nodes no matters the distance.