class BipartiteGraph::Subgraph

Attributes

edges[R]
graph[R]
nodes[R]
sinks[R]
sources[R]

Public Class Methods

new(graph) click to toggle source
# File lib/bipartite_graph/subgraph.rb, line 4
def initialize(graph)
  @graph = graph
  clear
end

Public Instance Methods

add_edge(edge) click to toggle source
# File lib/bipartite_graph/subgraph.rb, line 16
def add_edge(edge)
  @edges << edge
  @sources << edge.from
  @sinks   << edge.to
  @nodes = @sources + @sinks
end
clear() click to toggle source
# File lib/bipartite_graph/subgraph.rb, line 9
def clear
  @sources = Set.new
  @sinks   = Set.new
  @nodes   = Set.new
  @edges   = EdgeSet.new
end
has_node?(node) click to toggle source
# File lib/bipartite_graph/subgraph.rb, line 23
def has_node?(node)
  nodes.include?(node)
end