for (DefaultEdge edge : graph.edgeSet()) { PlanFragmentId source = graph.getEdgeSource(edge); PlanFragmentId target = graph.getEdgeTarget(edge);
/** * Return all the edges in the StateFlowGraph. * * @return a Set of all edges in the StateFlowGraph */ public Set<Eventable> getAllEdges() { return sfg.edgeSet(); }
public Set<DirectedEdge<ExecutableMethod>> edgeSet() { return graph.edgeSet(); }
public Set<DirectedEdge<ExecutableMethod>> edgeSet() { return graph.edgeSet(); }
/** * <p>edgeCount</p> * * @return a int. */ public int edgeCount() { return graph.edgeSet().size(); }
/** * <p>edgeSet</p> * * @return a {@link java.util.Set} object. */ public Set<E> edgeSet() { // TODO hash set? can't be sure E implements hash correctly return new LinkedHashSet<E>(graph.edgeSet()); /* * Set<E> r = new HashSet<E>(); * * for (E e : graph.edgeSet()) r.add(e); * * return r; */ }
@Override public String toString() { final Set<DefaultEdge> defaultEdges = graph.edgeSet(); StringBuilder s = new StringBuilder(System.lineSeparator()); defaultEdges.forEach(de -> s.append(de.toString()).append(System.lineSeparator())); return s.toString(); } }
/** {@inheritDoc} */ @Override public String toString() { StringBuffer sb = new StringBuffer(); for (ControlFlowEdge e : graph.edgeSet()) { sb.append(graph.getEdgeSource(e) + " -> " + graph.getEdgeTarget(e)); sb.append("\n"); } return sb.toString(); }
public static void renderDirected(DirectedGraph graph, String fileName) throws IOException { try (PrintStream out = new PrintStream(new FileOutputStream(fileName))) { out.println("digraph G {"); for (Object e : graph.edgeSet()) { out.println("\t" + graph.getEdgeSource(e) + " -> " + graph.getEdgeTarget(e)); } out.println("}"); } } }
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); }
/** @return String */ @Override public String toString() { StringBuilder buf = new StringBuilder(); if (schema != null) { buf.append(schema); buf.append("\n"); buf.append("---------"); buf.append("\n"); } if (context != null) { buf.append(context); buf.append("\n"); buf.append("---------"); buf.append("\n"); } buf.append(tree); buf.append(tree.getRoot()); for (Edge edge : tree.getGraph().edgeSet()) buf.append(edge); buf.append("\n"); return buf.toString(); } }
public static void exportAsGraph(Query query, File file) { DirectedGraph<Node, LabeledEdge> g = asJGraphT(query); System.out.println(g.edgeSet().size());
/** * 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)); } }
private static List<String> shortestCycle(DirectedGraph<String, DefaultEdge> graph) { FloydWarshallShortestPaths<String, DefaultEdge> floyd = new FloydWarshallShortestPaths<>(graph); int minDistance = Integer.MAX_VALUE; String minSource = null; String minDestination = null; for (DefaultEdge edge : graph.edgeSet()) { String src = graph.getEdgeSource(edge); String dst = graph.getEdgeTarget(edge); int dist = (int) Math.round(floyd.shortestDistance(dst, src)); // from dst to src if (dist < 0) { continue; } if (dist < minDistance) { minDistance = dist; minSource = src; minDestination = dst; } } if (minSource == null) { return null; } GraphPath<String, DefaultEdge> shortestPath = floyd.getShortestPath(minDestination, minSource); List<String> pathVertexList = Graphs.getPathVertexList(shortestPath); // note: pathVertexList will be [a, a] instead of [a] when the shortest path is a loop edge if (!Objects.equals(shortestPath.getStartVertex(), shortestPath.getEndVertex())) { pathVertexList.add(pathVertexList.get(0)); } return pathVertexList; }
public Method createMethodFromSubgraph(DirectedGraph<CfgBlock, CfgEdge> subgraph, String newMethodName) { Preconditions.checkArgument(vertexSet().containsAll(subgraph.vertexSet()), "Method does not contain all nodes from subgraph."); Method subgraphMethod = new Method(location, newMethodName, this.parameterList, this.returnTypes); for (CfgBlock v : subgraph.vertexSet()) { subgraphMethod.addVertex(v); } for (CfgEdge e : subgraph.edgeSet()) { subgraphMethod.addEdge(subgraph.getEdgeSource(e), subgraph.getEdgeTarget(e)); } subgraphMethod.initialize(thisVariable, returnVariables, locals, source, isProgramEntry); return subgraphMethod; }
for (DefaultEdge edge : graph.edgeSet()) { PlanFragmentId source = graph.getEdgeSource(edge); PlanFragmentId target = graph.getEdgeTarget(edge);
for (DefaultEdge edge : graph.edgeSet()) { PlanFragmentId source = graph.getEdgeSource(edge); PlanFragmentId target = graph.getEdgeTarget(edge);
for (E edge : graph.edgeSet()) {
/** * Load a knowledge graph into graphviz representation. Do what you want after that. * Use reverse if the relationship shows the inverse of the intended semantics. * * @param graph */ public void loadGraph(DirectedGraph graph, NodePropertiesProvider npp, boolean reverse) { addln(start_graph("fontsize=8", "fontname=\"sanserif\"", "overlap=\"scale\"")); for (Object s : graph.vertexSet()) { addNode(npp.getNodeId(s), "shape=" + npp.getNodeShape(s) + ", fontname=sanserif, fontsize=8, margin=\"0.055\""); } for (Object e : graph.edgeSet()) { Object s = graph.getEdgeSource(e); Object t = graph.getEdgeTarget(e); addDirectedEdge((reverse ? npp.getNodeId(t) : npp.getNodeId(s)), (reverse ? npp.getNodeId(s) : npp.getNodeId(t)), ("label=\"" + npp.getEdgeLabel(e) + "\", color=\"" + npp.getEdgeColor(e) + "\", fontname=sanserif, fontsize=8")); } addln(end_graph()); }