2 using System.Collections.Generic;
5 using System.Threading.Tasks;
33 private readonly Dictionary<Node, Arc> matchedArc;
34 private readonly HashSet<Arc> arcs;
35 private int edgeCount;
41 matchedArc =
new Dictionary<Node, Arc>();
42 arcs =
new HashSet<Arc>();
60 if (enabled == arcs.Contains(arc))
return;
65 throw new ArgumentException(
"Matchings cannot have loop arcs.");
66 if (matchedArc.ContainsKey(u))
67 throw new ArgumentException(
"Node is already matched: " + u);
68 if (matchedArc.ContainsKey(v))
69 throw new ArgumentException(
"Node is already matched: " + v);
87 return matchedArc.TryGetValue(node, out arc) ? arc :
Arc.
Invalid;
107 return matchedArc.Keys;
112 if (filter ==
ArcFilter.All)
return arcs;
113 if (edgeCount == 0)
return Enumerable.Empty<
Arc>();
114 return arcs.Where(arc =>
IsEdge(arc));
121 (filter ==
ArcFilter.Forward &&
U(arc) == u) ||
122 (filter ==
ArcFilter.Backward &&
V(arc) == u));
128 if (arc !=
Arc.
Invalid && YieldArc(u, filter, arc)) yield
return arc;
142 return matchedArc.Count;
147 return filter ==
ArcFilter.All ? arcs.Count : edgeCount;
153 return arc !=
Arc.
Invalid && YieldArc(u, filter, arc) ? 1 : 0;
168 return Graph.
HasNode(node) && matchedArc.ContainsKey(node);