public static Map computeLevels(Map vertexLevelMap, Digraph digraph, boolean longest) { if (vertexLevelMap == null) vertexLevelMap = new HashMap(digraph.order()); for (Iterator i = digraph.vertexIterator(); i.hasNext(); ) { Object rootCandidate = i.next(); if (digraph.incomingSize(rootCandidate) == 0) computeLevels(vertexLevelMap, digraph, rootCandidate, longest); } return vertexLevelMap; }
public static boolean isStronglyConnected(DigraphIteration digraph, Object firstVertex, int order) { return (isConnected(digraph, firstVertex, order) && isConnected(new ReversedIteration(digraph), firstVertex, order)); }
public static boolean isStronglyConnected(Digraph digraph) { return isStronglyConnected(digraph, digraph.vertexIterator().next(), digraph.order()); }
boolean acyclic = GraphUtils.isAcyclic(pkDependencyGraph); if (acyclic) { IndegreeTopologicalSort sorter = new IndegreeTopologicalSort(
public static Map shiftLevelsDown(Map vertexLevelMap, Digraph digraph) { for (Iterator i = digraph.vertexIterator(); i.hasNext(); ) { Object rootCandidate = i.next(); if (digraph.incomingSize(rootCandidate) == 0) shiftLevelsDown(vertexLevelMap, digraph, rootCandidate); } return vertexLevelMap; }
public static boolean hasLoops(Digraph digraph) { return (traverse(new LoopSearch(digraph)) != 0); } public static boolean isAcyclic(Digraph digraph) {
private void generateAcyclicSchema() { Digraph graph = new MapDigraph(MapDigraph.HASHMAP_FACTORY); Map vertexToTable = new HashMap(); GraphUtils.randomizeAcyclic(graph, tableCount, maxForeignKeysPerTable, maxReferencesPerTable, randomizer); tables = new ArrayList(tableCount);
List cycles = GraphUtils.findCycles(subgraphOrderingGraph); for (Iterator i = cycles.iterator(); i.hasNext(); ) { ArrayList cycle = (ArrayList)i.next();
GraphUtils.randomizeTree(digraph, 3, 4, randomizer); Map vertexShapeMap = new HashMap(); Point2D leftUpperCorner = new Point2D.Double(30, 30);
boolean acyclic = GraphUtils.isAcyclic(pkDependencyGraph); if (acyclic) { IndegreeTopologicalSort sorter = new IndegreeTopologicalSort(
public static Map shiftLevelsDown(Map vertexLevelMap, DigraphIteration digraph, Object root) { int minChildLevel = Integer.MAX_VALUE; for (ArcIterator i = digraph.outgoingIterator(root); i.hasNext(); ) { i.next(); Object child = i.getDestination(); shiftLevelsDown(vertexLevelMap, digraph, child); MutableInteger childLevel = (MutableInteger)vertexLevelMap.get(child); minChildLevel = (minChildLevel <= childLevel.intValue() ? minChildLevel : childLevel.intValue()); } if (minChildLevel != Integer.MAX_VALUE) { MutableInteger rootLevel = (MutableInteger)vertexLevelMap.get(root); rootLevel.setValue(minChildLevel - 1); } return vertexLevelMap; }
public static boolean isConnected(DigraphIteration digraph, Object firstVertex, int order) { Algorithm dfs = new DepthFirstSearch(digraph, firstVertex); return order == traverse(dfs); }
public static Map computeLevels(Map vertexLevelMap, DigraphIteration digraph, Object root, boolean longest) { if (vertexLevelMap == null) vertexLevelMap = new HashMap(); MutableInteger rootLevel = (MutableInteger)vertexLevelMap.get(root); if (rootLevel == null) { rootLevel = new MutableInteger(0); vertexLevelMap.put(root, rootLevel); } for (ArcIterator i = digraph.outgoingIterator(root); i.hasNext(); ) { i.next(); Object child = i.getDestination(); int childLevelCandidate = rootLevel.intValue()+1; MutableInteger childLevel = (MutableInteger)vertexLevelMap.get(child); if (childLevel == null) { childLevel = new MutableInteger(childLevelCandidate); vertexLevelMap.put(child, childLevel); computeLevels(vertexLevelMap, digraph, child, longest); } else if ((longest && childLevel.intValue() < childLevelCandidate) || (!longest && childLevel.intValue() > childLevelCandidate)) { childLevel.setValue(childLevelCandidate); computeLevels(vertexLevelMap, digraph, child, longest); } } return vertexLevelMap; }
public static boolean isConnected(Digraph digraph) { return isConnected(digraph, digraph.vertexIterator().next(), digraph.order()); }
public void doLayout() { // will operate on digraph of vertex wrappers instead of the original // digraph createWrapperDigraph(); // classify vertices by level (longest type) wrapperLevelMap = GraphUtils.computeLevels(new HashMap(wrapperDigraph .order()), wrapperDigraph, true); // shift vertices to leaves if possible // GraphUtils.shiftLevelsDown(vertexLevelMap, digraph); // split long arcs - make (k,2)partite digraph splitLongArcs(); // fill array of vertex levels createLevels(); // minimize number of arc intersections between each two levels // via barycentric method minimizeArcIntersections(); // adjust vertices horizontally to minimize arc lengths minimizeDistancesToBarycentres(); // finally, compute coordinates of vertices and arcs computeGeometry(); }