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)); }
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); }