protected V getMinDegreeVertexBruteForce(UndirectedGraph<V, E> graph) { int minDegree = Integer.MAX_VALUE; V minDegreeVertex = null; for (V vertex : graph.vertexSet()) { int degree = graph.degreeOf(vertex); if (degree < minDegree) { minDegreeVertex = vertex; break; } } return minDegreeVertex; }
tracksUpdated.clear(); final Set< Spot > vertexSet = lGraph.vertexSet(); if ( vertexSet.size() > 0 )
tracksUpdated.clear(); final Set< Spot > vertexSet = lGraph.vertexSet(); if ( vertexSet.size() > 0 )
public void addProcessModelElement(ProcessModelElement processModelElement, ControlFlowOutputPort<?> statePort) { processModelElementGraph.addVertex(processModelElement); Set<ControlFlowOutputPort<?>> statesInvolved = getStatesInvolved(processModelElement); Set<ControlFlowInputPort<?>> inputs = processModelElement.getInputs(); for (ProcessModelElement otherProcessModelElement : processModelElementGraph.vertexSet()) { if (processModelElement != otherProcessModelElement) { Set<ControlFlowOutputPort<?>> otherStatesInvolved = getStatesInvolved(otherProcessModelElement); Set<ControlFlowOutputPort<?>> stateIntersection = new LinkedHashSet<ControlFlowOutputPort<?>>(statesInvolved); stateIntersection.retainAll(otherStatesInvolved); boolean stateCouplingExists = stateIntersection.size() > 0; Set<ControlFlowInputPort<?>> otherInputs = otherProcessModelElement.getInputs(); Set<ControlFlowInputPort<?>> inputIntersection = new LinkedHashSet<ControlFlowInputPort<?>>(inputs); inputIntersection.retainAll(otherInputs); boolean inputCouplingExists = inputIntersection.size() > 0; if (stateCouplingExists || inputCouplingExists) { ProcessModelGraphEdge edge = new ProcessModelGraphEdge(stateIntersection, inputIntersection); processModelElementGraph.addEdge(processModelElement, otherProcessModelElement, edge); } } } }
/** * Compute the densest subgraph of a graph. * @param graph the graph. */ public CharikarDensestSubgraph(UndirectedGraph<V, E> graph) { this.graph = graph; for (V vertex : graph.vertexSet()) heap.insert(new FibonacciHeapNode<V>(vertex), graph.degreeOf(vertex)); calculateDensestSubgraph(); }
Set<Integer> nodes = undirectedGraph.vertexSet();
public static DirectedGraph<Node, DefaultLink> asDirectedGraph(UndirectedGraph<Node, DefaultLink> undirectedGraph) { if (undirectedGraph == null) { logger.debug("graph is null."); return null; } DirectedGraph<Node, DefaultLink> g = new DirectedWeightedMultigraph<>(DefaultLink.class); for (Node v : undirectedGraph.vertexSet()) g.addVertex(v); for (DefaultLink e: undirectedGraph.edgeSet()) g.addEdge(e.getSource(), e.getTarget(), e); return g; }
public static UndirectedGraph<Node, DefaultLink> asDefaultGraph(UndirectedGraph<Node, LabeledLink> graph) { if (graph == null) { logger.debug("graph is null."); return null; } UndirectedGraph<Node, DefaultLink> g = new WeightedMultigraph<>(DefaultLink.class); for (Node v : graph.vertexSet()) g.addVertex(v); for (DefaultLink e: graph.edgeSet()) g.addEdge(e.getSource(), e.getTarget(), e); return g; }
protected void calculateDensestSubgraph() { UndirectedSubgraph<V,E> currentSubGraph = new UndirectedSubgraph<V,E>(graph, graph.vertexSet(), null); double bestDensity = calculateDensity(graph); while (currentSubGraph.vertexSet().size() > 0) { currentSubGraph = new UndirectedSubgraph<V,E>(graph, currentSubGraph.vertexSet(), null); currentSubGraph.removeVertex(getMinDegreeVertex(currentSubGraph)); double density = calculateDensity(currentSubGraph); if (density > bestDensity) { bestDensity = density; bestSubGraph = currentSubGraph; } } }