class Ogr::GraphAsTriMatrix
Graph
implemented as Triangular Matrix
Public Class Methods
new()
click to toggle source
# File lib/ogr/graphs/graph_as_tri_matrix.rb, line 4 def initialize @store = TriMatrix.new(0) end
Public Instance Methods
degree(x)
click to toggle source
Returns vertex degree.
# File lib/ogr/graphs/graph_as_tri_matrix.rb, line 9 def degree(x) sum = 0 vc = (0..@store.size) vc.each do |i| sum += @store[x, i] if @store[x, i] end sum end
each_edge(vertexes) { |edge| ... }
click to toggle source
Edge
iterator
# File lib/ogr/graphs/graph_as_tri_matrix.rb, line 19 def each_edge(vertexes) size = vertexes.size (0...size).each do |v0| (0...v0).each do |v1| yield Edge.new(vertexes[v0], vertexes[v1], @store[v0, v1]) if connected?(v0, v1) end end end