protected double edgeWeight(Edge edge) { return edge.getWeight(); }
@Override public Number getValue(Element element, Graph gr) { return ((Edge) element).getWeight(gr.getView()); }
@Override public Number[] getValues(Graph graph) { List<Number> values = new ArrayList<>(); for (Edge e : graph.getEdges()) { double weight = e.getWeight(graph.getView()); values.add(weight); } return values.toArray(new Number[0]); }
@Override public boolean evaluate(Graph graph, Edge edge) { double weight = edge.getWeight(graph.getView()); return range.isInRange(weight); }
private double finalQ(int[] struct, double[] degrees, Graph graph, CommunityStructure theStructure, double totalWeight, double usedResolution, boolean weighted) { double res = 0; double[] internal = new double[degrees.length]; for (Node n : graph.getNodes()) { int n_index = theStructure.map.get(n); for (Edge edge : graph.getEdges(n)) { Node neighbor = graph.getOpposite(n, edge); if (n == neighbor) { continue; } int neigh_index = theStructure.map.get(neighbor); if (struct[neigh_index] == struct[n_index]) { if (weighted) { internal[struct[neigh_index]] += edge.getWeight(graph.getView()); } else { internal[struct[neigh_index]]++; } } } } for (int i = 0; i < degrees.length; i++) { internal[i] /= 2.0; res += usedResolution * (internal[i] / totalWeight) - Math.pow(degrees[i] / (2 * totalWeight), 2);//HERE } return res; }
@Override protected void refresh() { if (graph.getEdgeCount() > 0) { double minV = Double.MAX_VALUE; double maxV = Double.MIN_VALUE; for (Edge e : graph.getEdges()) { if (e.hasDynamicWeight()) { TimeMap timeMap = (TimeMap) e.getAttribute("weight"); if (timeMap != null) { Double numMin = (Double) timeMap.get(graph.getView().getTimeInterval(), Estimator.MIN); Double numMax = (Double) timeMap.get(graph.getView().getTimeInterval(), Estimator.MAX); minV = Math.min(numMin, minV); maxV = Math.max(numMax, maxV); } } else { minV = Math.min(e.getWeight(), minV); maxV = Math.max(e.getWeight(), maxV); } } min = minV; max = maxV; } } }
private void setInitialValues(Graph graph, Map<Node, Integer> indicies, double[] pagerankValues, double[] weights, boolean directed, boolean useWeights) { final int N = graph.getNodeCount(); for (Node s : graph.getNodes()) { final int index = indicies.get(s); pagerankValues[index] = 1.0 / N; if (useWeights) { double sum = 0; EdgeIterable eIter; if (directed) { eIter = ((DirectedGraph) graph).getOutEdges(s); } else { eIter = ((UndirectedGraph) graph).getEdges(s); } for (Edge edge : eIter) { if(!edge.isSelfLoop()){ sum += edge.getWeight(); } } weights[index] = sum; } } }
for (Edge edge : graph.getEdges(node, neighbor, edgeType)) { if (useWeight) { weight += edge.getWeight(graph.getView()); } else { weight += 1;
String sourceId = e.getSource().getId().toString(); String targetId = e.getTarget().getId().toString(); String weight = String.valueOf(e.getWeight()); statement.executeUpdate("insert into edges values('" + sourceId + "', '" + targetId + "', '" + weight + "')"); if (cancel) {
if (!edge.isSelfLoop()) { Node neighbor = graph.getOpposite(node, edge); inWeightPerNeighbor.addTo(neighbor, edge.getWeight());
@Override public Item[] getItems(Graph graph) { EdgeItem[] items = new EdgeItem[graph.getEdgeCount()]; int i = 0; for (Edge e : graph.getEdges()) { EdgeItem item = new EdgeItem(e); item.setData(EdgeItem.WEIGHT, e.getWeight(graph.getView())); item.setData(EdgeItem.DIRECTED, e.isDirected()); if (graph.isDirected(e)) { item.setData(EdgeItem.MUTUAL, ((DirectedGraph) graph).getMutualEdge(e) != null); } item.setData(EdgeItem.SELF_LOOP, e.isSelfLoop()); item.setData(EdgeItem.COLOR, e.alpha() == 0 ? null : e.getColor()); items[i++] = item; } return items; }
model = edges[id]; float w = (float) edge.getWeight(graphView); model.setWeight(w); minWeight = Math.min(w, minWeight);