@Override public int getElementCount() { return graph.getEdgeCount(); }
@Override public boolean init(Graph graph) { return graph.getEdgeCount() != 0; }
@Override public int size() { int size = model.getEdgeTypeCount(); return graph.getEdgeCount(0) == 0 ? size - 1 : size; }
@Override public float percentage(Object value) { int count = count(value); return (float) count / graph.getEdgeCount(); }
@Override public int getEdgesCount() { Graph graph = getCurrentGraph(); return graph.getEdgeCount(); }
@Override public Collection getValues() { Object[] labels = model.getEdgeTypeLabels(); ArrayList<Object> col = new ArrayList<>(labels.length); for (Object l : labels) { if (!(l == null && graph.getEdgeCount(0) == 0)) { col.add(l); } } return col; }
public double calculateDensity(Graph graph, boolean isGraphDirected) { double result; double edgesCount = graph.getEdgeCount(); double nodesCount = graph.getNodeCount(); double multiplier = 1; if (!isGraphDirected) { multiplier = 2; } result = (multiplier * edgesCount) / (nodesCount * nodesCount - nodesCount); return result; }
@Override public int count(Object value) { return graph.getEdgeCount(model.getEdgeType(value)); }
public Collection getEdgeTypeLabels() { Graph graph = graphModel.getGraph(); Object[] labels = graphModel.getEdgeTypeLabels(); ArrayList<Object> col = new ArrayList<>(labels.length); for (Object l : labels) { if (graph.getEdgeCount(graphModel.getEdgeType(l)) > 0) { col.add(l); } } return col; }
@Override public boolean init(Graph graph) { if (AttributeUtils.isNodeColumn(column)) { if (graph.getNodeCount() == 0) { return false; } } else if (AttributeUtils.isEdgeColumn(column)) { if (graph.getEdgeCount() == 0) { return false; } } return true; }
@Override public void execute(GraphModel graphModel) { Graph graph = graphModel.getGraphVisible(); selfLoopCount = 0; totalEdgeCount = graph.getEdgeCount(); for (Edge e : graph.getEdges()) { if (e.isSelfLoop()) { selfLoopCount++; } } }
@Override public boolean init(Graph graph) { if (AttributeUtils.isNodeColumn(column)) { if (graph.getNodeCount() == 0) { return false; } } else if (AttributeUtils.isEdgeColumn(column)) { if (graph.getEdgeCount() == 0) { return false; } } return true; }
@Override public boolean init(Graph graph) { if (AttributeUtils.isNodeColumn(column)) { if (graph.getNodeCount() == 0) { return false; } } else if (AttributeUtils.isEdgeColumn(column)) { if (graph.getEdgeCount() == 0) { return false; } } return true; }
@Override public void run() { Graph visibleGraph = model.getGraphVisible(); Graph fullGraph = model.getGraph(); final int nodesFull = fullGraph.getNodeCount(); final int nodesVisible = visibleGraph.getNodeCount(); final int edgesFull = fullGraph.getEdgeCount(); final int edgesVisible = visibleGraph.getEdgeCount(); final GraphType graphType = model.isDirected() ? GraphType.DIRECTED : model.isUndirected() ? GraphType.UNDIRECTED : GraphType.MIXED; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { String visible = NbBundle.getMessage(ContextPanel.class, "ContextPanel.visible"); String nodeText = String.valueOf(nodesVisible); String edgeText = String.valueOf(edgesVisible); if (nodesFull != nodesVisible || edgesFull != edgesVisible) { nodeText += nodesFull > 0 ? " (" + formatter.format(nodesVisible / (double) nodesFull) + " " + visible + ")" : ""; edgeText += edgesFull > 0 ? " (" + formatter.format(edgesVisible / (double) edgesFull) + " " + visible + ")" : ""; } nodeLabel.setText(nodeText); edgeLabel.setText(edgeText); graphTypeLabel.setText(graphType.type); } }); } }
@Override public void loop(GraphView window, Interval interval) { Graph graph = graphModel.getGraph(window); int count = graph.getEdgeCount(); graphModel.getGraphVisible().setAttribute(NB_EDGES, count, interval.getLow()); graphModel.getGraphVisible().setAttribute(NB_EDGES, count, interval.getHigh()); counts.put(interval.getLow(), count); counts.put(interval.getHigh(), count); }
int tasks = graph.getNodeCount() + graph.getEdgeCount(); Progress.start(progress, tasks);
@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; } } }
@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; }