コード例 #1
0
ファイル: Graph.cs プロジェクト: satish80/Algorithms
        public void AddEdge(int vertex, int weight)
        {
            if (AdjList.ContainsKey(vertex))
            {
                AdjList[vertex].Add(weight);
            }
            else
            {
                var list = new List <int>
                {
                    weight
                };
                AdjList.Add(vertex, list);
            }

            if (AdjList.ContainsKey(weight))
            {
                AdjList[weight].Add(vertex);
            }
            else
            {
                var list = new List <int>
                {
                    vertex
                };
                AdjList.Add(weight, list);
            }
        }
コード例 #2
0
        public void AddNode(NodeD vertices)
        {
            LinkedList <DEdge> neighbor = new LinkedList <DEdge>();

            AdjList.Add(vertices, neighbor);
            Size = 1 + Size;
        }