示例#1
0
文件: Graph.cs 项目: Premsjce/DJP
        public void AddEdge(GraphEdge graphEdge)
        {
            if (AdjacenceyList[graphEdge.Source] == null)
            {
                AdjacenceyList[graphEdge.Source] = new List <GraphNode>();
            }

            AdjacenceyList[graphEdge.Source].Add(new GraphNode(graphEdge.Destination, graphEdge.Cost));
        }
示例#2
0
文件: Graph.cs 项目: Premsjce/DJP
        public void RemoveEdge(GraphEdge graphEdge)
        {
            if (AdjacenceyList[graphEdge.Source] == null)
            {
                throw new Exception("Such edge does not exists");
            }
            var removalNode = AdjacenceyList[graphEdge.Source].Find((x) => (x.Destination == graphEdge.Destination) && (x.Cost == graphEdge.Cost));

            AdjacenceyList[graphEdge.Source].Remove(removalNode);
        }