MoonTools.Graph/Graph/UndirectedWeightedGraph.cs

19 lines
674 B
C#
Raw Normal View History

2019-10-24 04:29:26 +00:00
namespace MoonTools.Core.Graph
{
2019-10-24 08:10:49 +00:00
public class UndirectedWeightedGraph<TNode, TEdgeData> : DirectedWeightedGraph<TNode, TEdgeData>, IWeightedGraph<TNode, TEdgeData> where TNode : System.IEquatable<TNode>
2019-10-24 04:29:26 +00:00
{
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);
}
}
}
}