Пример #1
0
 public static int degree(Graph G, int v) {
   int degree = 0;
   for (int w : G.adj(v)) degree++;
   return degree;
 }
Пример #2
0
 public static int numberOfSelfLoops(Graph G) {
   int count = 0;
   for (int v = 0; v < G.V(); v++) for (int w : G.adj(v)) if (v == w) count++;
   return count / 2;
 }