mirror of
				https://github.com/krahets/hello-algo.git
				synced 2025-11-04 06:07:20 +08:00 
			
		
		
		
	Update graph_adjacency_list.java, .cs
This commit is contained in:
		@ -12,7 +12,7 @@ namespace hello_algo.chapter_graph;
 | 
			
		||||
/* 基于邻接表实现的无向图类 */
 | 
			
		||||
class GraphAdjList
 | 
			
		||||
{
 | 
			
		||||
    // 邻接表 adjList 中的元素是 Vertex 对象
 | 
			
		||||
    // 邻接表,key: 顶点,value:该顶点的所有邻接结点
 | 
			
		||||
    Dictionary<Vertex, List<Vertex>> adjList;
 | 
			
		||||
 | 
			
		||||
    /* 构造函数 */
 | 
			
		||||
 | 
			
		||||
@ -4,8 +4,10 @@
 | 
			
		||||
 * Author: zjkung1123 (zjkung1123@gmail.com), krahets (krahets@163.com)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
namespace hello_algo.include;
 | 
			
		||||
 | 
			
		||||
/* 顶点类 */
 | 
			
		||||
class Vertex
 | 
			
		||||
public class Vertex
 | 
			
		||||
{
 | 
			
		||||
    public int Val { get; init; }
 | 
			
		||||
    public Vertex(int val)
 | 
			
		||||
 | 
			
		||||
@ -11,8 +11,7 @@ import include.*;
 | 
			
		||||
 | 
			
		||||
/* 基于邻接表实现的无向图类 */
 | 
			
		||||
class GraphAdjList {
 | 
			
		||||
    // 邻接表,使用哈希表来代替链表,以提升删除边、删除顶点的效率
 | 
			
		||||
    // 请注意,adjList 中的元素是 Vertex 对象
 | 
			
		||||
    // 邻接表,key: 顶点,value:该顶点的所有邻接结点
 | 
			
		||||
    Map<Vertex, List<Vertex>> adjList;
 | 
			
		||||
 | 
			
		||||
    /* 构造方法 */
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user