Class: RGL::ImplicitGraph
Constant Summary collapse
- EMPTY_VERTEX_ITERATOR =
proc { |b| }
- EMPTY_NEIGHBOR_ITERATOR =
proc { |x, b| }
Instance Attribute Summary collapse
-
#directed ⇒ Object
writeonly
Sets the attribute directed.
Instance Method Summary collapse
-
#adjacent_iterator(&block) ⇒ Object
Sets the adjacent_iterator to block, which must be a block of two parameters: .
-
#directed? ⇒ Boolean
Returns the value of @directed.
-
#each_adjacent(v, &block) ⇒ Object
:nodoc:.
-
#each_edge(&block) ⇒ Object
:nodoc:.
-
#each_vertex(&block) ⇒ Object
:nodoc:.
-
#edge_iterator(&block) ⇒ Object
Sets the edge_iterator to block, which must be a block of two parameters: The first parameter is the source of the edges; the second is the target of the edge.
-
#initialize {|_self| ... } ⇒ ImplicitGraph
constructor
Create a new ImplicitGraph, which is empty by default.
-
#vertex_iterator(&block) ⇒ Object
Sets the vertex_iterator to block, which must be a block of one parameter which again is the block called by each_vertex.
Methods included from Graph
#acyclic?, #adjacent_vertices, #bfs_iterator, #bfs_search_tree_from, #condensation_graph, #depth_first_search, #depth_first_visit, #dfs_iterator, #dotty, #each, #each_connected_component, #edge_class, #edges, #edges_filtered_by, #empty?, #eql?, #has_vertex?, #implicit_graph, #num_edges, #out_degree, #print_dotted_on, #reverse, #size, #strongly_connected_components, #to_adjacency, #to_dot_graph, #to_s, #to_undirected, #topsort_iterator, #transitive_closure, #transitive_reduction, #vertices, #vertices_filtered_by, #write_to_graphic_file
Methods included from Enumerable
Constructor Details
#initialize {|_self| ... } ⇒ ImplicitGraph
Create a new ImplicitGraph, which is empty by default. The caller should configure the graph using vertex and neighbor iterators. If the graph is directed, the client should set directed to true. The default value for directed is false.
39 40 41 42 43 44 |
# File 'lib/rgl/implicit.rb', line 39 def initialize @directed = false @vertex_iterator = EMPTY_VERTEX_ITERATOR @adjacent_iterator = EMPTY_NEIGHBOR_ITERATOR yield self if block_given? # Let client overwrite defaults. end |
Instance Attribute Details
#directed=(value) ⇒ Object (writeonly)
Sets the attribute directed
29 30 31 |
# File 'lib/rgl/implicit.rb', line 29 def directed=(value) @directed = value end |
Instance Method Details
#adjacent_iterator(&block) ⇒ Object
Sets the adjacent_iterator to block, which must be a block of two parameters:
The first parameter is the vertex the neighbors of which are to be
traversed.
The second is the block which will be called for each neighbor
of this vertex.
85 86 87 |
# File 'lib/rgl/implicit.rb', line 85 def adjacent_iterator (&block) @adjacent_iterator = block end |
#directed? ⇒ Boolean
Returns the value of @directed.
48 49 50 |
# File 'lib/rgl/implicit.rb', line 48 def directed? @directed end |
#each_adjacent(v, &block) ⇒ Object
:nodoc:
56 57 58 |
# File 'lib/rgl/implicit.rb', line 56 def each_adjacent (v, &block) # :nodoc: @adjacent_iterator.call(v, block) end |
#each_edge(&block) ⇒ Object
:nodoc:
60 61 62 63 64 65 66 |
# File 'lib/rgl/implicit.rb', line 60 def each_edge (&block) # :nodoc: if defined? @edge_iterator @edge_iterator.call(block) else super # use default implementation end end |
#each_vertex(&block) ⇒ Object
:nodoc:
52 53 54 |
# File 'lib/rgl/implicit.rb', line 52 def each_vertex (&block) # :nodoc: @vertex_iterator.call(block) end |
#edge_iterator(&block) ⇒ Object
Sets the edge_iterator to block, which must be a block of two parameters: The first parameter is the source of the edges; the second is the target of the edge.
93 94 95 |
# File 'lib/rgl/implicit.rb', line 93 def edge_iterator (&block) @edge_iterator = block end |
#vertex_iterator(&block) ⇒ Object
Sets the vertex_iterator to block, which must be a block of one parameter which again is the block called by each_vertex.
72 73 74 |
# File 'lib/rgl/implicit.rb', line 72 def vertex_iterator (&block) @vertex_iterator = block end |