Sha256: a1cbde0f0d68513b67fa2b4110c53403b11941dc163e4ae9c61073bffa56066f
Contents?: true
Size: 1.01 KB
Versions: 13
Compression:
Stored size: 1.01 KB
Contents
module Pacer module Neo4j module Algo class BlockCostEvaluator import org.neo4j.graphalgo.CostEvaluator import org.neo4j.graphdb.Direction import com.tinkerpop.blueprints.impls.neo4j.Neo4jEdge include CostEvaluator DIRS = { Direction::INCOMING => :in, Direction::OUTGOING => :out, Direction::BOTH => :both } attr_reader :block, :graph, :default def initialize(block, graph, default) @block = block @graph = graph @default = default.to_f end def getCost(rel, dir) e = Pacer::Wrappers::EdgeWrapper.new graph, Neo4jEdge.new(rel, graph.blueprints_graph) result = block.call e, DIRS[dir] if result.is_a? Numeric result.to_f elsif default default else fail Pacer::ClientError, "No cost returned and no default specified: #{ result.inspect }" end end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems