Class: BipartiteGraph::Subgraph
- Inherits:
-
Object
- Object
- BipartiteGraph::Subgraph
- Defined in:
- lib/bipartite_graph/subgraph.rb
Instance Attribute Summary collapse
-
#edges ⇒ Object
readonly
Returns the value of attribute edges.
-
#graph ⇒ Object
readonly
Returns the value of attribute graph.
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
-
#sinks ⇒ Object
readonly
Returns the value of attribute sinks.
-
#sources ⇒ Object
readonly
Returns the value of attribute sources.
Instance Method Summary collapse
- #add_edge(edge) ⇒ Object
- #clear ⇒ Object
- #has_node?(node) ⇒ Boolean
-
#initialize(graph) ⇒ Subgraph
constructor
A new instance of Subgraph.
Constructor Details
#initialize(graph) ⇒ Subgraph
Returns a new instance of Subgraph.
4 5 6 7 |
# File 'lib/bipartite_graph/subgraph.rb', line 4 def initialize(graph) @graph = graph clear end |
Instance Attribute Details
#edges ⇒ Object (readonly)
Returns the value of attribute edges.
3 4 5 |
# File 'lib/bipartite_graph/subgraph.rb', line 3 def edges @edges end |
#graph ⇒ Object (readonly)
Returns the value of attribute graph.
3 4 5 |
# File 'lib/bipartite_graph/subgraph.rb', line 3 def graph @graph end |
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
3 4 5 |
# File 'lib/bipartite_graph/subgraph.rb', line 3 def nodes @nodes end |
#sinks ⇒ Object (readonly)
Returns the value of attribute sinks.
3 4 5 |
# File 'lib/bipartite_graph/subgraph.rb', line 3 def sinks @sinks end |
#sources ⇒ Object (readonly)
Returns the value of attribute sources.
3 4 5 |
# File 'lib/bipartite_graph/subgraph.rb', line 3 def sources @sources end |
Instance Method Details
#add_edge(edge) ⇒ Object
16 17 18 19 20 21 |
# 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 ⇒ Object
9 10 11 12 13 14 |
# 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) ⇒ Boolean
23 24 25 |
# File 'lib/bipartite_graph/subgraph.rb', line 23 def has_node?(node) nodes.include?(node) end |