예제 #1
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;
 }
예제 #2
0
 public static int maxDegree(Graph G) {
   int max = 0;
   for (int v = 0; v < G.V(); v++) if (degree(G, v) > max) max = degree(G, v);
   return max;
 }
예제 #3
0
 public static int avgDegree(Graph G) {
   return 2 * G.E() / G.V();
 }