mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-27 01:06:28 +08:00
f0b092fec4
* 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 commit5eae708
(#317) * Add Zig code blocks. * fix: resolve build error for commit5eae708
(#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>
37 lines
847 B
Java
37 lines
847 B
Java
/**
|
|
* File: graph_adjacency_list.cs
|
|
* Created Time: 2023-02-06
|
|
* Author: zjkung1123 (zjkung1123@gmail.com), krahets (krahets@163.com)
|
|
*/
|
|
|
|
/* 顶点类 */
|
|
class Vertex
|
|
{
|
|
public int Val { get; init; }
|
|
public Vertex(int val)
|
|
{
|
|
Val = val;
|
|
}
|
|
|
|
/* 输入值列表 vals ,返回顶点列表 vets */
|
|
public static Vertex[] valsToVets(int[] vals)
|
|
{
|
|
Vertex[] vets = new Vertex[vals.Length];
|
|
for (int i = 0; i < vals.Length; i++)
|
|
{
|
|
vets[i] = new Vertex(vals[i]);
|
|
}
|
|
return vets;
|
|
}
|
|
|
|
/* 输入顶点列表 vets ,返回值列表 vals */
|
|
public static List<int> vetsToVals(List<Vertex> vets)
|
|
{
|
|
List<int> vals = new List<int>();
|
|
foreach (Vertex vet in vets)
|
|
{
|
|
vals.Add(vet.Val);
|
|
}
|
|
return vals;
|
|
}
|
|
}
|