Module: Plexus::DirectedGraphBuilder

Includes:
GraphBuilder
Included in:
Digraph, DirectedGraph, DirectedPseudoGraphBuilder
Defined in:
lib/plexus/directed_graph.rb,
lib/plexus/directed_graph/distance.rb,
lib/plexus/directed_graph/algorithms.rb

Overview

Digraph is a directed graph which is a finite set of vertices and a finite set of edges connecting vertices. It cannot contain parallel edges going from the same source vertex to the same target. It also cannot contain loops, i.e. edges that go have the same vertex for source and target.

DirectedPseudoGraph is a class that allows for parallel edges, and DirectedMultiGraph is a class that allows for parallel edges and loops as well.

Defined Under Namespace

Modules: Algorithms, ClassMethods, Distance

Instance Method Summary collapse

Methods included from GraphBuilder

#+, #-, #<<, #add_edge, #add_edges, #add_edges!, #add_vertex, #add_vertices, #add_vertices!, #adjacent, #adjacent?, #closed_pth_neighborhood, #complement, #connected?, #degree, #each, #edge?, #empty?, #eql?, #from_array, #in_degree, #include?, #induced_subgraph, #inspect, #max_degree, #max_in_degree, #max_out_degree, #merge, #min_degree, #min_in_degree, #min_out_degree, #neighborhood, #num_edges, #open_pth_neighborhood, #out_degree, #regular?, #remove_edge, #remove_edges, #remove_edges!, #remove_vertex, #remove_vertices, #remove_vertices!, #set_neighborhood, #size, #vertex?

Methods included from Dot

#dotty, #to_dot, #to_dot_graph, #write_to_graphic_file

Methods included from Labels

#[], #[]=, #clear_all_labels, #delete_label, #edge_label, #edge_label_delete, #edge_label_set, #vertex_label, #vertex_label_delete, #vertex_label_set

Instance Method Details

#initialize(*params) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/plexus/directed_graph.rb', line 25

def initialize(*params)
  # FIXME/TODO: setting args to the hash or {} while getting rid
  # on the previous parameters prevents from passing another
  # graph to the initializer, so you cannot do things like:
  # UndirectedGraph.new(Digraph[1,2, 2,3, 2,4, 4,5, 6,4, 1,6])
  # As args must be a hash, if we're to allow such syntax,
  # we should provide a way to handle the graph as a hash
  # member.
  args = (params.pop if params.last.kind_of? Hash) || {}
  args[:algorithmic_category] = DirectedGraphBuilder::Algorithms
  super *(params << args)
end