Class: DS::Digraph

Inherits:
Graph
  • Object
show all
Defined in:
lib/ds/graphs/digraph.rb

Constant Summary

Constants inherited from Graph

Graph::Infinity

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Graph

#add, #add_edges, #bfs, #degree, #each_edge, #each_vertex, #edge?, #edge_size, #get_edge, #initialize, #neighbors, #remove, #vertex_size

Constructor Details

This class inherits a constructor from DS::Graph

Class Method Details

.create(args) ⇒ Object



4
5
6
# File 'lib/ds/graphs/digraph.rb', line 4

def self.create(args)
  new(args,:matrix)
end

Instance Method Details

#in_degree(x) ⇒ Object

Returns number of incoming edges to given vertex.



10
11
12
# File 'lib/ds/graphs/digraph.rb', line 10

def in_degree x
  @g.degree x, :in
end

#out_degree(x) ⇒ Object

Returns number of outcoming edges to given vertex.



15
16
17
# File 'lib/ds/graphs/digraph.rb', line 15

def out_degree x
  @g.degree x, :out
end