Interface ObjectGraph<T>

  • All Known Subinterfaces:
    StringGraph

    public interface ObjectGraph<T>
    Author:
    Tim Boudreau
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      List<Score<T>> apply​(RankingAlgorithm<?> alg)  
      Set<T> bottomLevelNodes()
      Get the set of nodes which have no outbound edges.
      List<T> byClosureSize()
      Get a list of the nodes in the graph sorted by the size of their closure.
      List<T> byReverseClosureSize()
      Get a list of the nodes in the graph sorted by the size of their reverse closure (all paths to the top of the graph from this node).
      Set<T> children​(T node)
      Get the set of string node names which are immediate child nodes of a given one (if the graph is cyclic, this may include the node name passed).
      Set<T> closureOf​(T node)
      Get the closure of this node in the graph - all nodes which are reachable following outbound edges from this node and its descendants.
      int closureSize​(T node)
      Determine the size of the closure of this node, following outbound edges to the bottom of the graph, traversing each node once.
      default Set<T> disjunctionOfClosureOfHighestRankedNodes()
      This requires some explaining - it is used to pick the initial set of colorings that are active - attempting to find nodes that are likely to be ones someone would want flagged.
      default int distance​(T a, T b)
      Get the distance along the shortest path between two node.
      Set<String> edgeStrings()
      For logging convenience, get a list of strings that identify the edges present in this graph.
      default List<Score<T>> eigenvectorCentrality()
      Compute the eigenvector centrality - "most likely to be connected *through*" - score for each node.
      int inboundReferenceCount​(T node)
      Count the number of nodes that have outbound edges to the passed node.
      boolean isUnreferenced​(T node)
      Returns true if this node has no inbound edges.
      int outboundReferenceCount​(T node)
      Count the number of nodes this node has outbound edges to.
      default List<Score<T>> pageRank()
      Compute the pagerank score of every node in the graph.
      Set<T> parents​(T node)
      Get the set of strings which are immediate parent nodes to a given one (if the graph is cyclic, this may include the node name passed).
      List<ObjectPath<T>> pathsBetween​(T a, T b)  
      Set<T> reverseClosureOf​(T node)
      Get the reverse closure of a node in the graph - all nodes which have an outbound edge to this node, and all nodes which have an outbound edge to one of those, and so forth, to the top of the graph.
      int reverseClosureSize​(T node)
      Determine the size of the inverse closure of this node, following inbound edges to the top of the graph, traversing each node once.
      void save​(ObjectOutput out)
      Optimized serialization support.
      T toNode​(int index)  
      int toNodeId​(T name)  
      Set<T> topLevelOrOrphanNodes()
      Get the set of nodes which have no inbound edges.
      default void walk​(ObjectGraphVisitor<? super T> v)
      Walk the tree of nodes in some order, such that each node is only visited once.
      default void walk​(T startingWith, ObjectGraphVisitor<? super T> v)
      Walk the tree of node definitions and node references in some order, starting from the passed starting node.
      default void walkUpwards​(T startingWith, ObjectGraphVisitor<? super T> v)
      Walk the antecedents of a node.
    • Method Detail

      • byClosureSize

        List<T> byClosureSize()
        Get a list of the nodes in the graph sorted by the size of their closure.
        Returns:
        A list of string node names
      • byReverseClosureSize

        List<T> byReverseClosureSize()
        Get a list of the nodes in the graph sorted by the size of their reverse closure (all paths to the top of the graph from this node).
        Returns:
        A list of string node names
      • edgeStrings

        Set<String> edgeStrings()
        For logging convenience, get a list of strings that identify the edges present in this graph.
        Returns:
      • parents

        Set<T> parents​(T node)
        Get the set of strings which are immediate parent nodes to a given one (if the graph is cyclic, this may include the node name passed).
        Parameters:
        node - A node name
        Returns:
        The set of parents
      • children

        Set<T> children​(T node)
        Get the set of string node names which are immediate child nodes of a given one (if the graph is cyclic, this may include the node name passed).
        Parameters:
        node - The node name
        Returns:
        A set of child node names
      • inboundReferenceCount

        int inboundReferenceCount​(T node)
        Count the number of nodes that have outbound edges to the passed node. Will be zero if it has none.
        Parameters:
        node - The node name
        Returns:
        A count of edges
      • outboundReferenceCount

        int outboundReferenceCount​(T node)
        Count the number of nodes this node has outbound edges to.
        Parameters:
        node - The node name
        Returns:
        A count of edges
      • topLevelOrOrphanNodes

        Set<T> topLevelOrOrphanNodes()
        Get the set of nodes which have no inbound edges.
        Returns:
        A set of node names
      • bottomLevelNodes

        Set<T> bottomLevelNodes()
        Get the set of nodes which have no outbound edges.
        Returns:
        A set of nodes
      • isUnreferenced

        boolean isUnreferenced​(T node)
        Returns true if this node has no inbound edges.
        Parameters:
        node - A node
        Returns:
        Whether or not it has inbound edges
      • closureSize

        int closureSize​(T node)
        Determine the size of the closure of this node, following outbound edges to the bottom of the graph, traversing each node once.
        Parameters:
        node - A node
        Returns:
        The size of its closure
      • reverseClosureSize

        int reverseClosureSize​(T node)
        Determine the size of the inverse closure of this node, following inbound edges to the top of the graph, traversing each node once.
        Parameters:
        node -
        Returns:
      • reverseClosureOf

        Set<T> reverseClosureOf​(T node)
        Get the reverse closure of a node in the graph - all nodes which have an outbound edge to this node, and all nodes which have an outbound edge to one of those, and so forth, to the top of the graph.
        Parameters:
        node - A node name
        Returns:
        A set of nodes
      • closureOf

        Set<T> closureOf​(T node)
        Get the closure of this node in the graph - all nodes which are reachable following outbound edges from this node and its descendants.
        Parameters:
        node - A node name
        Returns:
        A set of nodes
      • walk

        default void walk​(ObjectGraphVisitor<? super T> v)
        Walk the tree of nodes in some order, such that each node is only visited once.
        Parameters:
        v - A visitor
      • walk

        default void walk​(T startingWith,
                          ObjectGraphVisitor<? super T> v)
        Walk the tree of node definitions and node references in some order, starting from the passed starting node.
        Parameters:
        startingWith - The starting node
        v - A visitor
      • walkUpwards

        default void walkUpwards​(T startingWith,
                                 ObjectGraphVisitor<? super T> v)
        Walk the antecedents of a node.
        Parameters:
        startingWith - The starting node
        v - A visitor
      • distance

        default int distance​(T a,
                             T b)
        Get the distance along the shortest path between two node.
        Parameters:
        a - One node
        b - Another node
        Returns:
        the distance
      • eigenvectorCentrality

        default List<Score<T>> eigenvectorCentrality()
        Compute the eigenvector centrality - "most likely to be connected *through*" - score for each node. This finds nodes which are most critical - connectors - in the node graph.
        Returns:
      • pageRank

        default List<Score<T>> pageRank()
        Compute the pagerank score of every node in the graph.
        Returns:
      • disjunctionOfClosureOfHighestRankedNodes

        default Set<T> disjunctionOfClosureOfHighestRankedNodes()
        This requires some explaining - it is used to pick the initial set of colorings that are active - attempting to find nodes that are likely to be ones someone would want flagged. The algorithm is this: Rank the nodes according to their pagerank. That typically gets important but common grammar elements such as "expression" or "arguments". Take the top third of those nodes - these will be the most connected to nodes. Then take the closure of each of those - the set of nodes it or nodes it calls touches, and xor them to get the disjunction of their closures. That gives you those nodes which are called indirectly or directly by *one* of the highly ranked nodes, but none of the others. These have a decent chance of being unique things one would like distinct syntax highlighting for.
        Returns:
      • toNodeId

        int toNodeId​(T name)
      • toNode

        T toNode​(int index)