You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hello-algo/codes/csharp/utils/Vertex.cs

34 lines
822 B

Add C# code for the chapter Heap and Graph (#324) * add : C# heap ,graph, fix type "sift"=>"shift" * chore: rename "shift" to "sift" * add: heap,graph C# sample code ,fix format * fix md format * fix md intend foramt * fix basic_operation_of_graph.md format * fix md format * fix md format * fix indentation format * chore: fix my_heap.cs test * fix: test and doc typo * fix bug for commit 5eae708 (#317) * Add Zig code blocks. * fix: resolve build error for commit 5eae708 (#318) * Unify the function naming of queue from `offer()` to `push()` * Update TypeScript codes. * Update binary_search_tree * Update graph operations. * Fix code indentation. * Update worst_best_time_complexity, leetcode_two_sum * Update avl_tree * copy zig codes of chapter_array_and_linkedlist and chapter_computatio… (#319) * copy zig codes of chapter_array_and_linkedlist and chapter_computational_complexity to markdown files * Update time_complexity.md --------- Co-authored-by: Yudong Jin <krahets@163.com> * Fix Python code styles. Update hash_map. * chore: fix heap logic * Update graph_adjacency_matrix.cs * Update graph_adjacency_matrix.cs * Update my_heap.cs * fix: heap test * fix naming format * merge markdown * fix markdown format * Update graph_adjacency_list.cs * Update graph_adjacency_matrix.cs * Update PrintUtil.cs * Create Vertex.cs * Update heap.cs --------- Co-authored-by: zjkung1123 <zjkung1123@fugle.tw> Co-authored-by: sjinzh <99076655+sjinzh@users.noreply.github.com> Co-authored-by: Yudong Jin <krahets@163.com> Co-authored-by: nuomi1 <nuomi1@qq.com>
2 years ago
/**
* File: Vertex.cs
Add C# code for the chapter Heap and Graph (#324) * add : C# heap ,graph, fix type "sift"=>"shift" * chore: rename "shift" to "sift" * add: heap,graph C# sample code ,fix format * fix md format * fix md intend foramt * fix basic_operation_of_graph.md format * fix md format * fix md format * fix indentation format * chore: fix my_heap.cs test * fix: test and doc typo * fix bug for commit 5eae708 (#317) * Add Zig code blocks. * fix: resolve build error for commit 5eae708 (#318) * Unify the function naming of queue from `offer()` to `push()` * Update TypeScript codes. * Update binary_search_tree * Update graph operations. * Fix code indentation. * Update worst_best_time_complexity, leetcode_two_sum * Update avl_tree * copy zig codes of chapter_array_and_linkedlist and chapter_computatio… (#319) * copy zig codes of chapter_array_and_linkedlist and chapter_computational_complexity to markdown files * Update time_complexity.md --------- Co-authored-by: Yudong Jin <krahets@163.com> * Fix Python code styles. Update hash_map. * chore: fix heap logic * Update graph_adjacency_matrix.cs * Update graph_adjacency_matrix.cs * Update my_heap.cs * fix: heap test * fix naming format * merge markdown * fix markdown format * Update graph_adjacency_list.cs * Update graph_adjacency_matrix.cs * Update PrintUtil.cs * Create Vertex.cs * Update heap.cs --------- Co-authored-by: zjkung1123 <zjkung1123@fugle.tw> Co-authored-by: sjinzh <99076655+sjinzh@users.noreply.github.com> Co-authored-by: Yudong Jin <krahets@163.com> Co-authored-by: nuomi1 <nuomi1@qq.com>
2 years ago
* Created Time: 2023-02-06
* Author: zjkung1123 (zjkung1123@gmail.com), krahets (krahets@163.com)
*/
namespace hello_algo.utils;
Add C# code for the chapter Heap and Graph (#324) * add : C# heap ,graph, fix type "sift"=>"shift" * chore: rename "shift" to "sift" * add: heap,graph C# sample code ,fix format * fix md format * fix md intend foramt * fix basic_operation_of_graph.md format * fix md format * fix md format * fix indentation format * chore: fix my_heap.cs test * fix: test and doc typo * fix bug for commit 5eae708 (#317) * Add Zig code blocks. * fix: resolve build error for commit 5eae708 (#318) * Unify the function naming of queue from `offer()` to `push()` * Update TypeScript codes. * Update binary_search_tree * Update graph operations. * Fix code indentation. * Update worst_best_time_complexity, leetcode_two_sum * Update avl_tree * copy zig codes of chapter_array_and_linkedlist and chapter_computatio… (#319) * copy zig codes of chapter_array_and_linkedlist and chapter_computational_complexity to markdown files * Update time_complexity.md --------- Co-authored-by: Yudong Jin <krahets@163.com> * Fix Python code styles. Update hash_map. * chore: fix heap logic * Update graph_adjacency_matrix.cs * Update graph_adjacency_matrix.cs * Update my_heap.cs * fix: heap test * fix naming format * merge markdown * fix markdown format * Update graph_adjacency_list.cs * Update graph_adjacency_matrix.cs * Update PrintUtil.cs * Create Vertex.cs * Update heap.cs --------- Co-authored-by: zjkung1123 <zjkung1123@fugle.tw> Co-authored-by: sjinzh <99076655+sjinzh@users.noreply.github.com> Co-authored-by: Yudong Jin <krahets@163.com> Co-authored-by: nuomi1 <nuomi1@qq.com>
2 years ago
/* 顶点类 */
public class Vertex {
public int val;
public Vertex(int val) {
this.val = val;
Add C# code for the chapter Heap and Graph (#324) * add : C# heap ,graph, fix type "sift"=>"shift" * chore: rename "shift" to "sift" * add: heap,graph C# sample code ,fix format * fix md format * fix md intend foramt * fix basic_operation_of_graph.md format * fix md format * fix md format * fix indentation format * chore: fix my_heap.cs test * fix: test and doc typo * fix bug for commit 5eae708 (#317) * Add Zig code blocks. * fix: resolve build error for commit 5eae708 (#318) * Unify the function naming of queue from `offer()` to `push()` * Update TypeScript codes. * Update binary_search_tree * Update graph operations. * Fix code indentation. * Update worst_best_time_complexity, leetcode_two_sum * Update avl_tree * copy zig codes of chapter_array_and_linkedlist and chapter_computatio… (#319) * copy zig codes of chapter_array_and_linkedlist and chapter_computational_complexity to markdown files * Update time_complexity.md --------- Co-authored-by: Yudong Jin <krahets@163.com> * Fix Python code styles. Update hash_map. * chore: fix heap logic * Update graph_adjacency_matrix.cs * Update graph_adjacency_matrix.cs * Update my_heap.cs * fix: heap test * fix naming format * merge markdown * fix markdown format * Update graph_adjacency_list.cs * Update graph_adjacency_matrix.cs * Update PrintUtil.cs * Create Vertex.cs * Update heap.cs --------- Co-authored-by: zjkung1123 <zjkung1123@fugle.tw> Co-authored-by: sjinzh <99076655+sjinzh@users.noreply.github.com> Co-authored-by: Yudong Jin <krahets@163.com> Co-authored-by: nuomi1 <nuomi1@qq.com>
2 years ago
}
/* 输入值列表 vals ,返回顶点列表 vets */
public static Vertex[] ValsToVets(int[] vals) {
Add C# code for the chapter Heap and Graph (#324) * add : C# heap ,graph, fix type "sift"=>"shift" * chore: rename "shift" to "sift" * add: heap,graph C# sample code ,fix format * fix md format * fix md intend foramt * fix basic_operation_of_graph.md format * fix md format * fix md format * fix indentation format * chore: fix my_heap.cs test * fix: test and doc typo * fix bug for commit 5eae708 (#317) * Add Zig code blocks. * fix: resolve build error for commit 5eae708 (#318) * Unify the function naming of queue from `offer()` to `push()` * Update TypeScript codes. * Update binary_search_tree * Update graph operations. * Fix code indentation. * Update worst_best_time_complexity, leetcode_two_sum * Update avl_tree * copy zig codes of chapter_array_and_linkedlist and chapter_computatio… (#319) * copy zig codes of chapter_array_and_linkedlist and chapter_computational_complexity to markdown files * Update time_complexity.md --------- Co-authored-by: Yudong Jin <krahets@163.com> * Fix Python code styles. Update hash_map. * chore: fix heap logic * Update graph_adjacency_matrix.cs * Update graph_adjacency_matrix.cs * Update my_heap.cs * fix: heap test * fix naming format * merge markdown * fix markdown format * Update graph_adjacency_list.cs * Update graph_adjacency_matrix.cs * Update PrintUtil.cs * Create Vertex.cs * Update heap.cs --------- Co-authored-by: zjkung1123 <zjkung1123@fugle.tw> Co-authored-by: sjinzh <99076655+sjinzh@users.noreply.github.com> Co-authored-by: Yudong Jin <krahets@163.com> Co-authored-by: nuomi1 <nuomi1@qq.com>
2 years ago
Vertex[] vets = new Vertex[vals.Length];
for (int i = 0; i < vals.Length; i++) {
Add C# code for the chapter Heap and Graph (#324) * add : C# heap ,graph, fix type "sift"=>"shift" * chore: rename "shift" to "sift" * add: heap,graph C# sample code ,fix format * fix md format * fix md intend foramt * fix basic_operation_of_graph.md format * fix md format * fix md format * fix indentation format * chore: fix my_heap.cs test * fix: test and doc typo * fix bug for commit 5eae708 (#317) * Add Zig code blocks. * fix: resolve build error for commit 5eae708 (#318) * Unify the function naming of queue from `offer()` to `push()` * Update TypeScript codes. * Update binary_search_tree * Update graph operations. * Fix code indentation. * Update worst_best_time_complexity, leetcode_two_sum * Update avl_tree * copy zig codes of chapter_array_and_linkedlist and chapter_computatio… (#319) * copy zig codes of chapter_array_and_linkedlist and chapter_computational_complexity to markdown files * Update time_complexity.md --------- Co-authored-by: Yudong Jin <krahets@163.com> * Fix Python code styles. Update hash_map. * chore: fix heap logic * Update graph_adjacency_matrix.cs * Update graph_adjacency_matrix.cs * Update my_heap.cs * fix: heap test * fix naming format * merge markdown * fix markdown format * Update graph_adjacency_list.cs * Update graph_adjacency_matrix.cs * Update PrintUtil.cs * Create Vertex.cs * Update heap.cs --------- Co-authored-by: zjkung1123 <zjkung1123@fugle.tw> Co-authored-by: sjinzh <99076655+sjinzh@users.noreply.github.com> Co-authored-by: Yudong Jin <krahets@163.com> Co-authored-by: nuomi1 <nuomi1@qq.com>
2 years ago
vets[i] = new Vertex(vals[i]);
}
return vets;
}
/* 输入顶点列表 vets ,返回值列表 vals */
public static List<int> VetsToVals(List<Vertex> vets) {
List<int> vals = new();
foreach (Vertex vet in vets) {
vals.Add(vet.val);
Add C# code for the chapter Heap and Graph (#324) * add : C# heap ,graph, fix type "sift"=>"shift" * chore: rename "shift" to "sift" * add: heap,graph C# sample code ,fix format * fix md format * fix md intend foramt * fix basic_operation_of_graph.md format * fix md format * fix md format * fix indentation format * chore: fix my_heap.cs test * fix: test and doc typo * fix bug for commit 5eae708 (#317) * Add Zig code blocks. * fix: resolve build error for commit 5eae708 (#318) * Unify the function naming of queue from `offer()` to `push()` * Update TypeScript codes. * Update binary_search_tree * Update graph operations. * Fix code indentation. * Update worst_best_time_complexity, leetcode_two_sum * Update avl_tree * copy zig codes of chapter_array_and_linkedlist and chapter_computatio… (#319) * copy zig codes of chapter_array_and_linkedlist and chapter_computational_complexity to markdown files * Update time_complexity.md --------- Co-authored-by: Yudong Jin <krahets@163.com> * Fix Python code styles. Update hash_map. * chore: fix heap logic * Update graph_adjacency_matrix.cs * Update graph_adjacency_matrix.cs * Update my_heap.cs * fix: heap test * fix naming format * merge markdown * fix markdown format * Update graph_adjacency_list.cs * Update graph_adjacency_matrix.cs * Update PrintUtil.cs * Create Vertex.cs * Update heap.cs --------- Co-authored-by: zjkung1123 <zjkung1123@fugle.tw> Co-authored-by: sjinzh <99076655+sjinzh@users.noreply.github.com> Co-authored-by: Yudong Jin <krahets@163.com> Co-authored-by: nuomi1 <nuomi1@qq.com>
2 years ago
}
return vals;
}
}