mirror of
				https://github.com/krahets/hello-algo.git
				synced 2025-11-04 14:18:20 +08:00 
			
		
		
		
	* Sync zh and zh-hant versions * Update en/README.md * Add a Q&A for chapter of introduction * Update the callout headers * Sync zh ang zh-hant versions * Bug fixes
		
			
				
	
	
		
			25 lines
		
	
	
		
			476 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			476 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
=begin
 | 
						|
File: vertex.rb
 | 
						|
Created Time: 2024-04-25
 | 
						|
Author: Xuan Khoa Tu Nguyen (ngxktuzkai2000@gmail.com)
 | 
						|
=end
 | 
						|
 | 
						|
### 頂點類別 ###
 | 
						|
class Vertex
 | 
						|
  attr_accessor :val
 | 
						|
 | 
						|
  def initialize(val)
 | 
						|
    @val = val
 | 
						|
  end
 | 
						|
end
 | 
						|
 | 
						|
### 輸入值串列 vals ,返回頂點串列 vets ###
 | 
						|
def vals_to_vets(vals)
 | 
						|
  Array.new(vals.length) { |i| Vertex.new(vals[i]) }
 | 
						|
end
 | 
						|
 | 
						|
### 輸入頂點串列 vets, 返回值串列 vals ###
 | 
						|
def vets_to_vals(vets)
 | 
						|
  Array.new(vets.length) { |i| vets[i].val }
 | 
						|
end
 |