Class RootGraph

java.lang.Object
noduledistances.imagej.RootGraph

public class RootGraph extends Object
The purpose of the class RootGraph is to hold all information related to the graph derived from the initial image, including the data and methods to translate between the abstract graph and the point and edges on the skeleton of the image. The class also holds all computational methods relating to the abstract graph.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Node is an extension of java.awt.point that includes an identifier for the node, i.e.
    int
     
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    RootGraph(ArrayList<ArrayList<int[]>> skeleton, GraphOverlay graphOverlay)
    constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addEdge(Node[] edge)
    Adds an edge to the graph.
    void
    addNodules(ArrayList<int[]> nodLocations)
    adds the set of nodules as Node objects to the graph by connecting each nodule node to the nearest node currently within the graph with an edge.
    ArrayList<int[]>
    ballSubgraph(int numNodes, Point2D pt)
    Find the numNodes closest Nodes to the given pt, and finds all edges that contain any of those nodes.
    ArrayList<ij.gui.ShapeRoi>
    ballSubgraphLines(int numNodes, Point2D pt)
    Find the numNods closest nodes to the given point, then creates an arrayList of lines that are all edges containing any of the closest nodes.
    i.e. it records all edges containing the numNodes closest nodes, returning them as Roi objects.
    protected int
    computeLengthOfPath(List<edu.asu.emit.algorithm.graph.abstraction.BaseVertex> path)
    Computes the length of the given path. i.e. the sum of the lengths of the lines between each arc in the path.
    void
    computeShortestDistances(int numIterations)
    Computes and stores the all-pairs distance calculations between all Nodules numIteration times.
    boolean
    containsEdge(int a, int b)
    Checks whether the graph contains the edge [a,b].
    protected com.programmerare.edu.asu.emit.algorithm.graph.GraphWithConstructor
    creates a graph structure using Yan Qi's graph package to utilize their implementation of k shortest paths.
    Finds searches for all in-arcs of the given node.
     
    void
    Used to merge disconnected parts of the graph to create one connected graph.
    ArrayList<int[]>
    Returns the subgraph that is all edges containing a nodule node as at least one of the nodes.
    void
    removeEdge(Node[] nodeEdge)
    method for removing the given edge.
    protected ArrayList<int[]>
    shortestPathsToList(List<edu.asu.emit.algorithm.graph.Path> shortest_paths_list)
    converts the list of computed shortest paths to an ArrayList of Arrays of ints.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • skeleton

      public ArrayList<ArrayList<int[]>> skeleton
    • numNodules

      public int numNodules
    • nodes

      public ArrayList<Node> nodes
      Node is an extension of java.awt.point that includes an identifier for the node, i.e. Node.type == 0 -> skeleton node type == 1 -> red nodule type == 2 -> green nodule type == 3 -> mixed nodule
  • Constructor Details

    • RootGraph

      public RootGraph(ArrayList<ArrayList<int[]>> skeleton, GraphOverlay graphOverlay)
      constructor. Constructs the graph object from the skeleton. LingDong's algorithm wasn't designed to convert the skeleton into a graph, so sometimes the graph becomes disconnected when the provided object it's skeletonizing is connected. We attempt to amend this by saying that any two nodes from the skeleton are the same if they are within 8 pixels (refer to Node.equals). We also add edges at the end if two nodes are within 9 pixels.
      Parameters:
      skeleton - : skeleton object from LingDong's skeletonization algorithm.
      graphOverlay - : graphOverlay object which holds the root system image and the graph overlaying it.
  • Method Details

    • addEdge

      public void addEdge(Node[] edge)
      Adds an edge to the graph.
      Parameters:
      edge - : edge to add to the graph.
    • removeEdge

      public void removeEdge(Node[] nodeEdge)
      method for removing the given edge.
      Parameters:
      nodeEdge - : edge to remove. nodeEdge should be an array of size 2, one for each endpoint of the edge
    • mergeNonemptyComponents

      public void mergeNonemptyComponents(ArrayList<int[]> components)
      Used to merge disconnected parts of the graph to create one connected graph.
      Parameters:
      components - : parts of the graph that are disconnected.
    • getInstances

      public ArrayList<Point[]> getInstances(Point node)
      Finds searches for all in-arcs of the given node.
      Parameters:
      node - : node to find the in-arc for
      Returns:
      : all points who has arcs entering the given node.
    • addNodules

      public void addNodules(ArrayList<int[]> nodLocations)
      adds the set of nodules as Node objects to the graph by connecting each nodule node to the nearest node currently within the graph with an edge.
      Parameters:
      nodLocations - a list of x,y coordinates of the contour centroids of the polygon outlines of the nodules.
    • containsEdge

      public boolean containsEdge(int a, int b)
      Checks whether the graph contains the edge [a,b].
      Parameters:
      a - : source node of arc in question.
      b - : sink node of arc in question.
      Returns:
      : true if such an arc exists. False otherwise.
    • computeShortestDistances

      public void computeShortestDistances(int numIterations)
      Computes and stores the all-pairs distance calculations between all Nodules numIteration times. In each iteration, we remove a different edge
      Parameters:
      numIterations - : the number of times we compute the distance calculations.
    • shortestPathsToList

      protected ArrayList<int[]> shortestPathsToList(List<edu.asu.emit.algorithm.graph.Path> shortest_paths_list)
      converts the list of computed shortest paths to an ArrayList of Arrays of ints.
      Parameters:
      shortest_paths_list - : object to convert.
      Returns:
      : converted object.
    • computeLengthOfPath

      protected int computeLengthOfPath(List<edu.asu.emit.algorithm.graph.abstraction.BaseVertex> path)
      Computes the length of the given path. i.e. the sum of the lengths of the lines between each arc in the path.
      Parameters:
      path - : path to compute the length of.
      Returns:
      : length of the given path.
    • convertToYanGraph

      protected com.programmerare.edu.asu.emit.algorithm.graph.GraphWithConstructor convertToYanGraph()
      creates a graph structure using Yan Qi's graph package to utilize their implementation of k shortest paths.
      Returns:
      YanQi's graph object.
    • getNodules

      public Node[] getNodules()
      Returns:
      : the set of nodes of the graph that are nodules.
    • ballSubgraphLines

      public ArrayList<ij.gui.ShapeRoi> ballSubgraphLines(int numNodes, Point2D pt)
      Find the numNods closest nodes to the given point, then creates an arrayList of lines that are all edges containing any of the closest nodes.
      i.e. it records all edges containing the numNodes closest nodes, returning them as Roi objects.
      Parameters:
      numNodes - : number of nodes to find the edges of
      pt - : point to search around.
      Returns:
      : an arraylist of ShapeRoi lines which are the edges containing the edges of the numNodes closest nodes.
    • ballSubgraph

      public ArrayList<int[]> ballSubgraph(int numNodes, Point2D pt)
      Find the numNodes closest Nodes to the given pt, and finds all edges that contain any of those nodes.
      Parameters:
      numNodes - : number of nodes to find.
      pt - : point to search around.
      Returns:
      : subgraph containing the numNodes closest nodes and all edges related to,them.
    • noduleFSRep

      public ArrayList<int[]> noduleFSRep()
      Returns the subgraph that is all edges containing a nodule node as at least one of the nodes.
      Returns:
      The forward star representation as an ArrayList of Arrays of ints.