Codota Logo
Digraph
Code IndexAdd Codota to your IDE (free)

How to use
Digraph
in
org.objectstyle.ashwood.graph

Best Java code snippets using org.objectstyle.ashwood.graph.Digraph (Showing top 20 results out of 315)

  • Common ways to obtain Digraph
private void myMethod () {
Digraph d =
  • Codota IconFactory mapFactory;new MapDigraph(mapFactory)
  • Smart code suggestions by Codota
}
origin: org.objectstyle.ashwood/ashwood

public static Digraph randomize(Digraph digraph, int order, int size, Random randomizer) {
 for (int i = 1; i <= order; i++) digraph.addVertex(new Integer(i));
 Random random = randomizer;
 int n_2 = order*order;
 size = Math.min(size, n_2);
 for (int arc = 1; arc <= size; arc++) {
  int arcCode = random.nextInt(n_2);
  int origin = arcCode / order + 1;
  int dst = arcCode % order + 1;
  digraph.putArc(new Integer(origin), new Integer(dst), new Integer(arc));
 }
 return digraph;
}
origin: org.objectstyle.ashwood/ashwood

 public boolean evaluate(Object parameter) {
  return graph.containsVertex(parameter);
 }
}
origin: org.objectstyle.ashwood/ashwood

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;
}
origin: org.objectstyle.ashwood/ashwood

private static Digraph createDigraph2() {
  Digraph digraph = new MapDigraph(MapDigraph.HASHMAP_FACTORY);
  String[] vertices = new String[] { "A", "B", "C", "D", "E", "F" };
  digraph.addAllVertices(Arrays.asList(vertices));
  digraph.putArc("A", "B", Boolean.TRUE);
  digraph.putArc("A", "F", Boolean.TRUE);
  digraph.putArc("B", "C", Boolean.TRUE);
  digraph.putArc("F", "D", Boolean.TRUE);
  digraph.putArc("C", "D", Boolean.TRUE);
  digraph.putArc("E", "D", Boolean.TRUE);
  return digraph;
}
origin: org.objectstyle.ashwood/ashwood

public static Digraph randomizeAcyclic(Digraph digraph, int order, int incomingSize, int outgoingSize, Random randomizer) {
 Random random = randomizer;
 int arc = 1;
 for (int i = 1; i <= order; i++) {
  Integer destination = new Integer(i);
  digraph.addVertex(destination);
  for (int j = 0; j < incomingSize; j++) {
   int org = random.nextInt(i);
   if (org == 0) continue;
   Integer origin = new Integer(org);
   if (digraph.outgoingSize(origin) >= outgoingSize) continue;
   digraph.putArc(origin, destination, new Integer(arc++));
  }
 }
 return digraph;
}
origin: org.objectstyle.ashwood/ashwood

private void createWrapperDigraph() {
  wrapperDigraph = new MapDigraph(MapDigraph.HASHMAP_FACTORY);
  vertexWrapperMap = new HashMap(digraph.order());
  for (Iterator i = digraph.vertexIterator(); i.hasNext();) {
    Object vertex = i.next();
    VertexWrapper wrapper = new VertexWrapper(vertex);
    vertexWrapperMap.put(vertex, wrapper);
    wrapperDigraph.addVertex(wrapper);
  }
  for (ArcIterator i = digraph.arcIterator(); i.hasNext();) {
    i.next();
    Object wrapper1 = vertexWrapperMap.get(i.getOrigin());
    Object wrapper2 = vertexWrapperMap.get(i.getDestination());
    if (rootsUpwards)
      wrapperDigraph.putArc(wrapper1, wrapper2, Boolean.TRUE);
    else
      wrapperDigraph.putArc(wrapper2, wrapper1, Boolean.TRUE);
  }
}
origin: org.objectstyle.ashwood/ashwood

