protected boolean relax(Edge edge) { Node source = edge.getSource(); Node target = edge.getTarget(); double distSource = distances.get(source); double distTarget = distances.get(target); double weight = edgeWeight(edge); double sourceWeight = distSource + weight; if (sourceWeight < distTarget) { distances.put(target, sourceWeight); maxDistance = Math.max(maxDistance, sourceWeight); return true; } else { return false; } }
@Override public boolean evaluate(Graph graph, Edge edge) { Object srcValue = partition.getValue(edge.getSource(), graph); Object destValue = partition.getValue(edge.getTarget(), graph); srcValue = srcValue == null ? NULL : srcValue; destValue = destValue == null ? NULL : destValue; return parts.contains(srcValue) && parts.contains(destValue) && srcValue.equals(destValue); }
@Override public boolean evaluate(Graph graph, Edge edge) { Object srcValue = partition.getValue(edge.getSource(), graph); Object destValue = partition.getValue(edge.getTarget(), graph); srcValue = srcValue == null ? NULL : srcValue; destValue = destValue == null ? NULL : destValue; return parts.contains(srcValue) && parts.contains(destValue) && !srcValue.equals(destValue); } }
@Override public void execute() { Node[] nodes=new Node[]{clickedEdge.getSource(),clickedEdge.getTarget()}; DataTablesController dtc=Lookup.getDefault().lookup(DataTablesController.class); dtc.setNodeTableSelection(nodes); dtc.selectNodesTable(); }
public float getAverageEdgeLength(Graph graph) { float edgeLength = 0; int count = 1; for (Edge e : graph.getEdges()) { edgeLength += ForceVectorUtils.distance( e.getSource(), e.getTarget()); count++; } return edgeLength / count; }
@Override public void execute() { Node source = clickedEdge.getSource(); VizController.getInstance().getSelectionManager().centerOnNode(source); }
@Override public void deleteEdgeWithNodes(Edge edge, boolean deleteSource, boolean deleteTarget) { if (deleteSource) { deleteNode(edge.getSource()); } if (deleteTarget) { deleteNode(edge.getTarget()); } removeEdge(edge, getCurrentGraph());//If no node is deleted, we need to remove the edge. }
private EdgeImpl verifyEdge(Edge edge) { EdgeImpl edgeImpl = (EdgeImpl) edge; verifyElement(edgeImpl); EdgeImpl existingEdge = store.getEdge(edge.getId()); if (existingEdge != null && (!existingEdge.getSource().getId().equals(edge.getSource().getId()) || !existingEdge .getTarget().getId().equals(edge.getTarget().getId()))) { throw new RuntimeException("An edge with a similar id '" + edge.getId() + "' already exists"); } return edgeImpl; }
private EdgeImpl verifyEdge(Edge edge) { EdgeImpl edgeImpl = (EdgeImpl) edge; verifyElement(edgeImpl); EdgeImpl existingEdge = store.getEdge(edge.getId()); if (existingEdge != null && (!existingEdge.getSource().getId().equals(edge.getSource().getId()) || !existingEdge .getTarget().getId().equals(edge.getTarget().getId()))) { throw new RuntimeException("An edge with a similar id '" + edge.getId() + "' already exists"); } return edgeImpl; }
@Override public void execute() { VizController.getInstance().getSelectionManager().selectEdges(edges); VizController.getInstance().getSelectionManager().centerOnNode(clickedEdge.getSource()); }
public Helper(final Item item) { node = ((Edge) item.getSource()).getSource(); Item nodeSource = item.getData(SOURCE); x = nodeSource.getData(NodeItem.X); y = nodeSource.getData(NodeItem.Y); Float size = nodeSource.getData(NodeItem.SIZE); v1 = new Vector(x, y); v1.add(size, -size); v2 = new Vector(x, y); v2.add(size, size); } }
@Override public Graph filter(Subgraph[] graphs) { if (graphs.length > 1) { throw new IllegalArgumentException("Not Filter accepts a single graph in parameter"); } Graph graph = graphs[0]; Graph mainGraph = graph.getView().getGraphModel().getGraph(); for (Edge e : mainGraph.getEdges()) { Node source = e.getSource(); Node target = e.getTarget(); if (graph.contains(source) && graph.contains(target)) { Edge edgeInGraph = graph.getEdge(source, target, e.getType()); if (edgeInGraph == null) { //The edge is not in graph graph.addEdge(e); } else { //The edge is in the graph graph.removeEdge(edgeInGraph); } } } return graph; }