26 using System.Collections.Generic;
40 private DisjointSet<Node> nodeGroups;
41 private int unionCount;
46 nodeGroups =
new DisjointSet<Node>();
62 return nodeGroups.WhereIs(n).Representative;
70 return nodeGroups.Elements(nodeGroups.WhereIs(n));
79 var x = nodeGroups.WhereIs(u);
80 var y = nodeGroups.WhereIs(v);
81 if (x.Equals(y))
return x.Representative;
83 return nodeGroups.Union(x, y).Representative;
91 return Merge(graph.
U(arc), graph.
V(arc));
111 foreach (var node
in graph.
Nodes())
117 return graph.
Arcs(filter);
124 foreach (var arc
in graph.
Arcs(node, filter))
126 bool loop = (
U(arc) ==
V(arc));
128 if (!loop || !(filter ==
ArcFilter.All ||
IsEdge(arc)) || graph.
U(arc) == node)
136 foreach (var arc
in Arcs(u, filter))
137 if (this.Other(arc, u) == v) yield
return arc;
152 return Arcs(u, filter).Count();
157 return Arcs(u, v, filter).Count();