Map vertexMap = new HashMap(digraph.order());
longArcDigraph = new MapDigraph();
for (Iterator i = digraph.vertexIterator(); i.hasNext(); ) {
 Object vertex = i.next();
 int rank = rankFunction.intValue(vertex);
 if (wrapper == null) {
  wrapper = new LayerVertex(
    vertex, digraph.incomingSize(vertex), digraph.outgoingSize(vertex));
  if (vertexShape != null)
   wrapper.setGeometry(vertexShape);
 for (ArcIterator j = digraph.outgoingIterator(vertex); j.hasNext(); ) {
  j.next();
  Object dst = j.getDestination();
  if (dstWrapper == null) {
   dstWrapper = new LayerVertex(
     dst, digraph.incomingSize(dst), digraph.outgoingSize(dst));
   if (vertexShape != null)
    dstWrapper.setGeometry(vertexShape);
   LayerVertex dummy = new LayerVertex(null, 1, 1);
   if (k == 1)
    longArcDigraph.putArc(wrapper, dstWrapper, dummy);
   origin.getSuccessors().add(dummy);
   dummy.getPredecessors().add(origin);
 for (ArcIterator i = longArcDigraph.arcIterator(); i.hasNext(); ) {
origin: org.objectstyle.ashwood/ashwood

  public static Digraph buildReferentialDigraph(Digraph digraph,
      Collection tables) {
    HashMap tableMap = new HashMap();
    for (Iterator i = tables.iterator(); i.hasNext();) {
      Table table = (Table) i.next();
      tableMap.put(table.getFullName(), table);
      digraph.addVertex(table);
    }
    for (Iterator i = tables.iterator(); i.hasNext();) {
      Table dst = (Table) i.next();
      for (Iterator j = dst.getForeignKeys().iterator(); j.hasNext();) {
        ForeignKey fk = (ForeignKey) j.next();
        String pkTableFullName = Table.composeFullName(fk
            .getPkTableCatalog(), fk.getPkTableSchema(), fk
            .getPkTableName());
        Table origin = (Table) tableMap.get(pkTableFullName);
        if (origin != null) {
          ArrayList fks = (ArrayList) digraph.getArc(origin, dst);
          if (fks == null) {
            fks = new ArrayList();
            digraph.putArc(origin, dst, fks);
          }
          fks.add(fk);
        }
      }
    }
    return digraph;
  }
}
origin: org.apache.cayenne/cayenne-nodeps

        continue;
      pkDependencyGraph.putArc(origin, dst, Boolean.TRUE);
for (Iterator i = dbEntitiesToResolve.iterator(); i.hasNext();) {
  DbEntity entity = (DbEntity) i.next();
  if (!pkDependencyGraph.containsVertex(entity)) {
    indexedDbEntities.put(entity, new Integer(index++));
origin: org.objectstyle.ashwood/ashwood

 LayerVertex v1 = layers[i].getVertex(j);
 LayerVertex v2 = layers[i].getVertex(j + 1);
 subgraphOrderingGraph.putArc(v1, v2, Boolean.TRUE);
 NestingTreeNode origin = v1.getParentSubgraph();
 NestingTreeNode dst = v2.getParentSubgraph();
 subgraphOrderingGraph.addVertex(origin);
 subgraphOrderingGraph.addVertex(dst);
 if (origin == dst) continue;
 if (origin == root) origin = v1;
 if (dst == root) dst = v2;
 subgraphOrderingGraph.putArc(origin, dst, Boolean.TRUE);
 subgraphOrderingGraph.removeArc(
   cycle.get(minWeightIndex - 1), cycle.get(minWeightIndex));
} else {
 subgraphOrderingGraph.removeArc(
   cycle.get(cycle.size() - 1), cycle.get(0));
origin: org.objectstyle.ashwood/ashwood

public int order() {
 return digraph.order();
}
origin: org.objectstyle.ashwood/ashwood

public static boolean isAcyclic(Digraph digraph) {
 int order = digraph.order();
 if (order == 0) return true;
 Set spanned = new HashSet(order);
 DepthFirstStampSearch dfs = new DepthFirstStampSearch(digraph, digraph.vertexIterator().next());
 for (Iterator i = digraph.vertexIterator(); i.hasNext();) {
  Object dfsRoot = i.next();
  if (spanned.contains(dfsRoot)) continue;
  dfs.reset(dfsRoot);
  Map dfsOrders = dfs.traverse(new HashMap(digraph.order()));
  for (Iterator j = dfsOrders.entrySet().iterator(); j.hasNext();) {
   Map.Entry entry = (Map.Entry)j.next();
   Object origin = entry.getKey();
   DepthFirstStampSearch.OrderPair orgOrders = (DepthFirstStampSearch.OrderPair)entry.getValue();
   spanned.add(origin);
   for (ArcIterator k = digraph.outgoingIterator(origin); k.hasNext();) {
    k.next();
    Object dst = k.getDestination();
    DepthFirstStampSearch.OrderPair dstOrders = (DepthFirstStampSearch.OrderPair)dfsOrders.get(dst);
    if (dstOrders.getPostOrder() > orgOrders.getPostOrder()) return false;
   }
  }
  if (dfsOrders.size() == order) break;
 }
 return true;
}
origin: org.objectstyle.ashwood/ashwood

private void splitLongArcs() {
  for (ArcIterator i = wrapperDigraph.arcIterator(); i.hasNext();) {
    i.next();
    Object origin = i.getOrigin();
    Pair splitArc = (Pair) entry.getKey();
    List dummyWrappers = (List) entry.getValue();
    wrapperDigraph.removeArc(splitArc.first, splitArc.second);
    Object origin = splitArc.first;
    for (Iterator j = dummyWrappers.iterator(); j.hasNext();) {
      Object dummyVertex = j.next();
      wrapperDigraph.putArc(origin, dummyVertex, Boolean.TRUE);
      origin = dummyVertex;
    wrapperDigraph.putArc(origin, splitArc.second, Boolean.TRUE);
origin: org.objectstyle.ashwood/ashwood

public static boolean isConnected(Digraph digraph) {
 return isConnected(digraph, digraph.vertexIterator().next(), digraph.order());
}
origin: org.objectstyle.ashwood/ashwood

private void init(Digraph digraph) {
 vertexRankMap = new HashMap(digraph.order());
 IndegreeTopologicalSort traversal = new IndegreeTopologicalSort(digraph);
 while (traversal.hasNext()) {
  Object vertex = traversal.next();
  int rank = -1;
  for (ArcIterator i = digraph.incomingIterator(vertex); i.hasNext(); ) {
   i.next();
   Object predecessor = i.getOrigin();
   int predRank = intValue(predecessor);
   if (predRank < 0)
    throw new ArithmeticException("Ranking failed.");
   rank = Math.max(rank, predRank);
  }
  rank++;
  assignRank(vertex, rank);
 }
}
origin: org.objectstyle.ashwood/ashwood

public boolean addVertex(Object vertex) {
 return digraph.addVertex(vertex);
}
origin: org.objectstyle.ashwood/ashwood

public Object putArc(Object origin, Object destination, Object arc) {
 return digraph.putArc(destination, origin, arc);
}
origin: org.objectstyle.ashwood/ashwood

public Digraph positionArcs() {
 Digraph arcGeometryDigraph = new MapDigraph();
 for (ArcIterator i = longArcDigraph.arcIterator(); i.hasNext(); ) {
  LayerVertex dummy = (LayerVertex)i.next();
  LayerVertex origin = (LayerVertex)i.getOrigin();
  y = y1 - h;
  points.add(new Point((int)x, (int)y));
  arcGeometryDigraph.putArc(origin.getUserVertex(), dst.getUserVertex(), points);
origin: org.objectstyle.ashwood/ashwood

 public boolean evaluate(Object vertex) {
  return LoopSearch.this.digraph.hasArc(vertex, vertex);
 }
});
origin: org.objectstyle.ashwood/ashwood

public boolean addAllVertices(Collection vertices) {
 return digraph.addAllVertices(vertices);
}
org.objectstyle.ashwood.graphDigraph

Most used methods

  • addVertex
  • containsVertex
  • order
  • putArc
  • addAllVertices
  • arcIterator
  • containsAllVertices
  • getArc
  • hasArc
  • incomingIterator
  • incomingSize
  • isEmpty
  • incomingSize,
  • isEmpty,
  • isIncomingEmpty,
  • isOutgoingEmpty,
  • outgoingIterator,
  • outgoingSize,
  • removeAllVertices,
  • removeArc,
  • removeIncoming,
  • removeOutgoing

Popular in Java

  • Creating JSON documents from java classes using gson
  • getSharedPreferences (Context)
  • startActivity (Activity)
  • runOnUiThread (Activity)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • BitSet (java.util)
    This class implements a vector of bits that grows as needed. Each component of the bit set has a boo
  • Locale (java.util)
    A Locale object represents a specific geographical, political, or cultural region. An operation that
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now