Class: Middleman::Dependencies::DirectedAdjacencyGraph

Inherits:
RGL::DirectedAdjacencyGraph
  • Object
show all
Defined in:
middleman-core/lib/middleman-core/dependencies/graph.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ DirectedAdjacencyGraph

Returns a new instance of DirectedAdjacencyGraph


10
11
12
13
14
# File 'middleman-core/lib/middleman-core/dependencies/graph.rb', line 10

def initialize(*args)
  super

  @vertices_by_key = {}
end

Instance Method Details

#add_edge(u, v) ⇒ Object


24
25
26
# File 'middleman-core/lib/middleman-core/dependencies/graph.rb', line 24

def add_edge(u, v)
  super(merged_vertex_or_new(u), merged_vertex_or_new(v))
end

#add_vertex(v) ⇒ Object


16
17
18
19
20
21
22
# File 'middleman-core/lib/middleman-core/dependencies/graph.rb', line 16

def add_vertex(v)
  mv = merged_vertex_or_new(v)

  @vertices_by_key[mv.key] = mv

  super(mv)
end

#find_vertex_by_key(key) ⇒ Object


38
39
40
# File 'middleman-core/lib/middleman-core/dependencies/graph.rb', line 38

def find_vertex_by_key(key)
  @vertices_by_key[key]
end

#remove_vertex(vertex) ⇒ Object


28
29
30
31
32
33
34
35
36
# File 'middleman-core/lib/middleman-core/dependencies/graph.rb', line 28

def remove_vertex(vertex)
  each_adjacent(vertex) do |v|
    remove_vertex(v) unless v == vertex
  end

  @vertices_by_key.delete(vertex.key)

  super(vertex)
end