public boolean hasClass(String className) { return inheritanceGraph.containsVertex(className); }
List<DataType> getSubVertexes(DataType vertex) { if (super.containsVertex(vertex)) { return asList(vertex); } return vertexSet().stream().filter(vertex::isCompatibleWith).collect(toList()); }
List<DataType> getSuperVertexes(DataType vertex) { //Use the parent's method to check if the actual vertex exists if (super.containsVertex(vertex)) { return asList(vertex); } return vertexSet().stream().filter(graphVertex -> graphVertex.isCompatibleWith(vertex)).collect(toList()); }
public Set<String> getSubclasses(String className) { String classNameWithDots = ResourceList.getClassNameFromResourcePath(className); if (subclassCache.containsKey(classNameWithDots)) return subclassCache.get(classNameWithDots); if (!inheritanceGraph.containsVertex(classNameWithDots)) { LoggingUtils.logWarnAtMostOnce(logger, "Class not in inheritance graph: " + classNameWithDots); return new LinkedHashSet<>(); } // TreeSet so that classes are sorted by name and thus deterministic across platforms Set<String> result = new TreeSet<String>(); BreadthFirstIterator<String, DefaultEdge> bfi = new BreadthFirstIterator<String, DefaultEdge>( inheritanceGraph, classNameWithDots); while (bfi.hasNext()) { result.add(bfi.next()); } subclassCache.put(classNameWithDots, result); return result; }
public List<String> getOrderedSuperclasses(String className) { String classNameWithDots = ResourceList.getClassNameFromResourcePath(className); if (!inheritanceGraph.containsVertex(classNameWithDots)) { LoggingUtils.logWarnAtMostOnce(logger, "Class not in inheritance graph: " + classNameWithDots); return new LinkedList<>(); } EdgeReversedGraph<String, DefaultEdge> reverseGraph = new EdgeReversedGraph<String, DefaultEdge>( inheritanceGraph); List<String> orderedList = new LinkedList<>(); BreadthFirstIterator<String, DefaultEdge> bfi = new BreadthFirstIterator<String, DefaultEdge>( reverseGraph, classNameWithDots); while (bfi.hasNext()) { orderedList.add(bfi.next()); } return orderedList; }
public Set<String> getSuperclasses(String className) { String classNameWithDots = ResourceList.getClassNameFromResourcePath(className); if (!inheritanceGraph.containsVertex(classNameWithDots)) { LoggingUtils.logWarnAtMostOnce(logger, "Class not in inheritance graph: " + classNameWithDots); return new LinkedHashSet<>(); } EdgeReversedGraph<String, DefaultEdge> reverseGraph = new EdgeReversedGraph<String, DefaultEdge>( inheritanceGraph); // TreeSet so that classes are sorted by name and thus deterministic across platforms Set<String> result = new TreeSet<>(); BreadthFirstIterator<String, DefaultEdge> bfi = new BreadthFirstIterator<String, DefaultEdge>( reverseGraph, classNameWithDots); while (bfi.hasNext()) { result.add(bfi.next()); } return result; }
public void printBoundGraph( String filename ) { LOG.info( "writing stream bound graph to {}", filename ); DirectedMultigraph<Duct, Integer> graph = new DirectedMultigraph<>( new EdgeFactory<Duct, Integer>() { int count = 0; @Override public Integer createEdge( Duct sourceVertex, Duct targetVertex ) { return count++; } } ); TopologicalOrderIterator<Duct, Integer> iterator = getTopologicalOrderIterator(); while( iterator.hasNext() ) { Duct previous = iterator.next(); if( graph.containsVertex( previous ) || previous instanceof Extent ) continue; graph.addVertex( previous ); addNext( graph, previous ); } Util.printGraph( filename, graph ); }