module RDF::AllegroGraph::Functors::SnaFunctors

This module contains AllegroGraph functor definitions that may be called when building a query. Note that these functors merely add a functor expression to a query. The actual functor will be called on the server.

@see Session#generator

Constants

PrologLiteral

@private

Public Instance Methods

bidirectional_search_paths(from, to, generator, path, options={}) click to toggle source

Search for paths between two nodes following the edges specified by generator, and using a bidirectional search strategy.

@param [Symbol,RDF::Resource] from

Input: The start node in the path.

@param [Symbol,RDF::Resource] to

Input: The end node in the path.

@param [PrologLiteral] generator

Input: The generator to use when finding links to traverse.

@param [Symbol] to

Output: A list of nodes in the path.

@param [Hash] options @option options [Integer] :max_depth

Input: The maxium search depth.

@return [void]

# File lib/rdf/allegro_graph/functors/sna_functors.rb, line 70
def bidirectional_search_paths(from, to, generator, path, options={})
  search_paths('bidirectional-search-paths', from, to, generator, path,
               options)
end
breadth_first_search_paths(from, to, generator, path, options={}) click to toggle source

Search for paths between two nodes following the edges specified by generator, and using a breadth-first search strategy.

@param [Symbol,RDF::Resource] from

Input: The start node in the path.

@param [Symbol,RDF::Resource] to

Input: The end node in the path.

@param [PrologLiteral] generator

Input: The generator to use when finding links to traverse.

@param [Symbol] to

Output: A list of nodes in the path.

@param [Hash] options @option options [Integer] :max_depth

Input: The maxium search depth.

@return [void]

# File lib/rdf/allegro_graph/functors/sna_functors.rb, line 30
def breadth_first_search_paths(from, to, generator, path, options={})
  search_paths('breadth-first-search-paths', from, to, generator, path,
               options)
end
depth_first_search_paths(from, to, generator, path, options={}) click to toggle source

Search for paths between two nodes following the edges specified by generator, and using a depth-first search strategy.

@param [Symbol,RDF::Resource] from

Input: The start node in the path.

@param [Symbol,RDF::Resource] to

Input: The end node in the path.

@param [PrologLiteral] generator

Input: The generator to use when finding links to traverse.

@param [Symbol] to

Output: A list of nodes in the path.

@param [Hash] options @option options [Integer] :max_depth

Input: The maxium search depth.

@return [void]

# File lib/rdf/allegro_graph/functors/sna_functors.rb, line 50
def depth_first_search_paths(from, to, generator, path, options={})
  search_paths('depth-first-search-paths', from, to, generator, path,
               options)
end
ego_group(actor, depth, generator, group) click to toggle source

Generate an actor’s ego group.

@param [Symbol,RDF::Resource] actor

Input: The resource at the center of the graph.

@param [Integer] depth

Input: The maximum number of links to traverse.

@param [PrologLiteral] generator

Input: The generator to use when finding links to traverse.

@param [Array<RDF::Resource>] group

Output: Either a variable or resource.

@return [void]

# File lib/rdf/allegro_graph/functors/sna_functors.rb, line 127
def ego_group(actor, depth, generator, group)
  functor('ego-group', actor, PrologLiteral.new(depth),
          generator, group)
end
ego_group_member(actor, depth, generator, member) click to toggle source

Generate all members of an actor’s ego group.

@param [Symbol,RDF::Resource] actor

Input: The resource at the center of the graph.

@param [Integer] depth

Input: The maximum number of links to traverse.

@param [PrologLiteral] generator

Input: The generator to use when finding links to traverse.

@param [Symbol,RDF::Resource] group

Input/Output: Either a variable or resource.

@return [void]

# File lib/rdf/allegro_graph/functors/sna_functors.rb, line 143
def ego_group_member(actor, depth, generator, member)
  functor('ego-group-member', actor, PrologLiteral.new(depth),
          generator, member)
end
neighbor_count(actor, generator, count) click to toggle source

Count the neighbors of the actor.

@param [Symbol,RDF::Resource] actor

Input: The node whose neighbors we want to find.

@param [PrologLiteral] generator

Input: The generator to use when finding links to traverse.

@param [Symbol] count

Output: The number of neighbors of the actor.

@return [void]

# File lib/rdf/allegro_graph/functors/sna_functors.rb, line 97
def neighbor_count(actor, generator, count)
  functor('nodal-degree', actor, generator, count)
end
Also aliased as: nodal_degree
neighbors(actor, generator, neighbor) click to toggle source

Find all neighbors of the actor.

@param [Symbol,RDF::Resource] actor

Input: The node whose neighbors we want to find.

@param [PrologLiteral] generator

Input: The generator to use when finding links to traverse.

@param [Symbol] neighbor

Output: A neighbor of the actor.

@return [void]

# File lib/rdf/allegro_graph/functors/sna_functors.rb, line 111
def neighbors(actor, generator, neighbor)
  functor('nodal-neighbors', actor, generator, neighbor)
end
Also aliased as: nodal_neighbors
nodal_degree(actor, generator, count)
Alias for: neighbor_count
nodal_neighbors(actor, generator, neighbor)
Alias for: neighbors
search_paths(functor_name, from, to, generator, path, options={}) click to toggle source

@private

# File lib/rdf/allegro_graph/functors/sna_functors.rb, line 76
def search_paths(functor_name, from, to, generator, path, options={})
  if options.has_key?(:max_depth)
    functor(functor_name, from, to, generator,
            PrologLiteral.new(options[:max_depth]), path)
  else
    functor(functor_name, from, to, generator, path)
  end
end