Author: vive
Date: 2007-07-12 20:42:25 +0000 (Thu, 12 Jul 2007)
New Revision: 14053

Modified:
   trunk/apps/load-balancing-sims/phase7/sim/SimpleGraph.java
Log:
New generation of directed/undirected


Modified: trunk/apps/load-balancing-sims/phase7/sim/SimpleGraph.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/SimpleGraph.java  2007-07-12 
20:40:57 UTC (rev 14052)
+++ trunk/apps/load-balancing-sims/phase7/sim/SimpleGraph.java  2007-07-12 
20:42:25 UTC (rev 14053)
@@ -25,9 +25,11 @@
      * @avgdeg: average degree of nodes
      * @directed: if to have directed edges
      * @local: if to have local edges (to nearest-neighbors in the lattice)
+     * @inconst: if to have a constant number of indegree edges (when using 
directed edges),
+     *           else use constant outdegree
      */

-    public void CreateKleinbergGraph(double avgdeg, boolean directed, boolean 
local) {
+    public void CreateKleinbergGraph(double avgdeg, boolean directed, boolean 
local, boolean inconst) {

        double degree;
        if(directed) {
@@ -45,6 +47,8 @@
            }
        }

+       System.err.println("Giving each node " + degree + " shortcuts" + (local 
? " and nearest-neighbor connections " : "") + " (average degree="+ (local ? 
(avgdeg+2) : avgdeg)  +")");
+       
        for(int i=0; i<nodes.length; i++) {
            SimpleNode src = nodes[i];

@@ -74,9 +78,16 @@
                    SimpleNode dst = nodes[destpos];

                    if (directed) {
-                       if (!src.hasNeighbor(dst)) {
-                           found = true;
-                           src.connect(dst);
+                       if (inconst) {
+                           if (!dst.hasNeighbor(src)) {
+                               found = true;
+                               dst.connect(src);
+                           }
+                       } else {
+                           if (!src.hasNeighbor(dst)) {
+                               found = true;
+                               src.connect(dst);
+                           }
                        }
                    } else {
                        if (!src.hasNeighbor(dst) && !dst.hasNeighbor(src)) {


Reply via email to