/** * @param graph * @param weighted if true, the edges will be weighted, otherwise all will have default value (1.0) * @param minWeight minimum edge weight if weighted * @param maxWeight maximum edge weight if weighted * @return a generator function */ public static mxGeneratorFunction getGeneratorFunction(mxGraph graph, boolean weighted, double minWeight, double maxWeight) { if (weighted) { return new mxGeneratorRandomFunction(minWeight, maxWeight, 2); } else { return null; } };
public mxGeneratorRandomFunction(double minWeight, double maxWeight, int roundToDecimals) { setWeightRange(minWeight, maxWeight); setRoundToDecimals(roundToDecimals); };
public double getCost(mxCellState state) { Double edgeWeight = null; edgeWeight = Math.random() * (maxWeight - minWeight) + minWeight; edgeWeight = (double) Math.round(edgeWeight * Math.pow(10, getRoundToDecimals())) / Math.pow(10, getRoundToDecimals()); return edgeWeight; };
public double getCost(mxCellState state) { Double edgeWeight = null; edgeWeight = Math.random() * (maxWeight - minWeight) + minWeight; edgeWeight = (double) Math.round(edgeWeight * Math.pow(10, getRoundToDecimals())) / Math.pow(10, getRoundToDecimals()); return edgeWeight; };
public mxGeneratorRandomFunction(double minWeight, double maxWeight, int roundToDecimals) { setWeightRange(minWeight, maxWeight); setRoundToDecimals(roundToDecimals); };
/** * @param graph * @param weighted if true, the edges will be weighted, otherwise all will have default value (1.0) * @param minWeight minimum edge weight if weighted * @param maxWeight maximum edge weight if weighted * @return a generator function */ public static mxGeneratorFunction getGeneratorFunction(mxGraph graph, boolean weighted, double minWeight, double maxWeight) { if (weighted) { return new mxGeneratorRandomFunction(minWeight, maxWeight, 2); } else { return null; } };