/** * Converts the flowStep that generated from cascading to a Map of DAGNode and its name to be used * to build Ambrose Graph. */ public void convert() { // returns a set of the nodes contained in this graph Set vertices = jobsGraph.vertexSet(); // create ambrose nodes for (Object vertex : vertices) { BaseFlowStep step = (BaseFlowStep) vertex; CascadingJob job = new CascadingJob(); job.setFeatures(getNodeFeatures(step)); String name = step.getName(); DAGNode<CascadingJob> node = new DAGNode<CascadingJob>(name, job); dagNamesMap.put(name, node); } // loop again to set the successors for each node after nodes are created for (Object vertex : vertices) { BaseFlowStep step = (BaseFlowStep) vertex; String name = step.getName(); DAGNode<CascadingJob> node = dagNamesMap.get(name); node.setSuccessors(getNodeSuccessors(vertex)); } }
/** * Return all the states in the StateFlowGraph. * * @return all the states on the graph. */ public Set<StateVertex> getAllStates() { return sfg.vertexSet(); }
/** * <p>getRandomVertex</p> * * @return a V object. */ public V getRandomVertex() { // TODO that's not really random for (V v : graph.vertexSet()) return v; return null; }
/** * <p>isEmpty</p> * * @return a boolean. */ public boolean isEmpty() { return graph.vertexSet().isEmpty(); }
/** * <p>vertexCount</p> * * @return a int. */ public int vertexCount() { return graph.vertexSet().size(); }
private JavaClass findClass(String classname) { for (JavaClass jClass : graph.vertexSet()) { if (jClass.getName().equals(classname)) { return jClass; } } return null; }
public static List<GraphPath> getPaths(DirectedGraph<Node, DefaultLink> g, int length) { List<GraphPath> graphPaths = new LinkedList<>(); if (g == null) return graphPaths; for (Node n : g.vertexSet()) { List<GraphPath> gpList = getOutgoingPaths(g, n, length); if (gpList != null) graphPaths.addAll(gpList); } return graphPaths; }
public Set<String> getIndexedClasses() { Set<String> classes = newHashSet(); Set<JavaClass> vertexSet = graph.vertexSet(); for (JavaClass each : vertexSet) { classes.add(each.getName()); } return classes; } }
/** * Return a downstream iterator of a build of default type. This will be overriden by specific build types. * * @return the downstream builds as an iterator */ @Override public Iterator<?> downstreamProjects() { FlowRun flowRun = (FlowRun) build; DirectedGraph<JobInvocation, FlowRun.JobEdge> directedGraph = flowRun.getJobsGraph(); return directedGraph.vertexSet().iterator(); }
protected List<String> getEndVertices() { final List<String> endVertices = new ArrayList<>(); Set<String> vertices = _directedGraph.vertexSet(); for (String vertex : vertices) { Set<UpgradeProcessEdge> upgradeProcessEdges = _directedGraph.outgoingEdgesOf(vertex); if (upgradeProcessEdges.isEmpty()) { endVertices.add(vertex); } } return endVertices; }
/** * <p>determineBranches</p> * * @return a {@link java.util.Set} object. */ public Set<V> determineBranches() { Set<V> r = new LinkedHashSet<V>(); for (V instruction : graph.vertexSet()) if (outDegreeOf(instruction) > 1) r.add(instruction); return r; }
public ClassVariable findClassVariableByName(final String name) { for (ClassVariable cv : this.typeGraph.vertexSet()) { if (name.equals(cv.getName())) { return cv; } } return null; }
public static Set<Node> getInNeighbors(DirectedGraph<Node, DefaultLink> g, Node n) { Set<Node> neighbors = new HashSet<>(); if (g == null || n == null || !g.vertexSet().contains(n)) return neighbors; Set<DefaultLink> incomingLinks = g.incomingEdgesOf(n); if (incomingLinks != null) { for (DefaultLink l : incomingLinks) { neighbors.add(l.getSource()); } } return neighbors; }
public static Set<Node> getOutNeighbors(DirectedGraph<Node, DefaultLink> g, Node n) { Set<Node> neighbors = new HashSet<>(); if (g == null || n == null || !g.vertexSet().contains(n)) return neighbors; Set<DefaultLink> outgoingLinks = g.outgoingEdgesOf(n); if (outgoingLinks != null) { for (DefaultLink l : outgoingLinks) { neighbors.add(l.getTarget()); } } return neighbors; }
private void constructCategoryGraph(Wikipedia pWiki, DirectedGraph<Integer,DefaultEdge> pGraph) throws WikiApiException { this.wiki = pWiki; this.graph = pGraph; this.numberOfNodes = this.graph.vertexSet().size(); this.numberOfEdges = this.graph.edgeSet().size(); this.undirectedGraph = new AsUndirectedGraph<Integer, DefaultEdge>(this.graph); }
public Set<Object> getScores() { Set<Object> set = new LinkedHashSet<Object>(); for( Node node : getGraph().vertexSet() ) { if( node.getScore() != null ) set.add( node.getScore() ); } return set; }
static public <V> BinaryRelation<V, V> getBinaryRelation(DirectedGraph<V, Edge<V>> source) { final BinaryRelation<V, V> relation = new BinaryRelationImpl<V, V>(); final Set<V> vertexSet = source.vertexSet(); for (V v : vertexSet) { final Set<Edge<V>> edges = source.outgoingEdgesOf(v); for (Edge<V> edge : edges) { final Pair<V, V> pair = Pair.create(edge.getSource(), edge.getTarget()); relation.asPairs().add(pair); } } return relation; }
/** * Copy the source graph into the target graph */ public static <V> void copyGraph(DirectedGraph<V, DefaultEdge> sourceGraph, DirectedGraph<V, DefaultEdge> targetGraph) { addAllVertices(targetGraph, sourceGraph.vertexSet()); for (DefaultEdge edge : sourceGraph.edgeSet()) { targetGraph.addEdge(sourceGraph.getEdgeSource(edge), sourceGraph.getEdgeTarget(edge)); } }