/** * Delete attributes used by this algorithm in nodes of the graph */ public void cleanNodes(){ cleanElement(graph.getEachNode()); }
/** * Delete attributes used by this algorithm in nodes of the graph */ public void cleanNodes(){ cleanElement(graph.getEachNode()); }
public void compute() { data.clear(); index = 0; S.clear(); for (Node v : graph.getEachNode()) { if (!data.containsKey(v)) strongConnect(v); } }
public void compute() { data.clear(); index = 0; S.clear(); for (Node v : graph.getEachNode()) { if (!data.containsKey(v)) strongConnect(v); } }
/** * calculates the source nodes * @return set of source nodes */ private Set<Node> calculateSourceNodes() { Set<Node> aSourceNodeSet = new HashSet<>(); for (Node aNode : graph.getEachNode()) { if (aNode.getInDegree() == 0) { aSourceNodeSet.add(aNode); } } if (aSourceNodeSet.isEmpty()) { throw new GraphHasCycleException(); } return aSourceNodeSet; }
SynchronizedGraph(Graph g) { super(g); elementLock = new ReentrantLock(); synchronizedNodes = new HashMap<String, Node>(); synchronizedEdges = new HashMap<String, Edge>(); for (Node n : g.getEachNode()) synchronizedNodes.put(n.getId(), new SynchronizedNode(this, n)); for (Edge e : g.getEachEdge()) synchronizedEdges.put(e.getId(), new SynchronizedEdge(this, e)); }
SynchronizedGraph(Graph g) { super(g); elementLock = new ReentrantLock(); synchronizedNodes = new HashMap<String, Node>(); synchronizedEdges = new HashMap<String, Edge>(); for (Node n : g.getEachNode()) synchronizedNodes.put(n.getId(), new SynchronizedNode(this, n)); for (Edge e : g.getEachEdge()) synchronizedEdges.put(e.getId(), new SynchronizedEdge(this, e)); }
HashSet<Node> centroid = new HashSet<Node>(); for (Node node : graph.getEachNode()) { float m = 0; APSP.APSPInfo info = node.getAttribute(apspInfoAttribute); .printf("APSPInfo missing. Did you compute APSP before ?\n"); for (Node other : graph.getEachNode()) { if (node != other) { double d = info.getLengthTo(other.getId()); for (Node node : graph.getEachNode()) node.setAttribute(centroidAttribute, centroid.contains(node) ? isInCentroid : isNotInCentroid);
private void initializeAlgorithm() { for (Node aNode : graph.getEachNode()) { for (Edge anEdge : aNode.getEachEdge()) { double aWeight = anEdge.getNumber(getWeightAttribute()); if (Double.isNaN(aWeight)) { weighted = false; } } distanceMap.put(aNode, 0.0); } }
/** * Add a new node and connect it with all others. * * @see org.graphstream.algorithm.generator.Generator#nextEvents() */ public boolean nextEvents() { String id = Integer.toString(nodeNames++); addNode(id); for (Node n : internalGraph.getEachNode()) { if (!n.getId().equals(id)) // We can compare refs safely here. addEdge(null, id, n.getId()); } return true; } }
/** * Delete attributes used by this algorithm in nodes and edges of the graph */ public void cleanGraph(){ cleanElement(graph.getEachEdge()); cleanElement(graph.getEachNode()); }
void compute(Graph g, StyleGroup style) { x3 = y3 = Double.MAX_VALUE; x4 = y4 = Double.MIN_VALUE; for (Node n : g.getEachNode()) { x3 = Math.min(x3, getX(n)); y3 = Math.min(y3, getY(n)); x4 = Math.max(x4, getX(n)); y4 = Math.max(y4, getY(n)); } Values v = style.getPadding(); if (v.getValueCount() > 0) { padding[0] = v.get(0); padding[1] = v.getValueCount() > 1 ? v.get(1) : v.get(0); } }
private void computeKahns() { while (!sourceNodes.isEmpty()) { Node aSourceNode = sourceNodes.iterator().next(); sourceNodes.remove(aSourceNode); sortedNodes[index] = aSourceNode; index++; for (Iterator<Edge> it = aSourceNode.getLeavingEdgeIterator(); it.hasNext(); ) { Edge aLeavingEdge = it.next(); Node aTargetNode = aLeavingEdge.getTargetNode(); it.remove(); aTargetNode.getEnteringEdgeSet().remove(aLeavingEdge); if (aTargetNode.getEnteringEdgeSet().isEmpty()) { sourceNodes.add(aTargetNode); } } } boolean hasCycle = false; for (Node aNode : graph.getEachNode()) { if (!aNode.getEnteringEdgeSet().isEmpty()) { hasCycle = true; break; } } if (hasCycle) { throw new GraphHasCycleException(); } }
/** * Delete attributes used by this algorithm in nodes and edges of the graph */ public void cleanGraph(){ cleanElement(graph.getEachEdge()); cleanElement(graph.getEachNode()); }
/** * Add a new node and connect it with all others. * * @see org.graphstream.algorithm.generator.Generator#nextEvents() */ public boolean nextEvents() { String id = Integer.toString(nodeNames++); addNode(id); for (Node n : internalGraph.getEachNode()) { if (!n.getId().equals(id)) // We can compare refs safely here. addEdge(null, id, n.getId()); } return true; } }
void compute(Graph g, StyleGroup style) { x3 = y3 = Double.MAX_VALUE; x4 = y4 = Double.MIN_VALUE; for (Node n : g.getEachNode()) { x3 = Math.min(x3, getX(n)); y3 = Math.min(y3, getY(n)); x4 = Math.max(x4, getX(n)); y4 = Math.max(y4, getY(n)); } Values v = style.getPadding(); if (v.getValueCount() > 0) { padding[0] = v.get(0); padding[1] = v.getValueCount() > 1 ? v.get(1) : v.get(0); } }
for (Node n : g.getEachNode()) current = Math.max(current, n.getDegree());
for (Node n : g.getEachNode()) current = Math.max(current, n.getDegree());
/** * Step of the generator. Add a new node and connect it with some others. * * @see org.graphstream.algorithm.generator.Generator#nextEvents() */ public boolean nextEvents() { String id = Integer.toString(nodeNames++); addNode(id); for (Node n : internalGraph.getEachNode()) { if (!id.equals(n.getId()) && distance(id, n.getId()) < threshold) addEdge(id + "-" + n.getId(), id, n.getId()); } return true; }
/** * Step of the generator. Add a new node and connect it with some others. * * @see org.graphstream.algorithm.generator.Generator#nextEvents() */ public boolean nextEvents() { String id = Integer.toString(nodeNames++); addNode(id); for (Node n : internalGraph.getEachNode()) { if (!id.equals(n.getId()) && distance(id, n.getId()) < threshold) addEdge(id + "-" + n.getId(), id, n.getId()); } return true; }