/** * For the iterative algorithm to work properly the refinement and * optimization options should be turned on, because the alignment has to be * consistent at every recursive step. * * @param param * CeSymm parameters, make sure they are cloned */ public CeSymmIterative(CESymmParameters param) { params = param; alignGraph = new SimpleGraph<Integer, DefaultEdge>(DefaultEdge.class); levels = new ArrayList<CeSymmResult>(); }
/** * Create a builder for this kind of graph. * * @param edgeClass class on which to base factory for edges * @param <V> the graph vertex type * @param <E> the graph edge type * @return a builder for this kind of graph */ public static <V, E> GraphBuilder<V, E, ? extends SimpleGraph<V, E>> createBuilder( Class<? extends E> edgeClass) { return new GraphBuilder<>(new SimpleGraph<>(edgeClass)); }
/** * Create a builder for this kind of graph. * * @param edgeSupplier the edge supplier of the new graph * @param <V> the graph vertex type * @param <E> the graph edge type * @return a builder for this kind of graph */ public static <V, E> GraphBuilder<V, E, ? extends SimpleGraph<V, E>> createBuilder(Supplier<E> edgeSupplier) { return new GraphBuilder<>(new SimpleGraph<>(null, edgeSupplier, false)); }
public static Graph<Node, LabeledEdge<Node, Node>> toGraph(QuadFilterPatternCanonical qfpc) { //EdgeFactory <Node, LabeledEdge<Node, Node>> edgeFactory = (v, e) -> new LabeledEdgeImpl<>(v, e, null); Graph<Node, LabeledEdge<Node, Node>> graph = new SimpleGraph<>((v, e) -> new LabeledEdgeImpl<>(v, e, null)); toGraph(graph, qfpc); return graph; } public static Stream<Map<Var, Var>> match(QuadFilterPatternCanonical view, QuadFilterPatternCanonical user) {
private static Graph<Integer, DefaultEdge> initContactGraph(List<SubunitCluster> clusters){ Graph<Integer, DefaultEdge> graph = new SimpleGraph<>(DefaultEdge.class);
SimpleGraph<Glyph, GlyphLink> subGraph = new SimpleGraph<>(GlyphLink.class); Graphs.addAllVertices(subGraph, set); Graphs.addAllEdges(subGraph, graph, setEdges);
public IndexFilteredTriplePattern() { this.graph = new SimpleGraph<>((v, e) -> new LabeledEdgeImpl<>(v, e, null)); this.keyToNode = new ReversibleMapImpl<>(); }
/** * Convenience method for testing. * Only works for queries whose element is a BGP + filters. * * @param view * @param user * @return */ public static boolean tryMatch(Query view, Query user) { Graph<Node, LabeledEdge<Node, Node>> a = new SimpleGraph<>((v, e) -> new LabeledEdgeImpl<>(v, e, null)); Graph<Node, LabeledEdge<Node, Node>> b = new SimpleGraph<>((v, e) -> new LabeledEdgeImpl<>(v, e, null)); toGraph(a, view); toGraph(b, user); // visualizeGraph(a); // visualizeGraph(b); // try(Scanner s = new Scanner(System.in)) { s.nextLine(); } Stream<Map<Var, Var>> tmp = QueryToGraph.match(a, b); tmp = tmp.peek(x -> System.out.println("Solution: " + x)); boolean result = tmp.count() > 0; return result; }
SimpleGraph<Section, Touching> graph = new SimpleGraph<>(Touching.class);
public static void main(String [] args) completeGraph = new SimpleGraph<Object, DefaultEdge>(DefaultEdge.class);
/** * Compute the Voronoi diagram as a graph of its vertices * * @param points * the vertices * @param width * the width of the diagram * @param height * the height of the diagram * @return the graph */ public static Graph<Point2d, DefaultEdge> computeVoronoiGraph(List<? extends Point2d> points, double width, double height) { final FortunesAlgorithm f = new FortunesAlgorithm(width, height); final List<Line2d> edges = f.runFortune(points); final Graph<Point2d, DefaultEdge> graph = new SimpleGraph<Point2d, DefaultEdge>(DefaultEdge.class); for (final Line2d l : edges) { graph.addEdge(l.begin, l.end); } return graph; }
private List<Set<String>> getClusters(List<String> dir1, List<String> dir2, Matrix scores) { UndirectedGraph<String, DefaultEdge> graph = new SimpleGraph<String, DefaultEdge>(DefaultEdge.class); for (String f : dir1) graph.addVertex(f); if (dir1 != dir2) for (String f : dir2) graph.addVertex(f); final double[][] matrixData = scores.getArray(); for (int r=0; r<matrixData.length; r++) { for (int c=r; c<matrixData[0].length; c++) { String f1 = dir1.get(r); String f2 = dir2.get(c); if ( matrixData[r][c] != 0 && f1!=f2 ) { graph.addEdge(f1, f2); } } } ConnectivityInspector<String, DefaultEdge> conn = new ConnectivityInspector<String, DefaultEdge>(graph); return conn.connectedSets(); }
private List<Set<String>> getClusters(List<String> dir1, List<String> dir2, Matrix scores) { UndirectedGraph<String, DefaultEdge> graph = new SimpleGraph<String, DefaultEdge>(DefaultEdge.class); for (String f : dir1) graph.addVertex(f); if (dir1 != dir2) for (String f : dir2) graph.addVertex(f); final double[][] matrixData = scores.getArray(); for (int r=0; r<matrixData.length; r++) { for (int c=r; c<matrixData[0].length; c++) { String f1 = dir1.get(r); String f2 = dir2.get(c); if ( matrixData[r][c] != 0 && f1!=f2 ) { graph.addEdge(f1, f2); } } } ConnectivityInspector<String, DefaultEdge> conn = new ConnectivityInspector<String, DefaultEdge>(graph); return conn.connectedSets(); }
public static boolean bipartiteMatchingFull(SparseDoubleMatrix2D candidateList, int[] signatureDepths, int[] functionDepths, int depth) { UndirectedGraph<String, DefaultEdge> g = new SimpleGraph<String, DefaultEdge>(DefaultEdge.class);
boolean reverse) { Graph<Node, DefaultEdge> augJoinGraph = new SimpleGraph<>(DefaultEdge.class);
/** * Convert the similarity matrix to an unweighted, undirected * graph representation. A threshold is used to determine * if edges should be created. If the value at [r][c] is bigger * than the threshold, then an edge will be created between the * vertices represented by index[r] and index[c]. * * @param threshold the threshold * @return the graph */ public UndirectedGraph<String, DefaultEdge> toUndirectedUnweightedGraph(double threshold) { UndirectedGraph<String, DefaultEdge> graph = new SimpleGraph<String, DefaultEdge>(DefaultEdge.class); final int rows = this.getRowDimension(); final int cols = this.getColumnDimension(); final double[][] data = this.getArray(); for (String s : index) { graph.addVertex(s); } for (int r=0; r<rows; r++) { for (int c=0; c<cols; c++) { if (r != c && data[r][c] > threshold) graph.addEdge(index[r], index[c]); } } return graph; }
/** * Converts a self alignment into a directed jGraphT of aligned residues, * where each vertex is a residue and each edge means the equivalence * between the two residues in the self-alignment. * * @param selfAlignment * AFPChain * * @return alignment Graph */ public static Graph<Integer, DefaultEdge> buildSymmetryGraph( AFPChain selfAlignment) { Graph<Integer, DefaultEdge> graph = new SimpleGraph<Integer, DefaultEdge>( DefaultEdge.class); for (int i = 0; i < selfAlignment.getOptAln().length; i++) { for (int j = 0; j < selfAlignment.getOptAln()[i][0].length; j++) { Integer res1 = selfAlignment.getOptAln()[i][0][j]; Integer res2 = selfAlignment.getOptAln()[i][1][j]; graph.addVertex(res1); graph.addVertex(res2); graph.addEdge(res1, res2); } } return graph; }
/** * Craete a toy graph based on String objects. * * @return a graph based on String objects. */ private static UndirectedGraph<String, DefaultEdge> createStringGraph() { UndirectedGraph<String, DefaultEdge> g = new SimpleGraph<String, DefaultEdge>(DefaultEdge.class); String v1 = "v1"; String v2 = "v2"; String v3 = "v3"; String v4 = "v4"; // add the vertices g.addVertex(v1); g.addVertex(v2); g.addVertex(v3); g.addVertex(v4); // add edges to create a circuit g.addEdge(v1, v2); g.addEdge(v2, v3); g.addEdge(v3, v4); g.addEdge(v4, v1); return g; } }
public DistanceGraph(ConnectionData data, Hierarchy hierarchy) { // this.data = data; this.hierarchy = hierarchy; allMethods = data.getAllMethods(); g = new SimpleGraph<MethodDescription, DefaultEdge>(DefaultEdge.class); Set<Tuple> connections = data.getConnections(); for (Tuple tuple : connections) { MethodDescription start = tuple.getStart(); MethodDescription end = tuple.getEnd(); if (!start.equals(end)) { if (!g.containsVertex(start)) { g.addVertex(start); } if (!g.containsVertex(end)) { g.addVertex(end); } g.addEdge(start, end); } } }
/** * Returns all anticomponents of a graph and a vertex set. * * @param g A Graph * @param Y A set of vertices * @return List of anticomponents of Y in g */ private List<Set<V>> findAllAnticomponentsOfY(Graph<V, E> g, Set<V> Y) { Graph<V, E> target; if (g.getType().isSimple()) target = new SimpleGraph<>( g.getVertexSupplier(), g.getEdgeSupplier(), g.getType().isWeighted()); else target = new Multigraph<>( g.getVertexSupplier(), g.getEdgeSupplier(), g.getType().isWeighted()); new ComplementGraphGenerator<>(g).generateGraph(target); return findAllComponents(target, Y); }