MoonTools.Graph/Graph/UndirectedWeightedGraph.cs

19 lines
640 B
C#
Raw Normal View History

2019-10-24 04:29:26 +00:00
namespace MoonTools.Core.Graph
{
public class UndirectedWeightedGraph<TNode, TEdgeData> : DirectedWeightedGraph<TNode, TEdgeData> where TNode : System.IEquatable<TNode>
{
public override void AddEdge(TNode v, TNode u, int weight, TEdgeData edgeData)
{
base.AddEdge(v, u, weight, edgeData);
base.AddEdge(u, v, weight, edgeData);
}
public override void AddEdges(params (TNode, TNode, int, TEdgeData)[] edges)
{
foreach (var edge in edges)
{
AddEdge(edge.Item1, edge.Item2, edge.Item3, edge.Item4);
}
}
}
}