Class: RGL::ImplicitGraph

Inherits:
Object
  • Object
show all
Includes:
Graph
Defined in:
lib/laser/third_party/rgl/implicit.rb

Constant Summary

EMPTY_VERTEX_ITERATOR =
proc { |b|    }
EMPTY_NEIGHBOR_ITERATOR =
proc { |x, b| }

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from Graph

#acyclic?, #adjacent_vertices, #bfs_iterator, #bfs_search_tree_from, #build_dfst, #condensation_graph, #depth_first_search, #depth_first_spanning_tree, #depth_first_visit, #dfs_iterator, #dominance_frontier, #dominator_tree, #dotty, #each, #each_connected_component, #edge_class, #edges, #edges_filtered_by, #empty?, #eql?, #has_vertex?, #implicit_graph, #iterated_dominance_frontier, #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

#all?, #any?, #chunk, #collect, #collect_concat, #count, #cycle, #detect, #drop, #drop_while, #each_cons, #each_entry, #each_slice, #each_with_index, #each_with_object, #entries, #find_index, #first, #flat_map, #grep, #group_by, #include?, #inject, #map, #max, #max_by, #min, #min_by, #minmax, #minmax_by, #none?, #one?, #partition, #reject, #reverse_each, #select, #slice_before, #sort, #sort_by, #take, #take_while, #to_a, #to_set, #zip

Constructor Details

- (ImplicitGraph) initialize {|_self| ... }

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.

Yields:

  • (_self)

Yield Parameters:



39
40
41
42
43
44
# File 'lib/laser/third_party/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

- (Object) directed=(value) (writeonly)

Sets the attribute directed

Parameters:

  • value

    the value to set the attribute directed to.



29
30
31
# File 'lib/laser/third_party/rgl/implicit.rb', line 29

def directed=(value)
  @directed = value
end

Instance Method Details

- (Object) adjacent_iterator(&block)

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/laser/third_party/rgl/implicit.rb', line 85

def adjacent_iterator (&block)
  @adjacent_iterator = block
end

- (Boolean) directed?

Returns the value of @directed.

Returns:

  • (Boolean)


48
49
50
# File 'lib/laser/third_party/rgl/implicit.rb', line 48

def directed?
  @directed
end

- (Object) each_adjacent(v, &block)

:nodoc:



56
57
58
# File 'lib/laser/third_party/rgl/implicit.rb', line 56

def each_adjacent (v, &block)		# :nodoc:
  @adjacent_iterator.call(v, block)
end

- (Object) each_edge(&block)

:nodoc:



60
61
62
63
64
65
66
# File 'lib/laser/third_party/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

- (Object) each_vertex(&block)

:nodoc:



52
53
54
# File 'lib/laser/third_party/rgl/implicit.rb', line 52

def each_vertex (&block)			# :nodoc:
  @vertex_iterator.call(block)
end

- (Object) edge_iterator(&block)

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/laser/third_party/rgl/implicit.rb', line 93

def edge_iterator (&block)
  @edge_iterator = block
end

- (Object) vertex_iterator(&block)

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/laser/third_party/rgl/implicit.rb', line 72

def vertex_iterator (&block)
  @vertex_iterator = block
end