congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
Graph
Code IndexAdd Tabnine to your IDE (free)

How to use
Graph
in
org.antlr.misc

Best Java code snippets using org.antlr.misc.Graph (Showing top 17 results out of 315)

origin: stackoverflow.com

 public boolean isPath(Graph graph, Node start, Node target) {
  for (Node node : graph.getNode()) {
    if (node != null) {
      node.state = State.Unvisited;
    }
  }

  dfs(start);

  return target.state == State.Visited;
}
origin: antlr/antlr3

  public void DFS(Node<T> n, Set<Node<T>> visited, ArrayList<T> sorted) {
    if ( visited.contains(n) ) return;
    visited.add(n);
    if ( n.edges!=null ) {
      for (Node<T> target : n.edges) {
        DFS(target, visited, sorted);
      }
    }
    sorted.add(n.payload);
  }
}
origin: antlr/antlr3

public void sortGrammarFiles() throws IOException {
  Graph<String> g = new Graph<String>();
  List<String> missingFiles = new ArrayList<String>();
  for (String gfile : grammarFileNames) {
      String grammarName = grammar.getGrammarName();
      if ( vocabName!=null ) g.addEdge(gfile, vocabName+CodeGenerator.VOCAB_FILE_EXTENSION);
      g.addEdge(grammarName+CodeGenerator.VOCAB_FILE_EXTENSION, gfile);
  List<String> sorted = g.sort();
origin: com.ning.billing/killbill-osgi-bundles-analytics

public void sortGrammarFiles() throws IOException {
  Graph g = new Graph();
  List<String> missingFiles = new ArrayList<String>();
  for (String gfile : grammarFileNames) {
      String grammarName = grammar.getGrammarName();
      if ( vocabName!=null ) g.addEdge(gfile, vocabName+CodeGenerator.VOCAB_FILE_EXTENSION);
      g.addEdge(grammarName+CodeGenerator.VOCAB_FILE_EXTENSION, gfile);
  List<Object> sorted = g.sort();
origin: org.xtext/antlr-generator

public void sortGrammarFiles() throws IOException {
  Graph g = new Graph();
  List<String> missingFiles = new ArrayList<String>();
  for (String gfile : grammarFileNames) {
      String grammarName = grammar.getGrammarName();
      if ( vocabName!=null ) g.addEdge(gfile, vocabName+CodeGenerator.VOCAB_FILE_EXTENSION);
      g.addEdge(grammarName+CodeGenerator.VOCAB_FILE_EXTENSION, gfile);
  List<Object> sorted = g.sort();
origin: antlr/antlr3

  public void DFS(Node<T> n, Set<Node<T>> visited, ArrayList<T> sorted) {
    if ( visited.contains(n) ) return;
    visited.add(n);
    if ( n.edges!=null ) {
      for (Node<T> target : n.edges) {
        DFS(target, visited, sorted);
      }
    }
    sorted.add(n.payload);
  }
}
origin: antlr/antlr3

public void addEdge(T a, T b) {
  //System.out.println("add edge "+a+" to "+b);
  Node<T> a_node = getNode(a);
  Node<T> b_node = getNode(b);
  a_node.addEdge(b_node);
}
origin: antlr/antlr3

public void sortGrammarFiles() throws IOException {
  Graph<String> g = new Graph<String>();
  List<String> missingFiles = new ArrayList<String>();
  for (String gfile : grammarFileNames) {
      String grammarName = grammar.getGrammarName();
      if ( vocabName!=null ) g.addEdge(gfile, vocabName+CodeGenerator.VOCAB_FILE_EXTENSION);
      g.addEdge(grammarName+CodeGenerator.VOCAB_FILE_EXTENSION, gfile);
  List<String> sorted = g.sort();
origin: com.ning.billing/killbill-osgi-bundles-analytics

  public void DFS(Node n, Set<Node> visited, ArrayList<Object> sorted) {
    if ( visited.contains(n) ) return;
    visited.add(n);
    if ( n.edges!=null ) {
      for (Iterator it = n.edges.iterator(); it.hasNext();) {
        Node target = (Node) it.next();
        DFS(target, visited, sorted);
      }
    }
    sorted.add(n.payload);
  }
}
origin: com.ning.billing/killbill-osgi-bundles-analytics

public void addEdge(Object a, Object b) {
  //System.out.println("add edge "+a+" to "+b);
  Node a_node = getNode(a);
  Node b_node = getNode(b);
  a_node.addEdge(b_node);
}
origin: org.xtext/antlr-generator

  public void DFS(Node n, Set<Node> visited, ArrayList<Object> sorted) {
    if ( visited.contains(n) ) return;
    visited.add(n);
    if ( n.edges!=null ) {
      for (Iterator it = n.edges.iterator(); it.hasNext();) {
        Node target = (Node) it.next();
        DFS(target, visited, sorted);
      }
    }
    sorted.add(n.payload);
  }
}
origin: antlr/antlr3

public void addEdge(T a, T b) {
  //System.out.println("add edge "+a+" to "+b);
  Node<T> a_node = getNode(a);
  Node<T> b_node = getNode(b);
  a_node.addEdge(b_node);
}
origin: org.xtext/antlr-generator

/** DFS-based topological sort.  A valid sort is the reverse of
 *  the post-order DFA traversal.  Amazingly simple but true.
 *  For sorting, I'm not following convention here since ANTLR
 *  needs the opposite.  Here's what I assume for sorting:
 *
 *    If there exists an edge u -> v then u depends on v and v
 *    must happen before u.
 *
 *  So if this gives nonreversed postorder traversal, I get the order
 *  I want.
 */
public List<Object> sort() {
  Set<Node> visited = new HashSet<Node>();
  ArrayList<Object> sorted = new ArrayList<Object>();
  while ( visited.size() < nodes.size() ) {
    // pick any unvisited node, n
    Node n = null;
    for (Iterator it = nodes.values().iterator(); it.hasNext();) {
      n = (Node)it.next();
      if ( !visited.contains(n) ) break;
    }
    DFS(n, visited, sorted);
  }
  return sorted;
}
origin: org.xtext/antlr-generator

public void addEdge(Object a, Object b) {
  //System.out.println("add edge "+a+" to "+b);
  Node a_node = getNode(a);
  Node b_node = getNode(b);
  a_node.addEdge(b_node);
}
origin: antlr/antlr3

/** DFS-based topological sort.  A valid sort is the reverse of
 *  the post-order DFA traversal.  Amazingly simple but true.
 *  For sorting, I'm not following convention here since ANTLR
 *  needs the opposite.  Here's what I assume for sorting:
 *
 *    If there exists an edge u &rarr; v then u depends on v and v
 *    must happen before u.
 *
 *  So if this gives nonreversed postorder traversal, I get the order
 *  I want.
 */
public List<T> sort() {
  Set<Node<T>> visited = new OrderedHashSet<Node<T>>();
  ArrayList<T> sorted = new ArrayList<T>();
  while ( visited.size() < nodes.size() ) {
    // pick any unvisited node, n
    Node<T> n = null;
    for (Node<T> tNode : nodes.values()) {
      n = tNode;
      if ( !visited.contains(n) ) break;
    }
    DFS(n, visited, sorted);
  }
  return sorted;
}
origin: com.ning.billing/killbill-osgi-bundles-analytics

/** DFS-based topological sort.  A valid sort is the reverse of
 *  the post-order DFA traversal.  Amazingly simple but true.
 *  For sorting, I'm not following convention here since ANTLR
 *  needs the opposite.  Here's what I assume for sorting:
 *
 *    If there exists an edge u -> v then u depends on v and v
 *    must happen before u.
 *
 *  So if this gives nonreversed postorder traversal, I get the order
 *  I want.
 */
public List<Object> sort() {
  Set<Node> visited = new OrderedHashSet<Node>();
  ArrayList<Object> sorted = new ArrayList<Object>();
  while ( visited.size() < nodes.size() ) {
    // pick any unvisited node, n
    Node n = null;
    for (Iterator it = nodes.values().iterator(); it.hasNext();) {
      n = (Node)it.next();
      if ( !visited.contains(n) ) break;
    }
    DFS(n, visited, sorted);
  }
  return sorted;
}
origin: antlr/antlr3

/** DFS-based topological sort.  A valid sort is the reverse of
 *  the post-order DFA traversal.  Amazingly simple but true.
 *  For sorting, I'm not following convention here since ANTLR
 *  needs the opposite.  Here's what I assume for sorting:
 *
 *    If there exists an edge u &rarr; v then u depends on v and v
 *    must happen before u.
 *
 *  So if this gives nonreversed postorder traversal, I get the order
 *  I want.
 */
public List<T> sort() {
  Set<Node<T>> visited = new OrderedHashSet<Node<T>>();
  ArrayList<T> sorted = new ArrayList<T>();
  while ( visited.size() < nodes.size() ) {
    // pick any unvisited node, n
    Node<T> n = null;
    for (Node<T> tNode : nodes.values()) {
      n = tNode;
      if ( !visited.contains(n) ) break;
    }
    DFS(n, visited, sorted);
  }
  return sorted;
}
org.antlr.miscGraph

Javadoc

A generic graph with edges; Each node as a single Object payload. This is only used to topologically sort a list of file dependencies at the moment.

Most used methods

  • getNode
  • <init>
  • DFS
  • addEdge
  • sort
    DFS-based topological sort. A valid sort is the reverse of the post-order DFA traversal. Amazingly s

Popular in Java

  • Making http post requests using okhttp
  • setScale (BigDecimal)
  • getSystemService (Context)
  • compareTo (BigDecimal)
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • Sublime Text for Python
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now