26 using System.Collections.Generic;
44 private readonly
int nodeCount;
48 this.nodeCount = nodeCount;
51 if (nodeCount < 0)
throw new ArgumentException(
"Invalid node count: " + nodeCount);
52 long arcCount = (long)nodeCount*(nodeCount-1);
54 if (arcCount >
int.MaxValue)
55 throw new ArgumentException(
"Too many nodes: " + nodeCount);
62 return new Node(1L + index);
69 return (
int)(node.
Id - 1);
84 var t = x; x = y; y = t;
87 return GetArcInternal(x, y);
91 private Arc GetArcInternal(
int x,
int y)
93 return new Arc(1L + (
long)y * nodeCount + x);
98 return new Node(1L + (arc.
Id - 1) % nodeCount);
103 return new Node(1L + (arc.
Id - 1) / nodeCount);
113 for (
int i = 0; i < nodeCount; i++)
121 for (
int i = 0; i < nodeCount; i++)
122 for (
int j = 0; j < nodeCount; j++)
123 if (i != j) yield
return GetArcInternal(i, j);
127 for (
int i = 0; i < nodeCount; i++)
128 for (
int j = i+1; j < nodeCount; j++)
129 yield
return GetArcInternal(i, j);
137 if (filter ==
ArcFilter.Edge) yield
break;
139 foreach (var w
in Nodes())
140 if (w != u) yield
return GetArc(w, u);
143 foreach (var w
in Nodes())
144 if (w != u) yield
return GetArc(u, w);
151 if (filter ==
ArcFilter.Edge) yield
break;
164 var result = nodeCount * (nodeCount - 1);
171 if (!
Directed)
return nodeCount - 1;
174 case ArcFilter.All:
return 2 * (nodeCount - 1);
176 default:
return nodeCount - 1;
193 return node.
Id >= 1 && node.
Id <= nodeCount;