class GraphMatching::DirectedEdgeSet

A `DirectedEdgeSet` is simply a set of directed edges in a graph. Whether the graph is actually directed or not is irrelevant, we can still discuss directed edges in an undirected graph.

The naive implementation would be to use ruby's `Set` and RGL's `DirectedEdge`. This class is optimized to use a 2D array instead. The sub-array at index i represents a set (or subset) of vertexes adjacent to i.

Attributes

edges[R]

Public Class Methods

new(graph_size) click to toggle source
# File lib/graph_matching/directed_edge_set.rb, line 15
def initialize(graph_size)
  @edges = Array.new(graph_size + 1) { [] }
end

Public Instance Methods

add(v, w) click to toggle source
# File lib/graph_matching/directed_edge_set.rb, line 19
def add(v, w)
  edges[v] << w
end
adjacent_vertices(v) click to toggle source
# File lib/graph_matching/directed_edge_set.rb, line 23
def adjacent_vertices(v)
  edges[v]
end