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

Version Path
pacer-neo4j-2.3.7-java lib/pacer-neo4j/algo/block_cost_evaluator.rb
pacer-neo4j-2.3.6-java lib/pacer-neo4j/algo/block_cost_evaluator.rb
pacer-neo4j-2.3.5-java lib/pacer-neo4j/algo/block_cost_evaluator.rb
pacer-neo4j-2.3.4-java lib/pacer-neo4j/algo/block_cost_evaluator.rb
pacer-neo4j-2.3.3-java lib/pacer-neo4j/algo/block_cost_evaluator.rb
pacer-neo4j-2.3.2-java lib/pacer-neo4j/algo/block_cost_evaluator.rb
pacer-neo4j-2.3.0.pre-java lib/pacer-neo4j/algo/block_cost_evaluator.rb
pacer-neo4j-2.2.0-java lib/pacer-neo4j/algo/block_cost_evaluator.rb
pacer-neo4j-2.1.5-java lib/pacer-neo4j/algo/block_cost_evaluator.rb
pacer-neo4j-2.1.4-java lib/pacer-neo4j/algo/block_cost_evaluator.rb
pacer-neo4j-2.1.2-java lib/pacer-neo4j/algo/block_cost_evaluator.rb
pacer-neo4j-2.1.1-java lib/pacer-neo4j/algo/block_cost_evaluator.rb
pacer-neo4j-2.1.0-java lib/pacer-neo4j/algo/block_cost_evaluator.rb